日期:2014-05-18 浏览次数:20508 次
drop table #table1 create table #table1(id int, name varchar(20)) insert #table1 values(1, 's') insert #table1 values(2, 'c') insert #table1 values(3, 'b') insert #table1 values(4, 'd') insert #table1 values(6, 's') insert #table1 values(8, 't') insert #table1 values(9, 'a') insert #table1 values(10, 'cc') insert #table1 values(11, 'tt') insert #table1 values(13, 'ss') insert #table1 values(14, 'e') insert #table1 values(15, 'b') insert #table1 values(16, 'u') insert #table1 values(17, '9') insert #table1 values(18, 'jj') insert #table1 values(19, 'pp') insert #table1 values(20, 'to') insert #table1 values(21, 'tb') insert #table1 values(22, 'tu') insert #table1 values(23, 'uc') insert #table1 values(24, 'ue') insert #table1 values(25, 'ub') insert #table1 values(26, 'yk') drop table # select (ROW_NUMBER() over(order by id)-1)/10 as rowNo, id, name into # from #table1 select * from # a where id=(select max(id) from # where rowNo=a.rowNo)