パラメータを追加したいプロシージャがあります-パラメータはと呼ばれ@AmountType
ます。@AmountType
次に、そのパラメーターをwhere
句に追加して、さまざまな金額タイプをフィルター処理できるようにします。@AmountType
トリッキーな部分は、selectのcaseステートメントの部分から得られる値をの値にしたいということです。
したがって、AmountType1レコードのみを表示するか、AmountType2レコードのみを表示するなどです。明らかに、実際の列ではないwhere @AmountType = Amounts
ため、私はそれを行うことはできません。Amounts
これを達成する方法のアイデアはありますか?
これは私の声明です:
ALTER PROCEDURE spProc1
@Date datetime
AS
BEGIN
Select
location,
workDate,
case
when dollarAmount1 - dollarAmount2 < 0 Then 'AmountType1'
when dollarAmount1 - dollarAmount2 > 0 Then 'AmountType2'
when dollarAmount1 - dollarAmount2 = 0 Then 'AmountType3'
End As Amounts
From
table1
Where
@Date = workDate
END