获取错误错误:WHERE位置:98中不允许聚合函数

问题描述 投票:-1回答:1

我试图找到customer值的minimum我试过这样

select info->'customer'
from orders
where cast(info->'items'->>'qty' as INTEGER) =
      (select min(cast(info->'items'->>'qty' as INTEGER)))

这是我的代码

http://sqlfiddle.com/#!17/79606/17

获取错误:WHERE位置:98中不允许聚合函数

预期答案“Josh William”

sql postgresql postgresql-9.1 postgresql-9.4
1个回答
0
投票

你的子查询错过了FROM条款。尝试:

select info->'customer'
from orders
where cast(info->'items'->>'qty' as INTEGER) =
      (select min(cast(info->'items'->>'qty' as INTEGER))
              from orders)
© www.soinside.com 2019 - 2024. All rights reserved.