私は次のクエリを持っており、total1でtable1を更新しようとしています。 これを1ステップで実行する方法はありますか?ジョインとグループによる括弧でクエリを更新
select e.id
, p.id
, case
when count(distinct e.item) = 1 then 100
when count(distinct e.item) = 2 then 150
when count(distinct e.item) = 3 then 200
when count(distinct e.item) = 4 then 225
when count(distinct e.item) = 5 then 275
when count(distinct e.item) = 6 then 325
when count(distinct e.item) = 7 then 375
when count(distinct e.item) = 8 then 450
when count(distinct e.item) = 8 then 470
end as TotalPay
from table1 p
join table2 e on e.id = '111111'
and p.id=e.itemid
group by e.id, p.id
EXISTSの下のsubselectでは、WHERE句の 'id'に' TABLE1'という接頭辞を付けるべきではありませんか?そして、他の副選択のために。 –
@Andriy M:可能ですが、オプティマイザが、テーブルエイリアスを持たない列参照が適切に関連付けられているとの回答が既に説明されています。 –
私はそのビットを見落としました、私には恥です。ごめんなさい。 –