0
I’m beating myself up to bring in the sales number. I tried to make a Join of the tables, I studied what I needed and I used a Count, but it did not work well in the aggregation part.
Code used:
SELECT
to_char(
pay.created_at +
(SELECT utc_offset
FROM pg_timezone_names
WHERE name = 'America/Sao_Paulo'),
'YYYY/MM/DD'
) as "Data Pagamento",
ord.status as "Status",
count(*) as "Compras"
FROM
orders as ord
INNER JOIN
payments as pay on ord.id = pay.order_id
WHERE
ord.status = 'approved'
and
pay.status = 'approved'
GROUP BY
pay.created_at, ord.status
ORDER BY
pay.created_at asc
put in question the expected result
– Ricardo Pontual
You make a
GROUP BY pay.created_at, ord.status
but its expected output does not contain the status field. I don’t know what kind of data from your fieldpay.created_at
but you evaluated the use ofAT TIME ZONE
?– anonimo
Thanks guys! It worked with the at time zone. Hugs!
– Marcel Gomes