Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
0 views

Exp 7-Implementation of Aggregate Functions in SQL

Cse s5 lab

Uploaded by

rithulbgmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Exp 7-Implementation of Aggregate Functions in SQL

Cse s5 lab

Uploaded by

rithulbgmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

EXP: 7 IMPLEMENTATION OF AGGREGATE FUNCTIONS IN SQL

An aggregate function is a function that performs a calculation on a set of values, and returns a single
value. The most commonly used SQL aggregate functions are MIN( ), MAX( ), COUNT( ),SUM( )
and AVG( )
PRODUCT ( Draw table on Leftside)
ProductId ProductName Price
1 Book 18
2 Ink 19
3 Duster 10
4 Textbook 22
5 Bag 21

 MIN( ) - returns the smallest value within the selected column


Syntax:
SELECT MIN(column_name)
FROM table_name
WHERE condition;
Example:
SELECT MIN(Price) FROM Products;

OUTPUT: 10
 MAX( ) - returns the largest value within the selected column
Syntax:
SELECT MAX(column_name)
FROM table_name
WHERE condition;
Example:
SELECT MAX(Price) FROM Products;
OUTPUT: 22
 COUNT( ) - returns the number of rows in a set
Syntax:
SELECT COUNT(column_name)
FROM table_name
WHERE condition;
Example:
SELECT COUNT(ProductId) FROM Products;
Output: 5
 SUM( ) - returns the total sum of a numerical column
Syntax:
SELECT SUM(column_name)
FROM table_name
WHERE condition;
Example:
SELECT SUM(Price) FROM Products;
Output: 90
 AVG( ) - returns the average value of a numerical column
Syntax:
SELECT AVG(column_name)
FROM table_name
WHERE condition;
Example:
SELECT AVG(Price) FROM Products;
Output: 18
RESULT:
Successfully implemented Aggregate functions in SQL and output verified.

You might also like