Say I have a table called "Visits", and I want to create a query that counts the visits per day.
The way I would accomplish this would be to create a query as such:
SELECT Count(VisitId) as VisitCount, Convert(varchar(32), VisitDateTime, 101) as VisitDate
WHERE VisitDateTime BETWEEN '10/1/2010' AND '10/5/2010'
GROUP BY VisitDate
The problem I am trying to overcome is that if there were no visits in a given day, that day does not show in my list. For example, if there were 3 visits on the 1st, 2 on the 2nd, none on the 3rd, and 5 on the 4th, my result set would look like:
How can I create my query so that I get all days in the date range listed in the result set regardless of whether the VisitCount is zero?
View Complete Post