sql函数last()不是一个公认的函数 [英] sql function last() is not a recognized function

查看:148
本文介绍了sql函数last()不是一个公认的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的sql server 2008 DB上使用Last()函数,以拉出表上的最后一条记录。
更具体,我使用的查询是:

I am trying to use the Last() function on my sql server 2008 DB in order to pull out the last record on the table. to be more specific, the query I'm using is:

select Last(Id_Number) as id from table1

异常,我以这种方式开始,并继续后的..但点在第一行:

the exception I get starts this way and continue long after.. but the point is at the first line:

http://prntscr.com/1d4o6y

我可以做什么?

推荐答案

记录您有一个标识列(或最大的值代表最后一条记录的列):

If you want the last record and you have an identity column (or a column where the largest value would represent the last record):

select top 1 t.*
from t
order by id desc;

这篇关于sql函数last()不是一个公认的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆