在面试过程中多次碰到两道SQL查询的题目,一是查询A(ID,Name)表中第31至40条记录,ID作为主键可能是不是连续增长的列,大家写写看了 !
答案:
select top 10 * from A where ID not in (select top 30 ID from A)
或者
select top 10 * from A where id > (select max(id) from (select top 30 id from A)as A)
在面试过程中多次碰到两道SQL查询的题目,一是查询A(ID,Name)表中第31至40条记录,ID作为主键可能是不是连续增长的列,大家写写看了 !
答案:
select top 10 * from A where ID not in (select top 30 ID from A)
或者
select top 10 * from A where id > (select max(id) from (select top 30 id from A)as A)