簡體   English   中英

SQL可變長度數字字符串

[英]SQL variable length numeric string

該查詢將bc_int_phone轉換為僅消除-''字符的數字字符。 說獲得的數字不必具有相同的起始數字。 假設我正在搜索123-456-7890,但是形式可能是999 123-456-7890。我如何在此代碼中包含like %(bc_phone_number)%以合並這種情況?

select 
    ca.callingpartynumber, ca.originalcalledpartynumber, ca.duration,
    ca.duration_text, ca.finalcalledpartynumber,  
    case 
       when calledpartylastname is not null 
         then ca.calledpartylastname + ',' + calledpartyfirstname 
         else p1.name 
    end as calledpartyname,
    p1.location, p1.dept, p1.title,
    case 
       when callingpartylastname is not null 
         then ca.callingpartylastname + ',' + callingpartyfirstname 
         else p3.name 
    end as callingpartyname
from 
    calldata.calldetailreport ca
join 
    ps_bc_peoplesource_base p1 on ca.originalcalledpartynumber like replace(p1.bc_int_phone, '-', '')
left outer join 
    ps_bc_peoplesource_base p3 on ca.callingpartynumber like replace(p3.bc_int_phone, '-', '')
where 
    callingpartynumber in (select replace(bc_int_phone, '-', '') internal_modified  
                           from ps_bc_peoplesource_base 
                           where bc_lan_id like 'f7c')

嘗試like ca.originalcalledpartynumber like '%'||replace(p1.bc_int_phone, '-', '')||'%'

|| 是oracle中字符串的串聯運算符。 如果使用的是SQL Server,請使用+

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM