Helix Systems' facilities team is reviewing the company's office footprint ahead of a lease renewal decision.
Write a query to return each office location represented in the departments data, with no duplicates.
Assumptions:
- The
departmentstable contains every department at Helix Systems. - Multiple departments share the same
location(e.g., several departments at headquarters), so the column has duplicates.
Output:
- One row per distinct office location, with a single column
location.
Schema · hr 4 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT DISTINCT
location
FROM
departments The shape
DISTINCT location collapses a column that repeats once per department down to the four cities Helix Systems actually occupies — Austin, Chicago, New York, San Francisco. The duplication is structural: many departments share a building, so the raw column carries each city as many times as it has departments in it.
Clause by clause
SELECT DISTINCT locationreturns the uniquelocationvalues from whatever rowsFROMhands up. Every department contributes its city to the candidate set, and the deduplication runs across that set to produce one row per real office.FROM departmentsis the row source — the parent dimension here islocation, even though the table is keyed on department.DISTINCTon a child-table column is how the parent value space gets recovered without a separatelocationstable.
For the lease-renewal review, the result is exactly what the facilities team needs: four rows, four cities, no inflation from departmental headcount. If a fifth city were to appear, that's the cue that the office footprint has grown since the last review.
You practiced applying DISTINCT to a column with structural duplication — many departments per location. The shape recurs whenever a one-to-many relationship is being collapsed to its parent dimension.