getting error ERROR: aggregate functions are not allowed in WHERE Position: 98

getting error ERROR: aggregate functions are not allowed in WHERE Position: 98

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

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"

您的子查询缺少 FROM 子句。尝试:

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