Free practice · Interactive SQL · easy

Practice

List distinct customer states

Return each state_code once, alias it as state, and sort the result alphabetically.

Practice database

US customer accounts

A fictional customer directory for hand-checkable beginner queries.

Runs locally in your browser

customers

Customer profile fields used for account reporting.

6 rows

Grain One row per customer

  • customer_idTEXTPK
  • customer_nameTEXT
  • cityTEXT
  • state_codeTEXT
  • segmentTEXT
  • signup_dateTEXT
Preview source rows
customer_idcustomer_namecitystate_codesegmentsignup_date
C-101Northstar HealthAustinTXHealthcare2025-11-15
C-102Blue Ridge BooksRichmondVARetail2025-12-01
C-103Pacific Office WorksSan DiegoCAMidmarket2026-01-08

SQL editor

Write one read-only query

SELECT and WITH only
Changes to this practice database are never saved.
Ready to check your work?Edit the starter query, run it, then compare your result with the task.