1
I need to do the TOTAL sum per office of a field of hours that is in decimal format, in addition, perform the conversion of it.
I can do the sum of the employees, but I can’t add up to "groups" of the secretariat. Ex:
With my SQL it brings that employee 1233 has 20 hours and employee 4123 has 8 hours. But that’s not what I need. I need the sum to be on top of the secretariats. Office 10, 30 hours. Office 7, 8 hours.
I’m a little lost in the assembly of this query.
I got to that point and I’m stuck. Below is my query:
SELECT
S1.id,S1.cd_secretaria,
to_char(to_timestamp(sum((S2.nr_horas) * 60)), 'MI:SS')
FROM
sch_sismapa.tb_servidor S1
JOIN
sch_sismapa.tb_he_norm_diurno S2 on (S2.id_servidor = S1.id)
WHERE
S1.id_referencia = '5'
GROUP BY
S1.id,
S1.cd_secretaria
ORDER BY
S1.cd_secretaria,
S1.id;
I hope my doubt is clear.
What kind of data field hours, interval? In the desired result you want only the secretariats and the corresponding total hours of each of them?
– anonimo
The Field Type hours is real. Yes I want the total hours per office.
– douglas pjuizfora