settlements has one row per trade (trade_id, city, status). Return each city that has at least one trade with status 'completed', together with its number of completed trades. Cities with no completed trades are not returned. Output columns: city, completed_trades. Order by city ascending.
| Column | Type |
|---|---|
| trade_id | INTEGER |
| city | TEXT |
| status | TEXT |
| trade_id | city | status |
|---|---|---|
| 1 | New York | completed |
| 2 | Chicago | pending |
| 3 | New York | completed |
| 4 | Austin | completed |
| 5 | Chicago | completed |
| city | completed_trades |
|---|---|
| Austin | 1 |
| Chicago | 1 |
| New York | 2 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Repeated Vacancy Advertisements · Product Feedback Scorecards ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.