Link to home
Start Free TrialLog in
Avatar of rugby148
rugby148

asked on

Query with counts per group by date

Greetings.

I have a table:

ID
Field1
Timestamp (which is a populated with getdate())

I want to do a query that will respond with
date   count
10/1   4
10/2   4
10/3   52
etc.

Thanks,
John
SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
rugby148,

The only difference in the two approaches above is that mine returns a datetime for the Date
(although the time portion will always be midnight) while Swindle's returns a varchar.
To-MAY-to, to-MAH-to, really :)

Regards,

Patrick
And yours won't work because you left out the GROUP BY clause.    It won't parse.
Swindle said:
>>And yours won't work because you left out the GROUP BY clause.    It won't parse.

Touche :)
Avatar of rugby148
rugby148

ASKER

why the 101?
rugby148,

It's a code that specifies a particular format for the results of the CONVERT expression.  101
specifies mm/dd/yyyy; any of the formats that leave off the time portion would have sufficed
for my purpose.

Regards,

Patrick