Helix Systems' facilities manager is compiling a company directory ahead of a building access audit.
Write a query to return the name and location of every department.
Assumptions:
- The
departmentstable contains every department at Helix Systems. - Each department has a
nameand alocation(the office or city it's based in).
Output:
- One row per department, with columns
nameandlocation.
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
name,
location
FROM
departments The shape
FROM departments points at the directory table, and the two columns in the SELECT list shape each row into exactly what the building-access audit needs: a department label paired with its physical location.
Clause by clause
SELECT name, locationreturns two columns per row, in source order. For the facilities manager, that lines up with how the audit reads — department name on the left, the office or city on the right — so the result can drop straight into the audit spreadsheet without rearranging.FROM departmentsreads every department Helix Systems has on file. There's noWHERE, so every row in the table comes back; the audit needs the complete directory, not a filtered slice. Thedepartmentstable is the right row source because the prompt names a department-level question — not a per-employee or per-building one. Picking the right table is half the work of writing a query that returns the right shape.
Why this and not SELECT *
The directory table might carry more than name and location — a department code, a head-count column, a manager reference. None of those belong in an access audit; they'd just clutter the printed sheet. Naming the two columns the audit actually cares about keeps the result aligned with its purpose.
You practiced naming the table in FROM and pulling specific columns from it. The same SELECT … FROM shape applies whether the data is products, customers, or departments — the table changes, the structure doesn't.