Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我试图从我的数据库中检索最后一个值时,它会返回第一个值。通过使用以下查询。
SELECT [Id] from dbo.Tb_Patient;
我想得到最后一个值。我应该使用什么查询?
尝试这个
SELECT Top(1) [Id] from dbo.Tb_Patient order by Id desc;
或者,如果Id是 Auto Incremented 列,那么您也可以使用MAX函数来查找最大值。
Id
MAX
SELECT MAX([Id]) from dbo.Tb_Patient