Your question is SQL Grouping With Conditions. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
CarGurus wants to compare listing-quality marks across dealer groups. Write a PostgreSQL query that calculates the average mark for each dealer group using only listings with marks greater than 500.
dealer_groups to listings using the dealer group identifier.| Column | Type | Description |
|---|---|---|
| group_idPK | INT | Unique dealer group identifier |
| group_name | VARCHAR(100) | Dealer group name |
| market | VARCHAR(50) | Primary geographic market |
| Column | Type | Description |
|---|---|---|
| listing_idPK | INT | Unique vehicle listing identifier |
| group_id | INT | Dealer group associated with the listing |
| vehicle_title | VARCHAR(150) | Vehicle title displayed on CarGurus |
| marks | INT | Listing-quality mark |