There are two tables:
Clients
___________
idClient int
login varchar
Messages
___________
idMessage int
dateWakeup datetime
.... other fields
I need for each client to count the number of entries in the table Messages in a given range of time. I tried something like this:
SELECT c.login, count(m.idMessage) FROM Clients c, Messages m
where
m.idClient=c.idClient and m.dateWakeup>'2010-09-01 00:00:01'
and m.dateWakeup<'2010-10-01 00:00:01';
It is not working.
When using
COUNT(...), you have toGROUP BYyour results: