SQL

Store Inventory Analysis

Capstone: Store Inventory Analysis

Congratulations on reaching the capstone! Let's apply everything you've learned.

Challenge 1: Best Category

The store manager wants to know which category has the highest average price.

Write a query that shows:

  • Each category
  • The average price for that category

Order the results by average price (highest first) and limit to 1 result.

Strategy

You'll need to combine three concepts:

  • GROUP BY to get averages per category
  • ORDER BY ... DESC to sort highest first
  • LIMIT 1 to get only the top result

Query Structure

SELECT column, AGG(column)
FROM table
GROUP BY column
ORDER BY AGG(column) DESC
LIMIT 1;
query.sql
Loading SQL engine...
Downloading SQL engine… (one-time)

Downloading SQL engine… (one-time)

This runs entirely in your browser and is cached for next time.