Agreegate Functions- MIN() and MAX(), AVG(), SUM() and COUNT()
- MIN()
SELECT MIN(column_name)
FROM table_name WHERE condition
FROM table_name WHERE condition
ID | Name |
State | JoinDate | Experience |
---|---|---|---|---|
1 | Anoop |
Delhi | 2017-06-12 12:04:30.233 | 3 |
2 | Ankit Pandey |
Pune | 2017-06-15 01:03:34.247 | 4 |
3 | Gaurav Kapoor | Pune | 2017-07-11 10:03:30.577 | 2 |
4 | Arjit singh | Punjab | 2017-07-11 10:03:30.577 | 7 |
SELECT MIN(Experience) AS Experience
FROM EmployeeDetails
FROM EmployeeDetails
Experience
2
2
- MAX()
SELECT MAX(column_name)
FROM table_name WHERE condition
FROM table_name WHERE condition
ID | Name |
State | JoinDate | Experience |
---|---|---|---|---|
1 | Anoop |
Delhi | 2017-06-12 12:04:30.233 | 3 |
2 | Ankit Pandey |
Pune | 2017-06-15 01:03:34.247 | 4 |
3 | Gaurav Kapoor | Pune | 2017-07-11 10:03:30.577 | 2 |
4 | Arjit singh | Punjab | 2017-07-11 10:03:30.577 | 7 |
SELECT MAX(Experience) AS Experience
FROM EmployeeDetails
FROM EmployeeDetails
Experience
7
7
- COUNT()
SELECT COUNT(column_name)
FROM table_name
WHERE condition
FROM table_name
WHERE condition
ID | Name |
State | JoinDate | Experience |
---|---|---|---|---|
1 | Anoop |
Delhi | 2017-06-12 12:04:30.233 | 3 |
2 | Ankit Pandey |
Pune | 2017-06-15 01:03:34.247 | 4 |
3 | Gaurav Kapoor | Pune | 2017-07-11 10:03:30.577 | 2 |
4 | Arjit singh | Punjab | 2017-07-11 10:03:30.577 | 7 |
SELECT COUNT(Experience) As Experience
FROM EMployeeDetails
FROM EMployeeDetails
Experience
4
4
ID | Name |
State | JoinDate | Experience |
---|---|---|---|---|
1 | Anoop |
Delhi | 2017-06-12 12:04:30.233 | 3 |
2 | Ankit Pandey |
Pune | 2017-06-15 01:03:34.247 | 4 |
3 | Gaurav Kapoor | Pune | 2017-07-11 10:03:30.577 | 2 |
4 | Arjit singh | Punjab | 2017-07-11 10:03:30.577 | 7 |
5 | Tarun Sharma | Maharashtra | 2017-08-11 10:15:25.000 | 5 |
SELECT COUNT(State) As StateCount
FROM EMployeeDetails
FROM EMployeeDetails
StateCount
5
5
- AVG()
SELECT AVG(column_name)
FROM table_name
WHERE condition
FROM table_name
WHERE condition
ID | Name |
State | JoinDate | Experience |
---|---|---|---|---|
1 | Anoop |
Delhi | 2017-06-12 12:04:30.233 | 3 |
2 | Ankit Pandey |
Pune | 2017-06-15 01:03:34.247 | 4 |
3 | Gaurav Kapoor | Pune | 2017-07-11 10:03:30.577 | 2 |
4 | Arjit singh | Punjab | 2017-07-11 10:03:30.577 | 7 |
5 | Tarun Sharma | Maharashtra | 2017-08-11 10:15:25.000 | 5 |
SELECT AVG(Experience) As AvrageExperience
FROM EmployeeDetails
FROM EmployeeDetails
AvrageExperience
4.200000
4.200000
- SUM()
SELECT SUM(column_name) FROM table_name
WHERE condition
WHERE condition
ID | Name |
State | JoinDate | Experience |
---|---|---|---|---|
1 | Anoop |
Delhi | 2017-06-12 12:04:30.233 | 3 |
2 | Ankit Pandey |
Pune | 2017-06-15 01:03:34.247 | 4 |
3 | Gaurav Kapoor | Pune | 2017-07-11 10:03:30.577 | 2 |
4 | Arjit singh | Punjab | 2017-07-11 10:03:30.577 | 7 |
5 | Tarun Sharma | Maharashtra | 2017-08-11 10:15:25.000 | 5 |
SELECT SUM(Experience)
FROM EmployeeDetails
FROM EmployeeDetails
SUMExperience
21
21
Agreegate Functions- MIN() and MAX(), AVG(), SUM() and COUNT()
Reviewed by LanguageExpert
on
October 07, 2017
Rating:
No comments