两道SQL面试题目

来源:互联网 发布:linux如何查看网络连接 编辑:程序博客网 时间:2024/04/30 18:12
 
两道SQL面试题目

在面试过程中多次碰到两道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

原创粉丝点击