有没有正确的方法SUM(MAX() + MAX())
?
这就是我一直想做的事情
SELECT
SUM(MAX(account.BALANCE1) + MAX(account.BALANCE2)) AS TOTALBALANCE
FROM
account
JOIN
transaction t ON account.PRIMARYKEY = t.ACCOUNTKEY
WHERE
NOT EXISTS( SELECT
1
FROM
transaction a
WHERE
a.ACCOUNTKEY = t.ACCOUNTKEY
AND a.TYPE = 'PAYMENT')
HAVING TOTALBALANCE > 0
它的内容如下:
错误代码:1111。无效使用群组功能
答案 0 :(得分:3)
由于您没有指定任何GROUP BY
子句,
MAX(account.BALANCE1) + MAX(account.BALANCE2)
应该足以满足您的需求。