I have a table in wich some records are stored according to the moment or date thay are processed.
I need to create a graph for the last 30 days, so if in any given day there where no records I need a 0, so that the graph will paint the 0 and won't ignore that specific day.
So far this is what I've accomplished, but It'll give me only the days that have records on them:
SELECT
CAST([dbo].[N_Insc_Preg_Control].[FechaInscFn] AS DATE) AS [Fecha],
COUNT(*) AS [Regs]
FROM [dbo].[N_Insc_Preg_Control]
WHERE
[dbo].[N_Insc_Preg_Control].[FechaInscFn] >= DATEADD(DAY, DATEDIFF(DAY,0,CURRENT_TIMESTAMP)- 7,0)
GROUP BY
CAST([dbo].[N_Insc_Preg_Control].[FechaInscFn] AS DATE)
This returns this:
Fecha | Regs
2017-05-04 | 5
2017-05-05 | 2
2017-05-07 | 3
2017-05-08 | 7
So the table is missing all the days scince the last 30 days... I need all those days to appear in that table, but in 0
Any hint on how can I achieve this???
Thanks!