BasicsDISTINCTORDER BYGoogleAmazonMeta
Table
customers(customer_id INT, country VARCHAR)
Task
From customers(customer_id, country), return every unique non-null country sorted alphabetically.
Why It Matters: SELECT DISTINCT eliminates duplicate dimension values when building dropdowns, regional rollups, or unique-entity counts.
Output columns: country
Example
Input — customers
| customer_id | country |
|---|---|
| 1 | US |
| 2 | IN |
| 3 | US |
| 4 | DE |
Expected Output
| country |
|---|
| DE |
| IN |
| US |
Explanation: Duplicate country values collapse into one row per unique country, sorted alphabetically.
Requirements
- Exact output columns:
country - Row order: Exact
ORDER BYorder is checked by the grader. - Query type: Write a single read-only Standard SQL
SELECT(orWITH ... SELECT) query.
Constraints & Evaluation Criteria
- Return a single column `country` sorted alphabetically.
Hints
SQL⌘/Ctrl+Enter to Run · ⌘/Ctrl+Shift+Enter to Submit
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
customers (4 rows)
Expected Output / Criteria
3 row(s): (DE); (IN); (US)