摘要: 平常工作,尤其是面试中经常遇到这样一个问题,查询表A中31到40条的记录,ID可能是不连续的。(via:女孩礼物网)如果ID连续select * from A where ID between 31 and 40如果ID不连续,提供三种写法--两次对表A查询效率较低select top 10 * from A where ID not in (select top 30 ID from A)--外层查询没有对表A查询,效率大有提高select top 10 * from (select top 40 * from A order by ID) as t order by t.IDdesc--R 阅读全文
posted @ 2012-10-25 11:46 施瓦小辛格 阅读(6691) 评论(59) 推荐(21) 编辑