请教怎么样选择最末一条记录?
怎么样选择最末一条记录?
[解决办法]
有ID吗?
select top 1 * from tb order by id desc
[解决办法]
如果没有任何排序.
declare @num as int
select @num = count(*) from authors
set @num = @num - 1 --这里的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)