補全地市爲空的SQL

update npas.meta_localinfo e
set city_key = d.city_key,
city=d.city 
from (
select a.*,c.city_key from (
select site_planning_id,substr(area, 0, 3) as city 
from (select site_planning_id,area from npas.meta_localinfo where city_key is null and area is not null and area !='' ) as b ) as a
left JOIN npas.dim_city c
on c.city=a.city  ) as d where e.city_key is null and e.site_planning_id=d.site_planning_id

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章