I\'m using MS SQL Server but welcome comparitive solutions from other databases.
This is the basic form of my query. It returns the number of calls per day from the
Can you create the set of dates as part of your query? Something along the lines of:
SELECT COUNT(*) AS Calls, ...
FROM incidentsm1 RIGHT OUTER JOIN
(SELECT date_values
FROM TABLE(('27 Feb 2009'), ('28 Feb 2009'), ('1 Mar 2009'),
('2 Mar 2009'), ('3 Mar 2009'), ('4 Mar 2009'),
('5 Mar 2009')) AS date_list
)
ON ...
This is inspired by a sort of hybrid of Informix and DB2 notations and is pretty much guaranteed to be syntactically incorrect in both. Basically, is there a way in your DBMS of creating a literal table on the fly. One possibility - ugly but barely doable - would be to do a 7-way UNION of date literals selected from 'dual' or some table expression that guarantees one row (in Informix terms, SELECT MDY(2,28,2009) FROM "informix".systables WHERE tabid = 1 UNION ...
).