【问题标题】:What's wrong with the having clause in my query?我的查询中的 having 子句有什么问题?
【发布时间】:2019-11-10 09:17:31
【问题描述】:
Select facid, sum(slots) as total
from cd.bookings 
group by facid 
having total > 1000
order by facid;

【问题讨论】:

    标签: postgresql group-by having


    【解决方案1】:

    你不能在 HAVING 子句中引用列别名,你必须重复表达式:

    Select facid, sum(slots) as total
    from cd.bookings 
    group by facid 
    having sum(slots) > 1000
    order by facid;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-29
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多