我可以在mysql中使用聚合函数(LAST)吗? [英] can i use aggregation function (LAST) in mysql?
本文介绍了我可以在mysql中使用聚合函数(LAST)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在mysql中使用聚合函数(LAST)吗?
如果是,那么为什么给我以下查询错误:
can i use aggregation function (LAST) in mysql??
if yes then why give me error for following query::
SELECT `user_id`,last(`value`)
FROM `My_TABLE`
group by `user_id`
错误 ::您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第1行的'(value
)FROM My_TABLE
group by user_id
'附近使用
ERROR:: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(value
) FROM My_TABLE
group by user_id
' at line 1
编辑 ::我得到的答案是最后一个"未在MySql中使用.那么如何在MySql中执行呢?
EDIT:: I got answer "last" is not used in MySql. then How to perform it in MySql??
推荐答案
不,在mysql中没有所谓的LAST
No, There is nothing called LAST in mysql
请参见聚合函数的列表
编辑
您可以执行类似的操作
select f.user_id, f.value
from (
select MAX(value) as maxval
from my_table group by user_id
) as x inner join my_table as f on f.value = x.maxval
这篇关于我可以在mysql中使用聚合函数(LAST)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文