select * from
(select top 80percent * from table order by id)t
except
(select top 20percent * from table order by id)
在此基础上 查询最大值
select MAX(data1) as maxnum from
(select * from
(select top 80percent * from table order by id)t
except
select top 20percent * from table order by id) tp
查询数据表中 前五条 和后五条数据
SELECT * FROM
(select top 5 * from newnumber order by id )x
UNION ALL
SELECT * FROM
(select top 5 * from newnumber order by id desc)t
还可以这么写
SELECT * FROM
(select top 5 * from newnumber order by id desc)x
UNION ALL
select top 5 * from newnumber order by id
本文介绍了使用SQL进行高效数据查询的方法,包括如何利用子查询、排除特定数据集以及实现分页显示。通过实例展示了查询最大值、获取数据表中前五条和后五条数据的技巧,并对比了不同查询语句的实现方式。
1486

被折叠的 条评论
为什么被折叠?



