gpt4 book ai didi

mysql - mysql 中 SUM 函数的 SQL 错误代码 1630

转载 作者:行者123 更新时间:2023-11-30 21:53:21 25 4
gpt4 key购买 nike

我正在尝试的代码如下:

SELECT CONCAT(D.DriverFirstName,' ',D.DriverLastName)AS'Full Name',
SUM(T.EndOdometerKM-T.StartODometerKM) AS'Total KM Travelled'
FROM DRIVER AS D, TRIP AS T
WHERE D.DriverLicenceNum=T.DriverLicenceNum
GROUP BY T.DriverLicenceNum
HAVING SUM (T.EndOdometerKM-T.StartOdometerKM)>1000
ORDER BY SUM (T.EndOdometerKM-T.StartOdometerKM)ASC;

但是,我收到此错误消息:

#1630 - FUNCTION dbname.SUM does not exist.

根据其他帖子,问题通常是函数和括号 (SUM (code)) 之间的空格,而不是 (SUM(code)),但我的没有空格,问题仍然存在。

最佳答案

这种方式应该可行

SELECT 
CONCAT(D.DriverFirstName,' ',D.DriverLastName) AS 'Full Name',
SUM(T.EndOdometerKM-T.StartODometerKM) AS 'Total KM Travelled'
FROM DRIVER AS D, TRIP AS T
WHERE D.DriverLicenceNum=T.DriverLicenceNum
GROUP BY T.DriverLicenceNum
HAVING SUM(T.EndOdometerKM-T.StartOdometerKM) > 1000
ORDER BY SUM(T.EndOdometerKM-T.StartOdometerKM) ASC;

关于mysql - mysql 中 SUM 函数的 SQL 错误代码 1630,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46224589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com