【发布时间】:2021-02-22 13:28:15
【问题描述】:
有两个 Bigquery 表,
表 1:
store article sales
11 aa 14.5
11 bb 10.0
12 aa
12 bb
12 cc
13 aa 12.0
13 bb 11.4
13 dd 12.5
表 2:
store status likestore
11 Active
12 New 13
13 New
场景: 如果该商店的 tab2.status = 'New' 且 tab1.sales 为 NULL,则为该商店分配 tab2.likestore 的销售额。
试用:
select *,
case when tab2.status = 'New' and tab1.sales IS NULL then <to add other conditions explained in Scenario>
from tab1
left join tab2 on tab2.store = tab1.store
最终结果:
store article sales
11 aa 14.5
11 bb 10.0
12 aa 12.0
12 bb 11.4
12 cc
13 aa 12.0
13 bb 11.4
13 dd 12.5
【问题讨论】:
标签: sql google-bigquery case procedure