Select Statement  «Prev  Next»
Lesson 10

Aggregate SQL Select Statements and Functions Summary

Different aspects of SQL will be combined to produce the overall results you need to complete the course project.
In this module, you have seen how you can use different approaches to filtering and presenting information from tables, whether they are related or stand alone. You will be using these same techniques to format and present the information for the course project.
From
  1. DISTINCT,
  2. GROUP BY and
  3. subquery technique.
These various data extraction techniques producing meaningful reports.
Here is a review of some of the useful aggregate sql functions that were discussed in the module.


COUNT function Example

Use the GROUP BY clause with the SQL COUNT function.
This GROUP BY example uses the COUNT function to return the department and the number of employees (in the department) that make over $25,000 / year.

SELECT department, COUNT(*) AS "Number of employees"
FROM employees
WHERE salary > 25000
GROUP BY department;

MIN function Example

Use the GROUP BY clause with the SQL MIN function.
This GROUP BY example uses the MIN function to return the name of each department and the minimum salary in the department.

SELECT department, MIN(salary) AS "Lowest salary"
FROM employees
GROUP BY department;

MAX function Example

Use the GROUP BY clause with the SQL MAX function.
This GROUP BY example uses the MAX function to return the name of each department and the maximum salary in the department.

SELECT department, MAX(salary) AS "Highest salary"
FROM employees
GROUP BY department;

SQL Select - Quiz

Click the link below to test your proficiency in advanced uses of the SELECT statement.
SQL Select - Quiz