标签:语句 style span str 16px 法律 href fine ima
| ylbtech-SQL-W3School-函数:SQL LAST() 函数 |
| 1.返回顶部 |
LAST() 函数返回指定的字段中最后一个记录的值。
提示:可使用 ORDER BY 语句对记录进行排序。
SELECT LAST(column_name) FROM table_name
我们拥有下面这个 "Orders" 表:
| O_Id | OrderDate | OrderPrice | Customer |
|---|---|---|---|
| 1 | 2008/12/29 | 1000 | Bush |
| 2 | 2008/11/23 | 1600 | Carter |
| 3 | 2008/10/05 | 700 | Bush |
| 4 | 2008/09/28 | 300 | Bush |
| 5 | 2008/08/06 | 2000 | Adams |
| 6 | 2008/07/21 | 100 | Carter |
现在,我们希望查找 "OrderPrice" 列的最后一个值。
我们使用如下 SQL 语句:
SELECT LAST(OrderPrice) AS LastOrderPrice FROM Orders
结果集类似这样:
| LastOrderPrice |
|---|
| 100 |
| 2.返回顶部 |
| 3.返回顶部 |
| 4.返回顶部 |
| 5.返回顶部 |
| 6.返回顶部 |
| 作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
标签:语句 style span str 16px 法律 href fine ima
原文地址:https://www.cnblogs.com/storebook/p/11827576.html