4503.com 14503.com 2

View Code

(2).外层查询未有对表A进行询问,效用增高。

select top 10 * from A where ID not in (select top 30 ID from A)

2.ID不总是的情形:

4503.com 34503.com 4

4503.com 54503.com 6

4503.com,View Code

上述是团结做的笔记,学习进程中,好记性不比烂笔头,自个儿也记录下来,作为中年人的一片段。

View Code

select * from A where ID between 31 and 40

约略分成二种情景:ID一连和ID不总是。

(3).ROW_NUMBEPAJERO()函数成效更加高,SQL二〇〇七以上版本可用。

(1).一次对表查询,功效超级低。

4503.com 74503.com 8

1.ID连接的情事:

View Code

select top 10 * from (select top 40 ID from A order by ID) as a order by a.ID desc 
1 select * from(select *,ROW_NUMBER() over(order by ID)as 'userID' from A) as a where a.userID between 31 and 40