I have this query below and I want the faturamento
, ticket_medio
and qtd_pecas
, qtd_atendimentos
, to be divided by the numbers on Tuesdays.
Example had 5 Tuesdays with values registered in this view, I want it to be divided by 5.
What postgres function can I use?
SELECT
id_empresa,
id_loja,
sum(faturamento),
sum(ticket_medio),
sum(qtd_pecas),
sum(qtd_atendimentos)
FROM
sumario_diario
WHERE
to_char(data_sumario, 'dy') = 'tue'
AND id_loja = 19
GROUP BY
id_empresa,
id_loja;