我进行了查询,在其中我使用了与原始选择相同的子选择,但条件与原始选择不同,因此无法执行,因为出现此错误:
“在有效句中标识的列或表达式无效,SQLCODE = -119,SQLSTATE = 42803,DRIVER = 4.22.36”
如何更正此查询?
SELECT A.COL1,
count(A.COL2) AS YYY,
sum(A.COL3) AS XXX,
(SELECT count(COL1) AS WWW
from SCH.TAB01
where COL4=A.COL4
AND COL5=A.COL5
AND COL1=A.COL1
AND COL4 = date(days(current date) - 1)
AND COL3 > 5
GROUP BY COL1) AS OOO
from SCH.TAB01 as A
where A.COL4 = date(days(current date) - 1)
GROUP BY A.COL1
答案 0 :(得分:0)
删除子选择中的GROUP BY COL1
顺便说一句,您不需要date(days(current date) - 1)
,简单的CURRENT DATE - 1 DAY
就足够了。