select * from tb where year([time]) =2010
union all
select top 10 * from tb  order by [time] desc

解决方案 »

  1.   

    select top 10 * from tab order by Time desc
    union all
    select top 10 * from tab where Year(Time)=2010
      

  2.   

    select top 10 * from 表 order by abs(当前时间-time)
    union select * from 表 where time=2010
      

  3.   

    关于重复的已经知道了,使用UNION就可以了,但是如何排序?
      

  4.   

    既然简单你就说啊,用union 不可以排序,加了ALL以后可以,但是会有重复的行
    真郁闷
    我想查询时间离现在最近的1条和时间离现在最远的10条,我查询以后排序乱掉了,我希望的是1在前10条在后。
      

  5.   

    用union 不可以排序,就试下把查询的结果作为一个表,然后再排序,消除重复用下distinct
      

  6.   


    Select  * From(
    select * From (Select * From ChildDiscuss Where ParentID=53 and [Time]=(Select MIN([Time]) From ChildDiscuss c Where c.parentID=53))t1
    union all
    select * From (Select top 5 * From ChildDiscuss Where ParentID=53 order by [Time] desc)t2) t3这样做了也不行呢T T
      

  7.   

    select * from tb where year([time]) =2010
    union all
    select top 10 * from tb  order by [time] desc这样做必须两个表的表结构是相同的。
      

  8.   

    取前10个你可以试一下ms sqlserver 2005 中的row_numbers()函数,例子SELECT top 10 ROW_NUMBER() OVER (ORDER BY EMPID [Time] desc ) AS ROWID, * FROM tb