I have a problem with the following query :
SELECT USER
,TO_CHAR(LAST_LOGIN, 'DD/MM/YYYY') LAST_LOGIN
,SAILA
,MAX(INTENTS) INTENTS
,MAQ
FROM OWNER.MY_TABLE_NAME
WHERE LAST_LOGIN >= TO_DATE('22/02/2017' || ' 00:00:00', 'dd/mm/yyyy hh24:mi:ss')
AND LAST_LOGIN <= TO_DATE('22/02/2017' || ' 23:59:59', 'dd/mm/yyyy hh24:mi:ss')
GROUP BY USER
,TO_CHAR(LAST_LOGIN, 'DD/MM/YYYY')
,SAILA
,INTENTS
,MAQ
ORDER BY SAILA;
When executed in this way, it is executed correctly without any problem.
But when grading the fields of the table and "assigning" a name to the table sends me an error, I execute this query :
SELECT NAME_TABLE.USER
,TO_CHAR(NAME_TABLE.LAST_LOGIN, 'DD/MM/YYYY') LAST_LOGIN
,NAME_TABLE.SAILA
,MAX(NAME_TABLE.INTENTS) INTENTS
,NAME_TABLE.MAQ
FROM OWNER.MY_TABLE_NAME NAME_TABLE
WHERE NAME_TABLE.LAST_LOGIN >= TO_DATE('22/02/2017' || ' 00:00:00', 'dd/mm/yyyy hh24:mi:ss')
AND NAME_TABLE.LAST_LOGIN <= TO_DATE('22/02/2017' || ' 23:59:59', 'dd/mm/yyyy hh24:mi:ss')
GROUP BY NAME_TABLE.USER
,TO_CHAR(NAME_TABLE.LAST_LOGIN, 'DD/MM/YYYY')
,NAME_TABLE.SAILA
,NAME_TABLE.INTENTS
,NAME_TABLE.MAQ
ORDER BY NAME_TABLE.SAILA
,NAME_TABLE.LAST_LOGIN DESC;
The error it throws is:
[Error] Execution (1: 82): ORA-00979: not to GROUP BY expression
Does anyone know why that happens?
How could I solve it?