我想在{3}条件中使用CASE
。它显示错误。
我的查询:
select distinct a.phone, other,starttime,duration,imeinumber,
imsinumber,call_type,a.provider_key, a.celltowerid, siteaddress,
lat, long, azimuth from cdat a
left join cdatdupl.dbo.cdatcelltowerareanew b on
case
when a.provider_key!='9' then a.tower_key=b.tower_key
else a.celltowerid = b.celltowerid
and a.provider_key=b.provider_key
and a.state_key end=b.state_key
答案 0 :(得分:0)
您必须使用CASE
关键字
end
表达式
<强>语法强>
CASE { simple_case_expression
| searched_case_expression
}
[ else_clause ]
END
更新了查询
select distinct a.phone, other,starttime,duration,imeinumber,
imsinumber,call_type,a.provider_key, a.celltowerid, siteaddress,
lat, long, azimuth from cdat a
left join cdatdupl.dbo.cdatcelltowerareanew b on
case
when a.provider_key!='9' then a.tower_key=b.tower_key
else (a.celltowerid = b.celltowerid
and a.provider_key=b.provider_key
and a.state_key end=b.state_key)
end