sql - Grouping and summing items in a table using SSRS -
i have ssrs report, , i'm trying sum rows conditionally. have:
11/15/2010 12:14:43 | current rate | current speed | amount used in minute (speed*rate/60) etc etc etc
i trying add rows happened in hour, report show:
11/15/2010 | 12 - 1 | amount used hour (say, 7 gallons)
i cannot find anywhere how conditionally sum row per hour, or how report above.
thank in advance!
using following table testing:
create table `log` ( `entry_date` datetime default null, `amount_used` int(11) default null )
with test data:
entry_date amount_used 2010-11-01 10:00:00, 3 2010-11-01 10:30:00, 1 2010-11-01 11:00:00, 6
use query date, hour range , total amount used:
select date(entry_date) entry_date, concat_ws('-',convert(min(hour(entry_date)), char(2)), convert(max(hour(entry_date)),char(2))) hours, sum(amount_used) amount_used ( select entry_date, sum(amount_used) amount_used log group date(entry_date), hour(entry_date) ) t;
all concat/convert stuff range of hours in particular day, string. result:
entry_date hours amount_used 2010-11-01, 10-11, 10
Comments
Post a Comment