日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

dbms标识符无效_DBMS中的聚合运算符(分组依据和具有子句)

發布時間:2025/3/11 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dbms标识符无效_DBMS中的聚合运算符(分组依据和具有子句) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

dbms標識符無效

綜合運營商 (Aggregate Operators)

To calculate aggregate values, one requires some aggregate operators to perform this task. These operators run over the columns of a relation. The total number of five aggregate operators is supported by SQL and these are:

為了計算合計值 ,需要一些合計運算符來執行此任務。 這些運算符在關系的列上運行。 SQL支持五個聚合運算符的總數,它們是:

  • COUNT – To calculate the number of values present in a particular column.

    COUNT –計算特定列中存在的值的數量。

  • SUM – To calculate the sum of all the values present in a particular column.

    SUM –計算特定列中所有值的總和。

  • AVG – To calculate the average of all the values present in a particular column.

    AVG –計算特定列中所有值的平均值。

  • MAX – To find the maximum of all the values present in a particular column.

    MAX –查找特定列中所有值的最大值。

  • MIN – To find the minimum of all the values present in a particular column.

    MIN –查找特定列中所有值的最小值。

  • Mostly, with COUNT, SUM, and AVG, DISTINCT is specified in conjunction in order to eliminate any duplicate data. But for MAX and MIN, DISTINCT is not required to be specified as that will anyway not going to affect the output.

    通常,使用COUNT , SUM和AVG時 ,將DISTINCT一起指定以消除任何重復數據。 但是對于MAX和MIN ,則不需要指定DISTINCT ,因為那樣將不會影響輸出。

    For example: Find the average salary of all the employees.

    例如:查找所有員工的平均工資。

    SELECT AVG (E.salary) FROM Employee E

    按條款分組 (GROUP BY Clause)

    GROUP BY Clause is used to group the attributes with similar features under the given condition.

    GROUP BY子句用于在給定條件下對具有相似特征的屬性進行分組。

    Let us consider a table of student.

    讓我們考慮一張學生桌。

    IDNameMarksSection
    1Shiv89A
    2Parth78B
    3Ankush95A
    4Nimish83B
    ID 名稱 分數 部分
    1個 希夫 89 一個
    2 帕斯 78
    3 安庫什 95 一個
    4 尼米什人 83

    Question: Find the highest marks of the student for each section.

    問題:找出每個部分學生的最高分數。

    To find the highest marks section wise, we need to write two queries as:

    為了明智地找到最高分,我們需要編寫兩個查詢:

    SELECT MAX (S.Marks) FROM Student S WHERE S.Section = 'A' SELECT MAX (S.Marks) FROM Student S WHERE S.Section = 'B'

    As such, if we have many sections, we have to write the query that number of time. This looks quite lengthy.

    這樣,如果我們有很多部分,我們必須以該次數編寫查詢。 這看起來很長。

    GROUP BY clause made the solution easier as we don't require writing the queries the number of times of section, Instead, we write:

    GROUP BY子句使解決方案更容易,因為我們不需要編寫查詢來查詢段的次數,而是編寫:

    SELECT MAX (S.Marks) FROM Student S GROUP BY S.Section

    In this way, writing just one query, we will get the expected output.

    這樣,只編寫一個查詢,我們將獲得預期的輸出。

    IDNameMarksSection
    3Ankush95A
    4Nimish83B
    ID 名稱 分數 部分
    3 安庫什 95 一個
    4 尼米什人 83

    有條款 (HAVING Clause)

    HAVING Clause determines whether the answer needs to be generated for a given condition or not.

    HAVING子句確定是否需要為給定條件生成答案。

    Let us consider the previous example.

    讓我們考慮前面的例子。

    IDNameMarksSection
    1Shiv89A
    2Parth78B
    3Ankush95A
    4Nimish83B
    ID 名稱 分數 部分
    1個 希夫 89 一個
    2 帕斯 78
    3 安庫什 95 一個
    4 尼米什人 83

    Question: Find the highest marks of the student for each section having marks greater than 90.

    問題:對于分數大于90的每個部分,找出學生的最高分數。

    SELECT MAX (S.Marks) FROM Student S GROUP BY S.Section HAVING S.Marks > 90

    Thus, our output will be:

    因此,我們的輸出將是:

    IDNameMarksSection
    3Ankush95A
    ID 名稱 分數 部分
    3 安庫什 95 一個

    翻譯自: https://www.includehelp.com/dbms/aggregate-operators-group-by-and-having-clause-in-dbms.aspx

    dbms標識符無效

    總結

    以上是生活随笔為你收集整理的dbms标识符无效_DBMS中的聚合运算符(分组依据和具有子句)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。