MySQL trying to get hourly summary and count on row data -
mytable is:
tday char(3) dow int(1) tdate date ttime time t0 decimal(5,2) t1 decimal(5,2) t2 decimal(5,2) t3 decimal(5,2) total decimal(8,2)
given above structure , following data:
dow im cdate ctime g0 g1 g2 g3 thu 4 2010-12-02 05:29:15 1 3 0 11 thu 4 2010-12-02 05:34:22 0 4 1 0 thu 4 2010-12-02 05:39:28 6 0 7 0 thu 4 2010-12-02 05:44:35 8 7 3 9 thu 4 2010-12-02 05:49:41 0 7 0 8 thu 4 2010-12-02 05:54:48 1 7 0 1 thu 4 2010-12-02 05:59:54 3 0 5 3 thu 4 2010-12-02 06:05:01 0 9 1 0 thu 4 2010-12-02 06:10:07 2 9 10 0 thu 4 2010-12-02 06:15:13 0 0 16 0 thu 4 2010-12-02 06:20:20 2 0 8 0 thu 4 2010-12-02 06:25:26 1 0 0 0 thu 4 2010-12-02 06:30:33 1 5 19 21 thu 4 2010-12-02 06:35:39 3 0 6 0 thu 4 2010-12-02 06:40:46 3 4 7 2 thu 4 2010-12-02 06:45:52 3 3 0 20 thu 4 2010-12-02 06:50:58 5 0 7 10 thu 4 2010-12-02 06:56:05 0 7 7 0 thu 4 2010-12-02 07:01:11 7 0 10 3 thu 4 2010-12-02 07:06:18 0 0 0 1 thu 4 2010-12-02 07:11:24 0 0 0 0 thu 4 2010-12-02 07:16:31 9 3 1 0 thu 4 2010-12-02 07:21:37 0 0 3 10 thu 4 2010-12-02 07:26:44 0 1 3 0
what trying sum of columns g0..g3 hour per day.
i have tried "select ctime, sum(g0), sum(g1), sum(g2), sum(g3) mytable group ctime order cdate;" , various statements without getting success. results trying follows:
dow im cdate ctime g0 g1 g2 g3 thu 4 2010-12-02 05:00:00 19 28 16 32 thu 4 2010-12-02 06:00:00 20 51 86 65 thu 4 2010-12-02 07:00:00 16 4 17 14
could kindly assist. have spent considerable time looking @ submitted solutions , other answers on web nothing comes close think need in particular sql statement required.
thanks. grahame
i think you're looking like
select dow, im, cdate, hour(ctime) recorded_hour, sum(g0) sum_0, sum(g1) sum)1, sum(g2) sum_2, sum(g3) sum_3 mytable group recorded_hour
if want have hour different dates distinct, have add date column group clause
Comments
Post a Comment