MySQL Forums
Forum List  »  InnoDB

need help in create report group by hourly
Posted by: ks sam
Date: September 02, 2005 10:25PM

I'm creating a report using PHP and intended to generate a report that group sales into hourly.

Generally, i have creating in using hardcoded value for 24 sql queries:
select sum(txamount) from tbl_tx where txdatetime >= '$start_date' and txdatetime <= '$end_date';

just hope somebody can come out with a better query statement.

note:
$start_date = '2005-08-26 10:00:00'
$end_date = '2005-08-26 11:00:00'

next value;

$start_date = '2005-08-26 11:00:00'
$end_date = '2005-08-26 12:00:00' and so on ..


now i get the result like this: 24 hours format
TIME PERCENTAGE AMOUNT
10:00 - 11:00 0.00 % $ 0.00
11:00 - 12:00 0.00 % $ 0.00
12:00 - 13:00 0.00 % $ 0.00
13:00 - 14:00 0.00 % $ 0.00
14:00 - 15:00 12.92 % $ 278.00
and so on ...
07:00 - 08:00 0.00 % $ 0.00
08:00 - 09:00 0.00 % $ 0.00
09:00 - 10:00 0.00 % $ 0.00
Total: $ 2,152.00


Actually need result like this:
26/08/2005 27/08/2005
TIME PERCENTAGE AMOUNT PERCENTAGE AMOUNT
10:00 - 11:00 0.00 % $ 0.00 0.00 % $ 0.00
11:00 - 12:00 0.00 % $ 0.00 0.00 % $ 0.00
12:00 - 13:00 0.00 % $ 0.00 50.00 % $ 114.00
13:00 - 14:00 0.00 % $ 0.00 50.00 % $ 114.00
14:00 - 15:00 100.00 % $ 278.00 0.00 % $ 0.00
and so on ...
07:00 - 08:00 0.00 % $ 0.00 0.00 % $ 0.00
08:00 - 09:00 0.00 % $ 0.00 0.00 % $ 0.00
09:00 - 10:00 0.00 % $ 0.00 0.00 % $ 0.00
Total: $ 278.00 $ 228.00


Hope somebody can come out with better idea. Thanks.

Options: ReplyQuote


Subject
Views
Written By
Posted
need help in create report group by hourly
4529
September 02, 2005 10:25PM
2411
September 04, 2005 11:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.