I am a newbie who could use guidance. Must be a better way, hopefully in query using group by?
Have MySQL db with hundreds of thousands of event records.
The columns and records look like;
Col1 Char, Col2 DATE, Col3 Char
EventType1, YYYY-MM-DD HH:MM:SS, ##d HH:MM:SS
EventType2, YYYY-MM-DD HH:MM:SS, ##d HH:MM:SS
EventType1, YYYY-MM-DD HH:MM:SS, ##d HH:MM:SS
EventType1, YYYY-MM-DD HH:MM:SS, ##d HH:MM:SS
...
etc.
The query is assembled from passed parameters and in its simplest form looks something like;
Select Col1, Col2, Col3 from events where (col2>=StDate and col2<EnDate) group by Col1 order by Col1, Col2;
The desired output results is html'd/tabled to;
EventType1, sum of Col3 (for EventType1) is xxx Hours, xx Minutes and xx Seconds
EventType2, sum of Col3 (for EventType2) is xxx Hours, xx Minutes and xx Seconds
EventN+1 etc.
...
725,334 events occured for a total of XXXXX Hours, XXX Minutes and XXX Seconds
Isn't there a way to perform the summing for the table cells of hrs,mins and seconds of col3 in the query process? Walking through the output of thousands of records is extremely high overhead. OBTW, col3 is char not numeric and is passed from a logging device.
Thanks to anyone who can offer suggestions.
🙂