I need to set up a report for a customer with the billing for each day of a given month.
So the beauty, the problem is that now he wants even the days that have no sale, are shown in the table with the value showing zero.
For example, this my query fetches the month and year and makes a date.
I know it has easier ways but the version of firebird is old because it already has another system using it.
At last this is my query
SELECT EXTRACT(DAY FROM p.DATAFECHAMENTO) || '/' || EXTRACT(MONTH FROM p.DATAFECHAMENTO) || '/' || EXTRACT(YEAR FROM p.DATAFECHAMENTO) AS data
, SUM(pp.valor) AS total
FROM PEDIDOPAGAMENTO AS pp
INNER JOIN PEDIDO AS p ON pp.codpedido = p.codpedido
WHERE EXTRACT(MONTH FROM p.DATAFECHAMENTO) = @Mes
AND EXTRACT(YEAR FROM p.DATAFECHAMENTO) = @Ano
GROUP BY data
This query returns the following
These are the days that had something sold, but I wanted it to show the days that were not sold anything also with total = 0
Ex:
01/05/2017 0 0 05/05/2017 0 0 03/05/2017 0
...