Page 171 - SQL
P. 171
Minimum
The MIN() aggregate function will return the minimum of values selected.
SELECT MIN(Salary) FROM Employees
Maximum
The MAX() aggregate function will return the maximum of values selected.
SELECT MAX(Salary) FROM Employees
Count
The COUNT() aggregate function will return the count of values selected.
SELECT Count(*) FROM Employees
It can also be combined with where conditions to get the count of rows that satisfy specific
conditions.
SELECT Count(*) FROM Employees where ManagerId IS NOT NULL
Specific columns can also be specified to get the number of values in the column. Note that NULL
values are not counted.
Select Count(ManagerId) from Employees
Count can also be combined with the distinct keyword for a distinct count.
Select Count(DISTINCT DepartmentId) from Employees
Sum
The SUM() aggregate function returns the sum of the values selected for all rows.
SELECT SUM(Salary) FROM Employees
Selecting with null
SELECT Name FROM Customers WHERE PhoneNumber IS NULL
https://riptutorial.com/ 153

