Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Ordering
Limiting the output
Eliminating duplicate results
11. Select distinctive values in certain columns
Aggregation
Grouping
HAVING: filtering and ordering groups
Let's practice

Instruction

Excellent. You can also use DISTINCT on a group of columns. Take a look:

SELECT DISTINCT
  customer_id,
  order_date
FROM orders;

One customer may place many orders every day, but if we just want to know on what days each customers actually did place at least one order, the above query will check that.

Exercise

Check what positions there are in every department. In order to do that, select the columns department and position from the employees table and eliminate duplicates.

Stuck? Here's a hint!

Type:

SELECT DISTINCT
  department,
  position
FROM employees;