數(shù)據(jù)庫按照符號分割多行

原始數(shù)據(jù)

address source
臺灣,上海,北京 table1
黑龍江,吉林,遼寧 table2
例如:下面的sql語句

select
address_new as address,
'new_address' as source
from
th_rw.dwd_th3_new_source_address_all dtaa
lateral view explode(split(address,',')) t as address_new
where
`source`  = 'dwd_tw_huji_aft_8'
and
address like '%,%'

經(jīng)過sql語句轉(zhuǎn)換之后

address source
臺灣 table1
上海 table1
北京 table1
黑龍江 table2
吉林 table2
遼寧 table2

按照數(shù)據(jù)量對數(shù)據(jù)進(jìn)行分區(qū)展示

select 
address,
case when rank<=1200000 then 'ods_dzs_person_1'
     when rank<=2400000 then 'ods_dzs_person_2'
     when rank<=3600000 then 'ods_dzs_person_3'
     when rank<=4800000 then 'ods_dzs_person_4'
     when rank<=6000000 then 'ods_dzs_person_5'
     when rank<=7200000 then 'ods_dzs_person_6'
     when rank<=8400000 then 'ods_dzs_person_7'
     when rank<=9600000 then 'ods_dzs_person_8'
     else 'ods_dzs_person_9' end  as source
from 
(
select address, row_number() over (partition by source order by address) as rank
from dwd_th3_new_source_address_all88
where source = 'ods_dzs_person'
)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容