加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

oracle sql选择具有GROUP BY和HAVING子句的语法

发布时间:2021-03-06 08:48:45 所属栏目:站长百科 来源:网络整理
导读:我一向在通过一些sql语法来研究oracle sql测验,我发明白一些令人狐疑的对象 基于official引用,select语法如下: SELECT [ hint ] [ { { DISTINCT | UNIQUE } | ALL } ] select_list FROM { table_reference | join_clause | ( join_clause ) } [,{ table_ref

我一向在通过一些sql语法来研究oracle sql测验,我发明白一些令人狐疑的对象

基于official引用,select语法如下:

SELECT
    [ hint ]
    [ { { DISTINCT | UNIQUE } | ALL } ]
   select_list
     FROM { table_reference | join_clause | ( join_clause ) }
            [,{ table_reference | join_clause | (join_clause) } ] ...
     [ where_clause ]
     [ hierarchical_query_clause ]
     [ group_by_clause ]
     [ HAVING condition ]
     [ model_clause ]

基于此,您不能在GROUP BY子句之前行使HAVING子句.可是,假如我要在测试处事器中执行以下sql:

select 
   department_id,count (*)      
from 
    employees 
having 
    count(*) > 6 
group by 
    department_id ;

它不会发生语法错误,有人可以资助表明一下吗?我不以为参考文档是错误的,但假如是这样,我必要一些确认.

办理要领

如 here所述:

Use the HAVING clause to restrict the groups of returned rows to those groups for which the specified condition is TRUE. If you omit this clause,then the database returns summary rows for all groups.

Specify GROUP BY and HAVING after the where_clause and hierarchical_query_clause. If you specify both GROUP BY and HAVING,then they can appear in either order.

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读