SELECT top 3 id,sname,bchara... from pc_bbsmotif  
WHERE attribute=10 and Estate='T'
UNION  
SELECT top 7 id,sname,bchara... from pc_bbsmotif  
WHERE attribute=10 and Estate<>'T'
ORDER BY Estate,etime DESC
如果排序不对,你就改一下Estate为降序就OK了

解决方案 »

  1.   

    建议 estate 用int 类型,默认为 1 ,制定的贴为 0SELECT top 10 id,sname,bchara... from pc_bbsmotif  WHERE attribute=10 ORDER BY estate asc,etime DESC或者建议 estate 用varcher 类型,默认为 'b' ,制定的贴为 'a'SELECT top 10 id,sname,bchara... from pc_bbsmotif  WHERE attribute=10 ORDER BY estate asc,etime DESC
      

  2.   

    没看清楚题目,yujohny(踏网无痕) 的应该是正确的,但条件有些不对,我改一下:SELECT top 3 id,sname,bchara... from pc_bbsmotif  
    WHERE attribute=10 and Estate='T' ORDER BY etime DESC
    UNION  
    SELECT top 7 id,sname,bchara... from pc_bbsmotif  
    WHERE attribute=10 and Estate<>'T'
    ORDER BY etime DESC
      

  3.   

    select id,sname,bchara... 
    from (SELECT top 3 id,sname,bchara...  from pc_bbsmotif  
          WHERE attribute=10 and Estate='T'
          ORDER BY etime DESC) A
    UNION  
    select id,sname,bchara... 
    from (SELECT top 7 id,sname,bchara... from pc_bbsmotif  
          WHERE attribute=10 and id not in (SELECT top 3 id,sname,bchara...  from pc_bbsmotif  
          WHERE attribute=10 and Estate='T'
          ORDER BY etime DESC) C
          ORDER BY etime DESC) B
      

  4.   

    sql server服务器地址:61.145.112.134
    用户名:d12190
    密 码:cnnbpc