0
I have the following Query
:
select
MONTHNAME(ta2.change_time) as mes,
MONTH(ta2.change_time) as numeroMes,
case
when s2.name like '%Servidores' then cast(SUM(ta2.time_unit) as UNSIGNED) * 1.5 else cast(SUM(ta2.time_unit) as UNSIGNED)
end as TEMPO_CORRETO
from
otrs.service s2,
otrs.time_accounting ta2,
otrs.ticket t2,
otrs.ticket_type tt2
where
t2.id = ta2.ticket_id and
t2.type_id = tt2.id and
t2.service_id = s2.id and
ta2.change_time between '2018-04-01' and '2018-04-30' and
t2.customer_id = 'ZSCHIMMER SCHWARZ' and
tt2.name = 'Contrato PCH'
group by
t2.customer_id,
s2.name
order by
numeroMes
But I’m getting the following feedback:
However I would like to group these values per month, having a result like this:
I’ve tried everything but I haven’t got it yet, if you have an idea.
first need to include
mes, numeroMes
in thegroup by
, but what do you want to do with thetempo_correto
? Need to use some aggregation function on it,sum
,avg
, etc.– Ricardo Pontual