count records each month ?

S

SpookiePower

I have a table called TReport which have a date field
called daReportDate (yyyy-mm-dd). I want to count
how many times there is a record for each month in the
table. I tried it this way -

SELECT daReportDate, count(daReportDate)
FROM TReport
WHERE year(daReportDate)=(2007)
group by month(daReportDate)

But it does not work. I'm not sure about the count
and about the Group by.
 
G

Guest

SELECT Month(daReportDate), Count(daReportDate)
FROM TReport
WHERE Year(daReportDate)=(2007)
GROUP BY Month(daReportDate) ;

In a nutshell, what you select needs to also be part of the group by except
for the aggregrate functions like Count, Avg, Min, Max, etc.

You might have to change the WHERE to a HAVING.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top