I have 2 versions of oracle, Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production and Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
And I have this sql:
select an.idai, t1.fecha, 53, t1.val_d60, 0
from
( select ides, cana, ctec, trunc(fecha_d60, 'MM') as fecha, val_d60,
row_number() over (partition by ides,cana,ctec, trunc(fecha_d60, 'MM')
order by val_d60 asc) as orden
from azul_estdata60
where idflagv = 11
and ides < 25
and fecha_d60 >= '01/01/2016' and fecha_d60 <= '31/12/2016'
and cana = 8
order by ides, cana, ctec, val_d60 desc
) t1,
( select ides, cana, ctec, trunc(fecha_d60, 'MM') as fecha,
round(count(*)*.5,0) as percentil
from azul_estdata60
where idflagv in (11,12,13)
and ides < 25
and fecha_d60 >= '01/01/2016' and fecha_d60 <= '31/12/2016'
and cana = 8
group by ides, cana, ctec, trunc(fecha_d60, 'MM')
) t2
inner join azul_analogin an
on an.cana = t2.cana
and an.ctec = t2.ctec and an.ides = t2.ides
where t1.ides = t2.ides
and t1.cana = t2.cana
and t1.ctec = t2.ctec
and t1.fecha = t2.fecha
and orden = percentil;
It works on 11.2.0.1.0 but, on 11.2.0.3.0, I get this error:
ORA-00979: no es una expresión GROUP BY
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:
What can I do to solve this?
Thx.
'01/01/2016'
is not a date. Oracle may try to implicitly convert it to a date using theNLS_DATE_FORMAT
session parameter as the format mask but if this mask does not match then the conversion will fail (and the parameter can be set by each user in their session so when it changes it is a pain to debug as it can work for one user and not others). It would be better to useTO_DATE( '01/01/2016', 'DD/MM/YYYY' )
or an ANSI date literalDATE '2016-01-01'
. – MT0'01/01/2016'
is a string and not a date. Regardless of whether it works for you or not using strings for dates and relying on implicit conversion is bad practice as the user can change theNLS_DATE_FORMAT
in their session and that will break all the queries where you rely on implicit conversion without the query changing. – MT0cana
andcaña
orcána
. They may be used inconsistently between the code and the base table; depending on database settings, one may see them as the same but the other as different. If they are different betweenselect
andgroup by
, that might throw this error. The error message says exactly where this error occurred, can you share that info as well? – mathguy