SQL - DISTINCT
Overview
DISTINCT returns unique values from a result set.
SELECT DISTINCT department_id FROM employees;SELECT DISTINCT department_id FROM employees;SELECT DISTINCT department_id FROM employees;Expected Output (live)
| department_id | 
|---|
| 1 | 
| 2 | 
| 3 | 
Sample Use Cases (3)
1) Distinct cities (employees)
| city | 
|---|
| Austin | 
| Boston | 
| New York | 
| San Francisco | 
| Seattle | 
2) Distinct titles (employees)
| title | 
|---|
| Engineer | 
| HR Specialist | 
| Principal Engineer | 
| Sales Manager | 
3) Distinct customer cities
| city | 
|---|
| Austin | 
| Boston | 
| New York | 
| San Francisco | 
| Seattle |