1
I have this query below and I want faturamento
, ticket_medio
and qtd_pecas
, qtd_atendimentos
, be divided by the numbers of Tuesdays.
Example had 5 Tuesday fairs with registered values in this view, I want it to be divided by 5.
Which 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;
Could you attach an example of how this data is stored and how would you like it returned in SQL? I believe it would be clearer for the community staff to help.
– Camilo Santos
@Camilosantos I answered the question and created an example, see here: my answer
– Edvaldo Silva