SQL Flow Field Guide

Choose whether duplicate values stay

Use DISTINCT when a result needs each projected value once.

What you are trying to do

A service directory needs a list of regions where items are stocked, with each region shown once.

Work through it

  1. Count the repeated North values in the source.
  2. Follow the Region expression through DISTINCT.
  3. Check the unique result values and their order.

Check your work

The result has two rows, North and South. DISTINCT removes repeated projected Region values.

Practice SQL

Open in SQL Flow
SELECT DISTINCT Region
FROM (VALUES (N'North'), (N'North'), (N'South')) AS Stock(Region)
ORDER BY Region;

Knowledge check

Commands in this lesson

Next lesson Sort rows with a tie-breaker