0
select sum(t.amount)
from
(select yearquarter,
(case when sum(case when type not in (3, 4) then 1 else 0 end) = 0
then sum(amount)
else sum(case when type not in (3, 4) then amount else 0 end)
end)
from t
where status = 'A'
group by yearquarter)t;
必要性値を合計しようとすると、エラーを投げるが、あなたはあなたのトンのサブクエリで金額欄に名前を付けていなかったインナーケースステートメントは、内側case文から「量」を総括する
実際にここで何をしようとしていますか? –
エラー:メッセージ8155、レベル16、状態2、行13 't'の列2に列名が指定されていません。 msg 207、レベル16、状態1、行1 'amount'列名が無効です。 –
case文の2つのcase "amount"を1つに追加しようとしています –