**Count() Function In SQL**

**Count()**

Count Function in SQl Is Used To Just Count The Number Of row in Table

IN SqL COUNT() function IS Used To returning the number of rows that matches a specified criteria

**Count()Syntax-**The Basic Syntax for Count Function are As follows

SQL>SELECT COUNT(column_name) FROM table_name WHERE condition;

**EXAMPLE-**

SQL>SELECT COUNT(RollNo) FROM Student;

**Sum Function In SQL**

**SUM()**

Sum Function is used to Display The Total Sum of A Column,

Sum function are used to Display the total sum of a numeric column

NOTE- for the Sum function column should be numeric.

**Sum() Syntax-**The Basic Syntax For Sum Function are given Below

Sum Function Without Condition

SELECT SUM(column_name)FROM table_name;

Sum Function With Condition

SELECT SUM(column_name)FROM table_name WHERE condition;

**Example OF Sum () Function**

SQL Query-

SELECT SUM(Marks)FROM Student;

In Above Example It Will Display The Total Sum Of Marks Column in Student Table.

**Average Function In SQL**

**Avg()**

Average function is used to display the average value of Numeric column in SQL

NOTE- for the AVG()function column should be numeric.

**Avg() Syntax**-The Basic Syntax For Average Function Are given Below

Average function Without Condition

SELECT AVG(column_name)FROM table_name;

Average function With Condition

SELECT AVG(column_name)FROM table_name WHERE condition;

**Example of Average Function**

SQL Query-

SELECT AVG(Marks)FROM Student;

In Above Example It Will Display The Total Average Of Marks Column in Student Table

**MIN Function In SQL**

**MIN()**

Min Function Is Used To display Smallest Record From Selected Column

To Showing The Smallest Value From a column We Use The Min Function

NOTE- for the MIN() function column should be numeric.

**MIN()Syntax-**The Basic syntax For Min Function Given Below

SELECT MIN(column_name)FROM table_name WHERE condition;

**MIN Function Example**

SQL Query-

SELECT MIN(Marks) FROM Student;

In Above Example It Will Display The Smallest Number from the Marks column in Student table.

**MAX Function In SQL**

**MAX ()**

MAX Function Is Used To display Largest Record From Selected Column

To Showing The Largest Value From a column We Use The MAX Function

**NOTE-**for the MAX() function column should be numeric.

**MAX ()Syntax-**The Basic syntax For MAX Function Given Below

SELECT MAX (column_name)FROM table_name WHERE condition;

**MAX Function Example-**

SQL Query-

SELECT MAX (Marks)FROM Student;

**First() Function In SQL**

**First ()**

First Function Is used To Display First Record From The selected Column

**First () Synatx-**The Basic Synatx For First Function given Below

SELECT First (Column_name) FROM table_name;

**First() Function Example**

SQL Query-

SELECT First (StudentName) FROM Student;

In Above Example It will Display The First Name From StudentName column

**NOTE-**First() function is only supported in MS Access.

**LAST() Function In SQL**

**LAST()**

Last Function Is used To Display Last Record From The selected Column

**LAST() Synatx-**The Basic Synatx For Last Function given Below

SELECT LAST(Column_name) FROM table_name;

Last() Function Example

SQL Query-

SELECT LAST(StudentName) FROM Student;

In Above Example It will Display The Last Name From StudentName column

NOTE- The LAST() function is only supported in MS Access.

## 0 Comments