[英]Case statement in Bigquery
SQL中这个IF语句如何用CASE语句转换
if address='US\Madison Drive' then 'ZIP1234'
elseif address='US\123 Madison Dr' then 'ZIP1234'
elseif address'US\123 Madison-Dr' then 'ZIP1234'
ELSE 'ZIP9999' END
我需要在 where 条件下使用 CASE 语句重写此语句
Select a.ID, NAME, Address, ZIP from
table_A a left join table_B b
on a.ID = b.ID#
where {I need to put if condition mention above}
如何使用 CASE 语句转换 SQL 中的此 IF 语句
case address
when 'US\Madison Drive' then 'ZIP1234'
when 'US\123 Madison Dr' then 'ZIP1234'
when 'US\123 Madison-Dr' then 'ZIP1234'
else 'ZIP9999'
end
此特定示例的另一个选项
case when address in (
'US\Madison Drive',
'US\123 Madison Dr',
'US\123 Madison-Dr')
then 'ZIP1234'
else 'ZIP9999'
end
case address
when ('US' || CHR (92) || 'Madison Drive') then 'ZIP1234'
when ('US' || CHR (92) || '123 Madison Dr') then 'ZIP1234'
when ('US' || CHR (92) || '123 Madison-Dr') then 'ZIP1234'
else 'ZIP9999' end ```
**'\' was giving error**
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.