Author

Author- Ram Ranjeet Kumar

Sunday, June 21, 2020

GROUP BY CLAUSE IN SQL

GROUP BY CLAUSE IN SQL

  • GROUP BY CLAUSE IS USED TO CREATE THE GROUPS OR GROUP THE RECORDS.
  • GROUP BY CLAUSE EXECUTES ROW BY RAW.
  • GROUP  BY EXPRESSION IS THAT COLUMN NAME WHICH IS USED WITH GROUP BY CLAUSE.
  • WE CAN USE GROUP BY CLAUSE WITH OR WITHOUT USING WHERE CLAUSE.
  • WE CAN USE GROUP BY EXPRESSION IN SELECT CLAUSE.
  • GROUP BY CLAUSE WILL EXECUTES AFTER THE EXECUTION OF FROM CLAUSE.
  • GROUP BY CLAUSE EXECUTES ROW BY ROW, AFTER THE EXECUTION OF GROUP BY CLAUSE IT CREATES GROUPS.
  • SO THAT ANY CLAUSE WHICH EXECUTES AFTER THE EXECUTION OF GROUP BY CLAUSE IT EXECUTES AS GROUP BY GROUP.
  • WE CAN WRITE MULTIPLE COLUMN NAMES IN GROUP BY CLAUSE.
  • WE  CAN USE GROUP BY EXPRESSION ALONG WITH MULTI ROW FUNCTION [MRF()].

GROUP BY EXPRESSION

        THE COLUMN NAME OR EXPRESSION WHICH IS WRITTEN IN              GROUP BY CLAUSE IS KNOWN AS GROUP BY EXPRESSION.

SYNTAX

   

ORDER OF EXECUTION

    1. FROM
    2. WHERE (IF USED)
    3. GROUP BY
    4. SELECT

NATURE OF EXECUTION

  1. FROM
  2. WHERE--> ROW BY ROW
  3. GROUP BY--> ROW BY ROW
  4. SELECT--> GROUP BY GROUP

EXAMPLE




Q. SELECT MAXIMUM SALARY FROM EACH DEPARTMENT







GROUP BY






























































No comments:

Post a Comment