I have a column of datetimes, and a column of values. How do I add up all teh values that occur on the same day? so like... midnight:01 to 23:5 => add all the records that occur in that time period.
then group by day.
bit hard to explain. sadness.
I have a column of datetimes, and a column of values. How do I add up all teh values that occur on the same day? so like... midnight:01 to 23:5 => add all the records that occur in that time period.
then group by day.
bit hard to explain. sadness.
 
    
     
    
    Use:
SELECT SUM(t.value_column)
  FROM TABLE t
GROUP BY DATE(t.datetime_column)
The DATE function only captures the year/month/day portion - time is ignored, so anything on that date will be grouped together.
 
    
    In MySQL:
SELECT  CAST(datetime_field AS DATE) AS date_field, SUM(value)
FROM    mytable
GROUP BY
        date_field
