查询中的hading子句怎么了?

时间:2019-06-28 11:54:09

标签: postgresql group-by having

<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>eclipselink</artifactId>
    <version>2.7.4</version>
    <exclusions>
        <exclusion>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>jakarta.persistence</artifactId>
        </exclusion>
    </exclusions>
</dependency>

1 个答案:

答案 0 :(得分:0)

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

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