私は以下のようなテーブルを持っています
Date |field1 | qty1 | qty2 | qty3
1 Aug | xyz | 0 | 0 | 3
1 Aug | xyz | 3 | 0 | 0
1 Aug | abc | 0 | 5 | 0
2 Aug | abc | 0 | 15 | 0
2 Aug | xyz | 0 | 12 | 0
2 Aug | xyz | 5 | 0 | 0
以下のように、各数量を個別に表示するための3つのストアドプロシージャを作成しました。
これが私の最初の手順です
create procedure firstprocedure
@startdate datetime, @enddate datetime
As
select date, sum (case when field1 = 'xyz', qty1) as XYZ,
sum (case when field1 = 'abc', qty1) as ABC
from table1
where date between @startdate and @enddate
group by date
これは私の2番目の手順です
Create procedure secondprocedure
@startdate datetime, @enddate datetime
As
select date, sum (case when field1 = 'xyz', qty2) as XYZ,
sum (case when field1 = 'abc', qty2) as ABC
from table1
where date between @startdate and @enddate
group by date
これは私の3番目の手順です
Create procedure thirdprocedure
@startdate datetime, @enddate datetime
As
select date, sum (case when field1 = 'xyz', qty3) as XYZ,
sum (case when field1 = 'abc', qty3) as ABC
from table1
where date between @startdate and @enddate
group by date
列(qty1、qty2、またはqty3)をパラメーターに配置し、実行中にqty1、qty2、またはqty3が必要かどうかを言及するだけの可能性はあるのでしょうか。それに応じて出力を生成する必要があります。