You are on page 1of 3

Multiple Row Functions(Group Function):

Multiple Row functions are also called Aggregate Functions because they summarize the results of a
query and return a single value calculated from all the values present in a column instead of providing
the listing of all of the rows.

To understand multiple row functions, we have created a table named student.

After inserting 10 tuples the qverall table is as under:-

The Aggregate functions are max(),min(),avg(),sum(),count(), count(*). We shall discuss one by one.

1.Sum():Returns the total sum of a numeric column.

2.Avg():Find the average value of any column or expression based on the column.

1|Page
3.Max():Returns the highest/largest value among the given set of values of any column or expression
based on columns.

4.Min():Returns the lowest/smallest value among the given set of values of any column or expression
based on columns.

5.Count():-It counts number of non-null values in a column.

6.Count-Distinct:The keywords Distinct and Count can be used together to count the number of records
excluding duplicate values.

Sorting in SQL-Order By

The SQL Order By clause is used to sort data in ascending or descending order based on one or more
columns.

To display name, marks and date of birth sorted in ascending order of date of birth from student.

2|Page
To display name, marks and date of birth sorted in descending order of date of birth from student.

Group By

The group by clause can be used in a select statement to collect data across multiple records
and group the results by one or more columns.

Having Clause

The Having clause is used in combination with Group by clause.

3|Page

You might also like