Select empty rows in joined count
Posted on 2005-05-03
I have the following query:
SELECT COUNT(dbo.Message.TerminalSubscriptionID) AS Expr1, ST_Terminal_CommonName_1.CommonName
FROM dbo.Message INNER JOIN
dbo.ST_Terminal_CommonName ST_Terminal_CommonName_1 ON
dbo.Message.TerminalSubscriptionID = ST_Terminal_CommonName_1.TerminalID
WHERE (dbo.Message.ReceivedTimestamp BETWEEN '2005-05-01' AND GETDATE())
GROUP BY ST_Terminal_CommonName_1.CommonName
It counts the number of message sent by all terminals in the st_terminal_commonname table.
It does that fine, but if there are no messages in the dbo.Messages table, then the terminal is ignored, how can I make it so that the terminals with a 0 count (they will also not have a date in the dbo.Messages table) show in the results.