PKID Name Sex Age 1 张飞 男 1 2 赵云 男 20 3 关羽 男 3 4 刘备 男 5 5 貂蝉 女 15 6 小乔 女 15 7 周瑜 男 15 8 大乔 女 15 9 曹操 男 3 改下数据是这样的, 我写的SQL语句是 select * from (select top 3 * from A1 where PKID not in(select top 3 PKID from A1 order by PKID)order by PKID asc) A1 order by Age asc 查询出来不对,请高手指点下
select top 3 * from (select * from a order by age asc)a where pkid not in(select top 6 pkid from (select * from a order by age asc) b )
select top 3 * from A1 where id not in (select id from A1 order by age) order by age
select top 3 * from A1 where id not in (select top 0 id from A1 order by age) order by age
select top 3 * from (select * from a order by age asc)a where pkid not in(select top 6 pkid from (select * from a order by age asc) b )但是access还要用一个 如果查询条数没有3条时,就会出错! 需要判断一下!
select top 5 * from Tb where UserId not in (select top (n-1)*5 UserID from Tb order by Age asc) order by Age asc
1 张飞 男 1
2 赵云 男 20
3 关羽 男 3
4 刘备 男 5
5 貂蝉 女 15
6 小乔 女 15
7 周瑜 男 15
8 大乔 女 15
9 曹操 男 3
改下数据是这样的,
我写的SQL语句是
select * from (select top 3 * from A1 where PKID not in(select top 3 PKID from A1 order by PKID)order by PKID asc) A1 order by Age asc
查询出来不对,请高手指点下
in(select top 6 pkid from (select * from a order by age asc) b )
in(select top 6 pkid from (select * from a order by age asc) b )但是access还要用一个 如果查询条数没有3条时,就会出错! 需要判断一下!
(select top (n-1)*5 UserID from Tb order by Age asc)
order by Age asc