다음 쿼리를 가지고 있는데 총계로 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' 접두사가 있어서는 안됩니까? 그리고 다른 subselect에 대해서도 마찬가지입니다. –
@Andriy M : 가능 합니다만, 그 답은 이미 옵티마이 저가 테이블 별칭이없는 열 참조가 제대로 연관되어 있다고 설명합니다. –
나는 그 점을 간과했다, 나에 수치. 죄송합니다. –