【发布时间】:2020-01-17 15:23:54
【问题描述】:
我正在尝试使用以下内容返回几个“平均 if”列:
select
date,
avg(case when hour >= 23 or hour <= 6) then (select price) else null end) as price1,
avg(case when (hour >= 16 and hour <= 18) then (select price) else null end) as price2
from
xxxxxxxxx
where
date <= '2019-12-31' and
date >= '2018-12-01'
group by
date
order by
date
当我单独使用每个 avg(case when) 时它可以工作,但是当我同时使用它们时会出现错误
无效操作:由于内部错误,不支持这种类型的关联子查询模式
【问题讨论】:
-
欢迎使用 StackOverflow!你确定你在第 2 行的括号是正确的?
-
只需将
(select price)替换为price
标签: sql amazon-redshift