select IDENTITY(int,1,1) as aid,* into ##temp FROM LOWMAINgo1st 100: select * from ##temp where aid <=100 2nd 100: select * from ##temp where aid >100 and aid <=200 3th 100: select * from ##temp where aid >200 and aid <=300 ...
怎样利用SQL语句进行分页显示select Top pageSize * from T where SortField NOT IN (select Top pageSize*pagei SortField from T order by SortField ) order by SortField例如,每页7条,列印第7页: select Top 10 * from T where SortField NOT IN (select Top 70 SortField from T order by SortField ) order by SortField
--if有ID列 select top 100 from Utable where ID not in (select top 200 ID from Utable)
---if need sort select top 100 from Utable where ID not in (select top 200 ID from Utable order by ID ) order by ID--if not 有ID列 select identity(int,1,1) as ID ,* into #T from Utable --order by.... select top 100 from #T where ID not in (select top 200 ID from #T)
select * from ##temp where aid <=100
2nd 100:
select * from ##temp where aid >100 and aid <=200
3th 100:
select * from ##temp where aid >200 and aid <=300
...
from T
where SortField NOT IN (select Top pageSize*pagei SortField
from T
order by SortField )
order by SortField例如,每页7条,列印第7页:
select Top 10 *
from T
where SortField NOT IN (select Top 70 SortField
from T
order by SortField )
order by SortField
select top 100 from Utable
where ID not in (select top 200 ID from Utable)
---if need sort
select top 100 from Utable
where ID not in (select top 200 ID from Utable order by ID )
order by ID--if not 有ID列
select identity(int,1,1) as ID ,*
into #T from Utable
--order by....
select top 100 from #T
where ID not in (select top 200 ID from #T)