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
select * from tb where year([time]) =2010 union all select top 10 * from tb order by [time] desc这样做必须两个表的表结构是相同的。
取前10个你可以试一下ms sqlserver 2005 中的row_numbers()函数,例子SELECT top 10 ROW_NUMBER() OVER (ORDER BY EMPID [Time] desc ) AS ROWID, * FROM tb
union all
select top 10 * from tab where Year(Time)=2010
union select * from 表 where time=2010
真郁闷
我想查询时间离现在最近的1条和时间离现在最远的10条,我查询以后排序乱掉了,我希望的是1在前10条在后。
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
union all
select top 10 * from tb order by [time] desc这样做必须两个表的表结构是相同的。