I have a field called time_elapsed that stores a sql TIME value, a start_date and end_date that are sql DATETIMES, a unique id and a batch_id that is a reference to the batches table. I’m looking to SUM the total of the time_elapsed field for every record in a date range, in the case of the example it is august first until now. If I join the batches table and group by operation_id it gives me the info that I need for individual operation_ids but not for every record combined.
select sum(TIME_TO_SEC(time_elapsed)) from batch_log
where batch_log.start_time between DATE("08-01-2011") and DATE(NOW()) and time_elapsed is not null
You possibly just aren’t matching any rows with your WHERE clause. Try doing a count(*) instead of a sum to check.