我有一列带有dma码的列。它们具有以下两种格式:
a)100123
b)=“ 100123”
我正在尝试将它们全部格式化为a)。
我尝试使用NULLIF(regexp_replace(column_name,'\ D','','g'),'')::数字
但是我无法使用正确的语法。
选择
ds.from_date
,state_map.state_name作为状态
,dma_region_name
,zip_map.dma_name作为dma_name
,regexp_replace(dma_region_id,'','[0-9]')
,邮编名称
,search_codes_map.is_sourcecode
,search_codes_map.geo
,search_codes_map.tactic
,search_codes_map.engine
,search_codes_map.strategy
,search_codes_map.device
,search_codes_map.campaign_type
,search_codes_map.keyword_type
,search_codes_map.intent_bucket
,search_codes_map.match_type
,search_codes_map.test_indicator
,SUM(ds.clicks)AS点击
,SUM(ds.impr)AS印象
,SUM(ds.cost)AS费用
,SUM(ds.phone_calls)AS phone_calls
,SUM(ds.dialogtech_calls)AS对话框
,SUM(ds.ebrc_completion)AS ebrc_completion
,0作为smart_phone_leads
,0作为smart_web_leads
,0作为smart_leads
,0作为smart_agent_appointments
,0作为smart_oles
,0作为phone_enrollment
,0作为smart_sales
,0作为smart_paid_sales
从digital.uhg_mr_is_search ds
-IS Campaign-to-source_code映射器
左联接uhg_part_b.v_is_search_manual_dims_dedupe search_codes_map
开启ds.campaign = search_codes_map.campaign_name
-引入州首字母缩写
-杨:请注意,在极少数情况下,我们没有状态名称,但原始数据中确实有DMA名称。未将它们映射为状态,因为我们在reftables中没有DMA ID映射器
左联接reftables.us_states state_map ON ds.state_name = state_map.state_name
左联接reftables.zip_dma_map zip_map ON右(ds.dma_region_id,3)= zip_map.dma_code
-左连接reftables.dcm_dma_map DMA ON dma.dma_code = map.dma_code
开始日期> ='2018-07-01' GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17) GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
;
答案 0 :(得分:1)
为什么不只使用replace()
?
select replace(replace(dma, '"', ''), '=') as dma_type_a