SQL COUNT(), AVG() and SUM() Function

COUNT() Function

COUNT function return number of rows base on given criteria.

Syntax
<?php  

    SELECT COUNT(column_name)
	FROM table_name
	WHERE condition;

?>


Example

This example will return you the number of records in student table.

<?php  

    SELECT COUNT(studentId)
	FROM student;

?>

AVG() Function

AVG function returns average value of a numeric column.

Syntax
<?php  

    SELECT AVG(column_name)
	FROM table_name
	WHERE condition;

?>


Example

This query will returns you the average fee of the students from student table.

<?php  

    SELECT AVG(Fee)
	FROM student;

?>

SUM() Function

SUM function returns total sum a numeric column.

Syntax
<?php  

    SELECT SUM(column_name)
	FROM table_name
	WHERE condition;

?>


Example

This query will returns you the total fee of the students from student table.

<?php  

    SELECT SUM(Fee)
	FROM student;

?>