Distinct Languages Spoken by Each Guide
Problem
A travel agency records which languages each tour guide offers and in which region. Table `guide_languages` has columns `(guide_id, language_id, region_id)`, and the pair `(language_id, region_id)` is unique. A single row means the guide offers that language in that region, so the same guide can appear with the same language across several regions.
Count how many distinct languages each guide offers across all regions.
Return the columns `guide_id` and `language_count`, in any order.
Tables
Example rows — the live problem includes the full dataset.
| guide_id | language_id | region_id |
|---|---|---|
| 1 | 2 | 3 |
| 1 | 2 | 4 |
| 1 | 3 | 3 |
Expected output
Your answer should return 2 rows with the columns guide_id, language_count.
Starter code (SQL)
SELECT *
FROM guide_languages;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock