SQL SELECT LAST语句

LAST()函数用于返回指定列的最后一个值。
语法SQL SELECT LAST()函数:

SELECT LAST (column_name) FROM table_name;

你应该注意到,LAST()函数在MS Access只支持。但也有方法可以得到在MySQL中,SQL服务器,Oracle等数据库的最后一个记录。
SELECT column_name FROM table_name ORDER BY column_name DESC LIMIT 1;

SELECT TOP 1 column_name FROM table_name ORDER BY column_name DESC;

SELECT column_name FROM table_name ORDER BY column_name DESC WHERE ROWNUM < =1;

让我们以客户的例子来检查SQL SELECT LAST的命令:
Customers表
顾客姓名年龄地址支出
KAMAL SHARMA26GHAZIABAD6000
ROBERT PETT23NEWYORK26000
SHIKHA SRIVASTAV22DELHI9000
【SQL SELECT LAST语句】如果你想从“客户”表中检索“CUSTOMER_NAME”列的最后一个值,你需要编写以下查询:
SELECT LAST (CUSTOMER_NAME) AS LAST_CUSTOMER FROM CUSTOMERS; After that query,you will find the result: SHIKHA SRIVASTAV

    推荐阅读