zoukankan      html  css  js  c++  java
  • SQL HAVING

    The HAVING clause is used in combination with the GROUP BY clause and the SQL aggregate functions. HAVING clause allows us to call the data conditionally on the column that return from using the SQL aggregate functions.

    The SQL HAVING syntax is simple and looks like this:

    SELECT [COLUMN NAME 1] , AGGREGATE FUNCTION ( [COLUMN NAME 2] )
    FROM [TABLE NAME]
    GROUP BY[COLUMN NAME 1]
    HAVING AGGREGATE FUNCTION ( [COLUMN NAME 2] ) = [CONDITION]


    EXAMPLE :

    Let’s say, we want to get the departments from GameScores that total scores is more than 4000.

    Table GameScores

    PlayerName Department Scores
    Jason IT 3000
    Irene IT 1500
    Jane Marketing 1000
    David Marketing 2500
    Paul HR 2000
    James HR 2000

    SQL statement :

    SELECT Department, SUM(Scores)
    FROM GameScores
    GROUP BY Department
    HAVING SUM(Scores)>4000

    Result:

    Department SUM(Scores)
    IT 4500
  • 相关阅读:
    层模型--绝对定位(position:absolute)
    什么是层模型?
    浮动模型
    流动模型(二)
    插值方法
    CFS调度分析(内核版本:2.6.34)
    CRC检验
    ubuntu误删home目录
    随想
    Android——Activity生命周期
  • 原文地址:https://www.cnblogs.com/zhoug2020/p/3328329.html
Copyright © 2011-2022 走看看