在面试过程中多次碰到两道SQL查询的题目,一是查询A(ID,Name)表中第31至40条记录,ID作为主键可能是不是连续增长的列,完整的查询语句如下:
select top 10 * from A where ID >(select max(ID) from (select top 30 ID from A order by A ) T) order by A
另外一道题目的要求是查询表A中存在ID重复三次以上的记录,完整的查询语句如下:
select * from(select count(ID) as count from table group by ID)T where T.count>3
两道SQL面试题目
最新推荐文章于 2024-07-25 18:43:45 发布