得到错误错误:在WHERE位置中不允许使用集合函数:98

时间:2018-09-17 22:23:27

标签: sql postgresql postgresql-9.1 postgresql-9.4

我正在尝试找到我尝试过的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中不允许使用聚合函数

预期答案 “乔希·威廉姆”

1 个答案:

答案 0 :(得分:0)

您的子查询错过了FROM子句。试试:

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