是否可以对多个条件进行分组以从不同的日期范围提取不同的数据?我想提取在不同时间运行的不同营销活动绩效数据。
例如,在以下假设查询中具有两个或多个 where 子句:
select
a.click_date,
b.account_id,
b.campaign_name,
sum(click_cnt) as clicks,
from A as a
full join B as b
on a.C = b.D and a.E = b.F
where
(
a.click_date >= '02-04-2018' and a.click_date <= '02-10-2018'
and
b.campaign_name = '%ad1%'
and
b.account_id in ('10001')
)
or
where
(
a.click_date >= '02-11-2018' and a.click_date <= '02-15-2018'
and
b.campaign_name = '%ad2%'
and
b.account_id in ('10002')
)
group by 1, 2, 3