--假设表table中am_id为主键
select top 60 * into #t
from ta
where type='2' or link='1'
order by convert(bigint,vote)desc,id select top 30 id, userid, name, fcer, vote
from #t
where am_id not in( select top 30 am_id from #t)drop table #t
select top 60 * into #t
from ta
where type='2' or link='1'
order by convert(bigint,vote)desc,id select top 30 id, userid, name, fcer, vote
from #t
where am_id not in( select top 30 am_id from #t)drop table #t
解决方案 »
- 大侠们看看这个SQL语句怎么优化
- 多表连接查询问题
- 触发器的一个小问题。
- 主键,外键,唯一键,他们有什么区别??
- DISTINCT && DISTINCTROW 为何 DISTINCTROW会SQL 关键字中没有出现??急求!
- 查询语句改存储过程问题
- 从表A中检索一条记录插入表B中??
- 怎样才能将一个.bak文件Restore到一个新的数据库中?
- 请问一下sql7.0能不能访问sql2000?
- 存储过程中update的表格怎么用output导出
- 请问,怎样判断varchar型字段中的记录是不是数字?
- 我要select 一个5个字段的表,但我不知道这个表的各个字段名,我只知道我要的字段是第2列,请问如何写
如果某个用户没有完全打开页面,就停止了。
那么 into #t 跟 drop table #t 就很可能出现问题吧? 比如into #t出现 #t已存在
select top 30 id, userid, name, fcer, vote
from (select top 60 *
from ta
where type='2' or link='1'
order by convert(bigint,vote)desc,id) t
where am_id not in( select top 30 am_id
from ta
where type='2' or link='1'
order by convert(bigint,vote)desc,id)
select top 60 *
from ta
where type='2' or link='1'
order by convert(bigint,vote)desc,id
一般来说分页语句都是用两个top实现的.