SQL FUNCTIONS
Five Important aggregate functions are SUM, AVG, MIN, MAX and COUNT. They are called aggregate functions because they summarize the results of a query, rather than listing all of the rows.
- SUM () gives the total of all the rows, satisfying any conditions, of the given column, where the given column is numeric.
- AVG () gives the average of the given column.
- MIN () gives the smallest figure in the given column.
- MAX () gives the largest figure in the given column.
- COUNT () gives the number of rows satisfying the conditions
1. SUM( ):
The SUM function returns the total sum of a column. NULL values are not included in the calculation.
Syntax :
SELECT SUM (column) FROM table
For example:
SELECT SUM (RollNumber) FROM Student;
2. AVG( ):
The AVG function returns the average value of a column in a selection. NULL values are not included in the calculation.
Syntax :
SELECT AVG (column) FROM table
For example:
SELECT AVG(RollNumber) FROM Student;
3. MIN( ):
The MIN function returns the lowest value in a column. NULL values are not included in the calculation.
Syntax :
SELECT MIN(column) FROM table;
For example:
SELECT MIN(RollNumber) FROM Student;
4. MAX( ):
The MAX function returns the highest value in a column. NULL values are not included in the calculation.
Syntax :
SELECT MAX(column) FROM table;
For example:
SELECT MAX(RollNumber) FROM Student;
5. COUNT( ):
The keyword COUNT can be used together to count the number of distinct results.
Syntax :
SELECT COUNT (column) FROM table;
For example:
SELECT COUNT (RollNumber) FROM Student;
More topics from DBMS to read:
EasyExamNotes.com covered following topics in these notes.- Introduction to Database
- Introduction to DBMS
- Advantages and disadvantages of DBMS
- DML, DDL and DCL
- Domains
- Introduction to data models
- Entities and Attributes
- Relationship among entities
- Tuples
- Attributes
- Relation
- Keys
- Twelve rules of CODD
- Schemas
- Integrity Constraints
- Normalization
- Functional dependency
- Transaction processing concepts
- Schedule
- Serializability
- OODBMS vs RDBMS
- RDBMS
- SQL join
- SQL functions: SUM(), AVG(), MAX(), MIN(), COUNT().
- Block, Extent, Segment
- Oracle Background processes
- Trigger
- Oracle cursor
- Introduction to Concurrency Control
A list of Video lectures
EasyExamNotes.com covered following topics in these notes.
- Introduction to Database
- Introduction to DBMS
- Advantages and disadvantages of DBMS
- DML, DDL and DCL
- Domains
- Introduction to data models
- Entities and Attributes
- Relationship among entities
- Tuples
- Attributes
- Relation
- Keys
- Twelve rules of CODD
- Schemas
- Integrity Constraints
- Normalization
- Functional dependency
- Transaction processing concepts
- Schedule
- Serializability
- OODBMS vs RDBMS
- RDBMS
- SQL join
- SQL functions: SUM(), AVG(), MAX(), MIN(), COUNT().
- Block, Extent, Segment
- Oracle Background processes
- Trigger
- Oracle cursor
- Introduction to Concurrency Control
A list of Video lectures
References:
- Korth, Silbertz,Sudarshan, “Fundamental of Database System”, McGraw Hill
- Atul Kahate , “ Introduction to Database Management System”, Pearson Educations
- Korth, Silbertz,Sudarshan, “Fundamental of Database System”, McGraw Hill
- Atul Kahate , “ Introduction to Database Management System”, Pearson Educations