I kinda got stuck at trying to combine a few queries. What I got is the table holding sort of statistics and reference to another table.
to get statistics report I'm running (short version):
SELECT COUNT(id)
from [Actions]
where date between '2012-01-01 00:00:00' AND '2012-01-01 23:59:59'
AND [Action]='request'
The question is if I want to get every-day statistics during the specified time period, how should this query look like? I understand if I change start and end dates, I'll get statistics for the whole specified period and not grouped by day. What am I missing?
Just GROUP BY date after eleminating the time part like so:
SELECT
CONVERT(VARCHAR(10), [date], 121) ByDay, COUNT(id)
FROM [Actions]
WHERE date BETWEEN '2012-01-01 00:00:00' AND '2012-01-01 23:59:59'
AND [Action]='request'
GROUP BY CONVERT(VARCHAR(10), [date], 121)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With