all problems

Most expensive product per category

sqlmediumGROUP BYMAX

For each product category return the category and the highest price in it, aliased as max_price. Sort by max_price descending.

hint ladder

query.sql
loading editor…
step inspector

Write a query with WITH … AS (…) blocks, then inspect each intermediate table before the final SELECT.

output

Run your code to see its output, or check your solution to grade it.

Reference solution

The shape we check against. Compare it with your query: the set of rows matters, the formatting does not.

SELECT category, MAX(price) AS max_price FROM products GROUP BY category ORDER BY max_price DESC;

Code is blurred until you solve this problem — the reasoning stays readable.