--假设表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

解决方案 »

  1.   

    这么写会不会有问题? 前台程序并发访问量很大,而且数据量也很大。
    如果某个用户没有完全打开页面,就停止了。
    那么 into #t 跟 drop table #t 就很可能出现问题吧? 比如into #t出现 #t已存在
      

  2.   

    --这个问题好解决,但是我担心的是,效果对不对.楼主可以把测试数据传过来吗?站内传也行.
    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)
      

  3.   

    要不你创建一个视图吧
    select top 60 *
    from ta
    where type='2' or link='1'
    order  by  convert(bigint,vote)desc,id
    一般来说分页语句都是用两个top实现的.