Reputation: 1047
Today I noticed, I may designed a table wrong - with lots of records ~1kk.
My goal is to group these records by day (YYYY-mm-dd)
, but I only have a datetime (YYYY-mm-dd H:i:s)
field.
Current query
SELECT COUNT(datetime), datetime FROM slowExecution group by datetime;
Is this even possible?
Upvotes: 0
Views: 142
Reputation: 2927
Yes it is, with the date()
function in sql which extracts the date from datetime so
SELECT COUNT(datetime), datetime FROM slowExecution group by DATE(datetime);
Upvotes: 3