Now there's a dataset
Goods Time Warehouse Amount
A 2008-01-03 a 100
A 2008-02-01 a 80
A 2008-02-05 a 55
To make a report, the report time is 2008-02-05
Warehouse A
Goods Month Day
A 235 80 55
How can I make this form in the Reporting service, warehouse A and item A is a summary dynamic group, but the year and the day there, how do I give the expression parameters.
Hope to give answers and suggestions
Define three formulas, judge is the year, sum (), Judge is the month, sum (), judgment is the same day, sum ()
select ' 1 ' type, warehouse, goods, sum (amount), DATEPART (Y, time) yera
From table
where time < reporting time
group by Warehouse, goods, DATEPART (Y, time)
UNION
select ' 2 ' type, warehouses, goods, Sum (amount), DATEPART (m, Time) yera,datepart (m, time) month
From table
where time < Report time
group by Warehouse, goods, DATEPART (Y, Time), DATEPART (M, time)
UNION
select ' 3 ', warehouse, goods, sum (amount) , Time
From table
where time < report time
group by Warehouse, goods, time
Data is processed in such a way that
use IIF to determine type in a report