deviloper
deviloper

Reputation: 7240

Mysql group by day in a date_time field

Is it ever possible to have a query that selects rows grouped by the day or month from a table that has a date_time filed holding full date_time value?

enter image description here

I need to get the sum of sr13, r4, huawei for each day. Any idea of how I can do it would be heartfully appreciated!

Upvotes: 2

Views: 290

Answers (1)

John Woo
John Woo

Reputation: 263683

You can use DATE() to extract the date from the value,

SELECT  DATE(date_time) datetime,
        SUM(sr13) total_sr13,
        SUM(r4) total_4
FROM    TableName
GROUP   BY DATE(date_time)

Upvotes: 2

Related Questions