10万条数据要查出第一和第三条,怎样写sql语句最好
展开全部
select
top
1
*
from
table
order
by
成绩
union
select
top
1
*
from
talbe
where
id
not
in(select
top
2
id
from
table
order
by
成绩)
top
1
*
from
table
order
by
成绩
union
select
top
1
*
from
talbe
where
id
not
in(select
top
2
id
from
table
order
by
成绩)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
子查询
select top 1 * from
(select top 3 * from tb order by col) a order by a.col
union all
select top 1 * from
(select top 3 * from tb order by col) b order by b.col desc
select top 1 * from
(select top 3 * from tb order by col) a order by a.col
union all
select top 1 * from
(select top 3 * from tb order by col) b order by b.col desc
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from TBL where rownum in (1,3)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询