通过ODBC执行sql命令时出现以下错误。
详细信息:“ODBC:ERROR [42000] [Teradata] [ODBC Teradata驱动程序] [Teradata数据库]语法错误,预期类似于'。'之间的'UDFCALLNAME'关键字。和'SUM'关键字。“
我正在运行的代码正在关注。
SELECT t1.BALANCE_DATE, t1.SUM(LCY_BALANCE) AS TOTAL_DEP, t2.SUM(LCY_BALANCE) AS TOTAL_CASH
FROM
(SELECT LCY_BALANCE, BALANCE_DATE FROM MY_BALANCE_TABLE
WHERE LINE_NUMBER BETWEEN '2300' AND '3311' AND BALANCE_DATE BETWEEN '2015-07-01' AND 2016-06-30' AND BRANCH_CODE = '5520'
GROUP BY BALANCE_DATE) t1
LEFT JOIN
(SELECT LCY_BALANCE, BALANCE_DATE FROM MY_BALANCE_TABLE
WHERE LINE_NUMBER IN ('0040','0050','0060','0105','0110','0115') AND BALANCE_DATE BETWEEN '2015-07-01' AND 2016-06-30' AND BRANCH_CODE = '5520'
GROUP BY BALANCE_DATE) t2
ON
t1.BALANCE_DATE = t2.BALANCE_DATE
可能是错误,请指导。
此致
KAM
答案 0 :(得分:1)
不要限定SUM
:
SELECT t1.BALANCE_DATE,
SUM(t1.LCY_BALANCE) AS TOTAL_DEP,
SUM(t2.LCY_BALANCE) AS TOTAL_CASH
FROM