此查询会将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')
答案 0 :(得分:0)
尝试like ca.originalcalledpartynumber like '%'||replace(p1.bc_int_phone, '-', '')||'%'
||
是oracle中字符串的连接运算符。
如果您使用的是SQL Server,请使用+
。