zoukankan      html  css  js  c++  java
  • oracle中关键字的执行顺序

    执行顺序:

    from

    where

    group by

    having

    select 

    order by

    ******当having/select 中出现组函数,那么其他没有被组函数修饰的列就必须出现下group by后面。

    因为一旦有group by 关键字 则代表 后序执行的数据都是要分组的 若在having select 中出现没有被组函数修饰的列,就必须将它放到group by后 先执行分组。

    select dept_id,avg(salary)
    from s_emp
    where avg(salary) > 1400
    group by dept_id;
    

      这个就是错的,在有group by 关键字的前提下,where后有组函数的出现,组函数必须在分组后才能使用,而根据执行顺序可知 where的执行顺序在group之前,所以该sql语句错误,改正 后为:

    select dept_id,avg(salary)
    from s_emp
    group by dept_id
    having avg(salary) > 1400;
    

      组函数可以出现的位置:select /having /order by后面。

  • 相关阅读:
    Region-Based Segmentation
    不同特征值对应的特征向量
    Edge Linking
    Canny Edge Detector
    度量与非度量方法
    Edge detection using LoG
    Sobel算子
    Edge Model
    Laplacian算子
    图像处理中的一阶导数与二阶导数
  • 原文地址:https://www.cnblogs.com/jamers-rz/p/13622264.html
Copyright © 2011-2022 走看看