GROUP FUNCTIONS

                                            Group Functions

Average, Sum, Distinct, Maximum, Minimum, Count:

Average:

The Avg function returns the average value of an expression.

Output: SQLFUN28

Sum:

 

The SQL SUM function returns the summed value of an expression.

Output:SQLFUN29

Maxmimum and Minimum:

The SQL MAX and MIN function returns the maximum and minimum value of an expression.

Output:SQLFUN30

Count:

The SQL COUNT function returns the number of rows in a query.

Output:SQLFUN31

Group By; Group By with Having; Group By with Where, Having and Order By:

Group By:

The SQL GROUP BY clause can be used in an SQL SELECT statement to collect data across multiple records and group the results by one or more columns.

Output:SQLFUN32

Group By with Having:

  • Oracle GROUP BY HAVING can be used to limit the returned rows after the grouping.  With Oracle GROUP BY HAVING, the HAVING clause is applied after the GROUP BY has taken place.
  • Oracle GROUP BY HAVING will group values that have a particular value. Oracle GROUP BY HAVING can be used in conjunction with other logical functions such as MIN, MAX, COUNT, and SUM.
  • With Oracle GROUP BY HAVING, the HAVING clause filters rows after the grouping with the Oracle GROUP BY clause.An example of Oracle GROUP BY HAVING using the MAX function can be seen below:

    Output:SQLFUN33

    Group By with Where:

    Output:SQLFUN34

    Having clause:

    The SQL HAVING clause is used in combination with the SQL Group By Clause. It can be used in an SQL Select Statement to filter the records that a SQL GROUP BY returns.

    Output:SQLFUN35

    Order By:

    The SQL ORDER BY clause allows you to sort the records in your result set. The SQL ORDER BY clause can only be used in SQL Select Statement.

    Output:SQLFUN36

 

Leave a Reply