日期:2014-05-18  浏览次数:20517 次

sql 查询第一条记录,和最后一条记录。
查询第一条记录,和最后一条记录。
谢!谢!

------解决方案--------------------
select top 1 * from tb order by id
select top 1 * from tb order by id desc

------解决方案--------------------
SQL code

SELECT * FROM 
(select top 1 * from tb order by id )x
UNION ALL 
SELECT * FROM 
(select top 1 * from tb order by id desc)x

------解决方案--------------------
top
和排序就可以了
------解决方案--------------------

------解决方案--------------------
探讨
select top 1 * from tb order by id
select top 1 * from tb order by id desc


------解决方案--------------------
select top 1 * from tb order by id 
select top 1 * from tb order by id desc