Ho provato a realizzare la seguente query:
ma ottengo l'errore:Error Code: 1111. Invalid use of group functioncodice:select detailDestinationName as 'Nome Coda', count(*) as 'Totale Chiamate ricevute', count(case when status = 'SERVED' then uniqueId else null end) as 'Chiamate Servite', (count(case when status = 'SERVED' then uniqueId else null end)/count(*)*100) as '% chiamate servite', ifnull((count(case when status = 'NOTSERVED' and waitingTime >= 30 then uniqueId else null end)/(count(*)-count(case when status = 'NOTSERVED' and waitingTime < 30 then uniqueId else null end))*100),0) as "Totale Abbandoni", count(case when status = 'NOTSERVED' and waitingTime >= 30 then uniqueId else null end) as 'Chiamate non Servite Superiori a 30 secondi', ifnull((count(case when status = 'NOTSERVED' and waitingTime >= 30 then uniqueId else null end)/count(case when status = 'NOTSERVED' then uniqueId else null end )*100),0) as '% chiamate non servite superiore a 30 secondi', count(case when status = 'NOTSERVED' and waitingTime < 30 then uniqueId else null end) as 'Chiamate non Servite Inferiori a 30 secondi', ifnull((count(case when status = 'NOTSERVED' and waitingTime < 30 then uniqueId else null end)/count(case when status = 'NOTSERVED' then uniqueId else null end )*100),0) as '% chiamate non servite inferiore a 30 secondi' from chiamate_report_new group by detailDestinationId UNION select 'TOTALE' as 'Nome Coda', sum(count(*)) as 'Totale Chiamate ricevute', sum(count(case when status = 'SERVED' then uniqueId else null end)) as 'Chiamate Servite', sum((count(case when status = 'SERVED' then uniqueId else null end)/count(*)*100)) as '% chiamate servite', sum(ifnull((count(case when status = 'NOTSERVED' and waitingTime >= 30 then uniqueId else null end)/(count(*)-count(case when status = 'NOTSERVED' and waitingTime < 30 then uniqueId else null end))*100),0)) as "Totale Abbandoni", sum(count(case when status = 'NOTSERVED' and waitingTime >= 30 then uniqueId else null end)) as 'Chiamate non Servite Superiori a 30 secondi', sum(ifnull((count(case when status = 'NOTSERVED' and waitingTime >= 30 then uniqueId else null end)/count(case when status = 'NOTSERVED' then uniqueId else null end )*100),0)) as '% chiamate non servite superiore a 30 secondi', sum(count(case when status = 'NOTSERVED' and waitingTime < 30 then uniqueId else null end)) as 'Chiamate non Servite Inferiori a 30 secondi', sum(ifnull((count(case when status = 'NOTSERVED' and waitingTime < 30 then uniqueId else null end)/count(case when status = 'NOTSERVED' then uniqueId else null end )*100),0)) as '% chiamate non servite inferiore a 30 secondi' from chiamate_report_new;
Cosa ho sbagliato?

Rispondi quotando