Forum Moderators: open

Message Too Old, No Replies

Average per day, but only if there is one on that day

         

Nutter

2:15 pm on Dec 13, 2005 (gmt 0)

10+ Year Member



I have a database of events and the date they happen on. There can be multiple events per day, but there are also days where there aren't any events. I want to get an average per day, but only count those days that have events.

My thinking is to use a combination of COUNT() and DISTINCT to count the dates that are within the search range and use that as my divisor. Is there an easier (or faster) way?

syber

4:00 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



I belive this will give you what you want


SELECT COUNT(eventdate) * 1.0 / (SELECT COUNT(DISTINCT eventdate) FROM events)
FROM events