如何查询出某些记录的第一条记录的某个字段?
Num Name Time
1 a 2009/05/01
1 a 2009/05/02
1 a 2009/05/03
2 b 2009/05/04
2 b 2009/05/05
假如上面的记录,我想只查出第一条记录的time字段和最后一条记录的time字段,sql语句如何写呢?
------解决方案--------------------select top 1 times from TB
union all
select top 1 times from(select rid=ROW_NUMBER() over(order by getdate()),* from TB) t
order by rid desc