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

查询表里的最后一条数据?
查询表里的最后一条数据?     没有ID     没有时间     How   to   do   ?

------解决方案--------------------
declare @num as int
select @num = count(*) from authors
set @num = @num - 1

declare @sql as varchar(200)
set @sql = 'select * from authors where au_id not in (select top ' + cast(@num as char) + ' au_id from authors) '
exec (@sql)

------解决方案--------------------
2005实现:
select top 1 *
from (select *,row=row_number() over( order by id) from sysobjects)ta
order by row desc