

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 2
click for more info
Not enough gems
Cost: 6 gems
1: AS Clause in SQL
incomplete
2: SQL Functions
incomplete
3: Between
incomplete
4: Distinct
incomplete
5: Logical Operators – AND
incomplete
6: OR
incomplete
7: In
incomplete
8: Like
incomplete
9: Underscore Operator
incomplete
10: Wildcards Quiz
incomplete
11: Query Practice – Discount Program
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Sometimes we want to retrieve records from a table without getting back any duplicates.
For example, we may want to know all the different companies our employees have worked at previously, but we don't want to see the same company multiple times in the report.
SQL offers us the DISTINCT keyword that removes duplicate records from the resulting query.
SELECT DISTINCT previous_company
FROM employees;
This only returns one row for each unique previous_company value.
CashPal executives want to know which countries we have customers in. We store country_code data as a column on the users table.
Run a DISTINCT query to get all the unique country_codes from the users table.