This Query:
Code:
SELECT o.periodo, o.cuitEmpresa, sum(o.total) FROM Dj o, Empresas e WHERE o.cuitEmpresa = e.cuit AND o.confirmado=TRUE AND CAST((substring(o.periodo,1, 4) || substring(o.periodo,6, 8)) AS integer) >=201301 AND CAST((substring(o.periodo,1, 4) || substring(o.periodo,6, 8)) AS integer) <=201301 GROUP BY o.periodo, o.cuitEmpresa
throw:
ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: column "
dj0_.periodo" must appear in the GROUP BY clause or be used in an aggregate function
Position: 8
and obviously if I add that alias (dj0_) to the field in the GROUP BY throw another error.