SQL Server 2005 で 1 つのケース式を使用して複数の列を取得するために SQL で wok できる Case のようなものがあるかどうか疑問に思っています。私は SQL の新人です。簡単すぎないことを願っています。前もって感謝します!!
Select RD.RepDailyInfoID, RD.TypeofDayID
Case WHEN RD.TypeofDayID = 1
THEN
isnull(cast(S.AmountSold as numeric(10,2)), 0) as AmountSold,
isnull(cast(S.S_AmountCollected as numeric(10,2)), 0) as AmountCollected,
S.S_PaymentMethod as PaymentMethod
When RD.TypeofDayID = 9
THEN
isnull(cast(U.AmountUpgraded as numeric(10,2)), 0) as AmountUpgraded,
isnull(cast(U.U_UpgradedCollected as numeric(10,2)), 0) + isnull(cast(U.RenewalCollected as numeric(10,2)), 0) as AmountCollected,
U.U_PaymentMethod as PaymentMethod
END
from RepDailyInfo RD
left outer join SellingInfo S on S.RepDailyInfoID = RD.RepDailyInfoID
left outer join UpgradingInfo U on U.RepDailyInfoID = RD.RepDailyInfoID
where RepID = @RepID