【发布时间】:2020-10-20 03:47:13
【问题描述】:
尝试执行子查询时出现以下错误子查询使用来自外部查询的未分组列“s.event_captured_dt”
select
to_date(s.event_captured_dt,'DD Mon YYYY')
,count(*) as count_
,(select count(*)
from spc_raw_responsys_kanui.sent s1
where to_date(s1.event_captured_dt,'DD Mon YYYY') between to_date(s.event_captured_dt,'DD Mon YYYY') - 7 and to_date(s.event_captured_dt,'DD Mon YYYY')
) as count7days_
from spc_raw_responsys_kanui.sent s
where 1=1
and to_date(s.event_captured_dt,'DD Mon YYYY') >= '2020-06-01 00:00:00'
group by to_date(s.event_captured_dt,'DD Mon YYYY')
这就是我想要达到的目标:
【问题讨论】:
-
请提供样本数据、预期结果和逻辑解释。
标签: sql date select subquery amazon-redshift