两道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

以上两道题目非常有代表意义,望各位把自己碰到的有代表的查询都贴上来。
posted on 2006-06-25 12:41  foson  阅读(2222)  评论(10编辑  收藏  举报