我有一个蜂巢表,其中的数据是这样的-
其中key只是一个唯一列,而ph1,ph2 ..是电话号码。 目的是将流行的电话号码替换为空白。 我已经有了一个包含常用电话号码的表格。 为此例如让我们假设100和50是受欢迎的电话号码。 因此,输出应如下所示-
我尝试了此查询,但配置单元不支持此查询-
select
case when ph1 in (select phone_no from popular_phone_number)
then "" end as ph1_masked,
case when ph2 in (select phone_no from popular_phone_number)
then "" end as ph2_masked
from base_table;
答案 0 :(得分:1)
您需要使用left join
和一些case
逻辑:
select bt.key,
(case when ppn1.phone_no is not null then null else ph1 end) as ph1,
(case when ppn2.phone_no is not null then null else ph2 end) as ph2,
(case when ppn3.phone_no is not null then null else ph3 end) as ph3,
(case when ppn4.phone_no is not null then null else ph4 end) as ph4
from base_table bt left join
popular_phone_number ppn1
on ppn1.phone_no = bt.ph1 left join
popular_phone_number ppn2
on ppn2.phone_no = bt.ph2 left join
popular_phone_number ppn3
on ppn3.phone_no = bt.ph3 left join
popular_phone_number ppn4
on ppn4.phone_no = bt.ph4;