Bolt Drive maintains a catalog of car models and vehicle price records across its operating cities. Write a PostgreSQL query that reports the lowest active price for every model, including models that currently have no active price.
Requirements
- Use a CTE to calculate the minimum
price_eur for each model from active price records only.
- Return every model from
car_models, including models without matching active prices.
- Output the brand, model name, and lowest active price in model ID order.
- Ignore inactive records and records whose
model_id is NULL through the join and filtering logic.
Output details
- Return columns named
brand, model_name, and lowest_active_price_eur, in that order.
- Order rows by
model_id ascending.
- Return
NULL for lowest_active_price_eur when a model has no active price.