我有一个转换成这个SQL的学说DQL:
SELECT o0_.id AS ID0,
o0_.pmn AS PMN1,
o0_.neteo AS NETEO2,
sum(o1_.monto_total) AS SCLR3,
o1_.periodo AS PERIODO4,
o1_.pagado AS PAGADO5
FROM operador o0_
LEFT JOIN operador_hub o2_ ON o0_.id = o2_.operador_id
LEFT JOIN outcollect o1_ ON o0_.id = o1_.operador_id
WHERE o0_.ishub = 0
AND o0_.neteo = 1
AND o0_.incluirReportes = 1
AND o0_.pmn NOT IN ('CHLTM', 'CHLCM')
AND o0_.id NOT IN (SELECT o3_.id FROM operador o3_ LEFT JOIN operador_hub o4_ ON o3_.id = o4_.operador_id LEFT JOIN outcollect o5_ ON o3_.id = o5_.operador_id WHERE (o4_.desde <= o5_.periodo AND (o4_.hasta >= o5_.periodo OR o4_.hasta IS NULL)))
AND o0_.activo = 1
GROUP BY o0_.pmn, PERIODO4
ORDER BY o0_.pmn ASC
这会产生ORA-00904: "PERIODO4": identificador no válido
该错误与GROUP BY o0_.pmn,PERIODO4行
直接相关似乎与不能将查询转换为ORACLE语法的学说有关。我正在使用OCI8驱动程序。
有什么想法吗?
----编辑----
这是DQL:
SELECT partial operador.{id, pmn, neteo},
sum(outcollect.montoTotal) as montoOut,
outcollect.periodo as periodo,
outcollect.pagado as pagado
FROM RoamingOperadoresBundle:Operador operador
LEFT JOIN operador.operadorHub operadorHub
LEFT JOIN operador.outcollect outcollect
WHERE operador.ishub = 0
AND operador.neteo = 1
AND operador.incluirReportes = 1
AND operador.pmn not in('CHLTM', 'CHLCM')
AND operador.id not in(SELECT op.id
FROM RoamingOperadoresBundle:Operador op
LEFT JOIN op.operadorHub opHub
LEFT JOIN op.outcollect out
WHERE (opHub.desde <= out.periodo and (opHub.hasta >= out.periodo or opHub.hasta is null)))
AND operador.activo = 1
GROUP BY operador.pmn, periodo ORDER BY operador.pmn
答案 0 :(得分:1)
我不确定您是如何生成此表表达式的,但是您收到错误是因为您没有在GROUP BY
子句中包含所有非聚合列。
另请注意 - 您不能按别名分组。您必须通过在table.column
表单中指定该列来引用该列。
它应该是这样的:
GROUP BY o0_.pmn, o0_.neteo, o1_.periodo, o1_.pagado