select top问题,急
我现在从一个表中select dfd,dsfa,sum(gg) from tablename where dfd like 'dsf% ' and dsfa= 'dfd ' group by dfd,dsfa
我想分页显示,用select top
但是select dfd,dsfa,sum(gg) from tablename where dfd like 'dsf% ' and dsfa= 'dfd ' group by dfd,dsfa的结果中没有主键!
我用select top 分页有问题,如果我想用临时表,给结果加上主键,再用select top
请问是否可行?应该怎样建临时表,插入主键????并成功分页?????
谢谢!!!!!!!!!!!!!
------解决方案--------------------查询第X页,每页Y条记录
select id=identity(int,1,1),* into #tb from 表
select * from #tb where id between (x-1)*y and x*y-1