I use MS SQL Server, but welcome comparative solutions from other databases.
This is the main form of my request. It returns the number of calls per day from the table "incidentsm1":
SELECT
COUNT(*) AS "Calls",
MAX(open_time),
open_day
FROM
(
SELECT
incident_id,
opened_by,
open_time - (9.0/24) AS open_time,
DATEPART(dd, (open_time-(9.0/24))) AS open_day
FROM incidentsm1
WHERE
DATEDIFF(DAY, open_time-(9.0/24), GETDATE())< 7
) inc1
GROUP BY open_day
This data is used to draw a histogram, but if there were no calls on that day of the week, there is no result line and, therefore, no bar, and the user looks like this: "why does the graph only have six days and skip from Saturday to Monday?"
Somehow I need to CONNECT EVERYTHING with an empty string from every day or something like that, but I can't figure it out.
I am limited to what I can do with a single SQL statement, and I have read-only access, so I cannot create a temporary table or anything else.