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 distinct 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
  CustomerId,
  OrderDate
FROM Order;

One customer may place many orders every day. However, we just want to know on what days each customer placed at least one order. The above query will check that.

Exercise

Check what positions there are in every department. To do so, select the Department and Position columns from the Employee table and eliminate duplicates.

Stuck? Here's a hint!

Type:

SELECT DISTINCT
  Department,
  Position
FROM Employee;