0
I’m making a call report from elastix and I have a problem here in the outcome.
Theoretically, if I don’t touch Where
, the result would have to be the same.
select distinct
(case left( devices.id ,2)
when '10' then 'SAC'
when '40' then 'SAC'
when '41' then 'SAC'
when '80' then 'OUTROS'
when '70' then 'OUTROS'
when '90' then 'RECEPCAO'
when '91' then 'ADMINISTRATIVO'
when '92' then 'COMERCIAL'
when '93' then 'T.I.'
when '95' then 'SAC'
when '98' then 'PROJETOS'
when '99' then 'DIRETORIA DE T.I.'
else ' ' end) AS grupo ,
round(sum(cdr.duration)/60) AS "duracao
from ((cdr join devices on(( devices.dial = substring_index(cdr.channel ,'-',1))))
join trunks on((substring_index(cdr.lastdata ,'/',2) = substring_index( trunks.channelid ,'/',2))))
where outcid = '12121212' and
!(left(cdr.dst,4) = 0800) and
(char_length(cdr.dst) > 4) and
cdr.duration > 60 and calldate >= '2014-02-01' and calldate <= '2014-02-20'
group by grupo with rollup;
what is the question?
– Math
You did not change Where but you changed the whole result set by using an Aggregate, in this case the SUM. Yes the result should be different. In addition to edit her question she was not very clear. From what I understand you use a select to return the grid and another, with the sum of durations per department. But it is not clear what its goal is. PS:. in print its aggregate total is twice as much as shown in the detailed.
– jean
PS2: You don’t need the distinct, the group by will already return only one Row per group.
– jean