Category Totals

SQL practice problem 24 of 67 · Aggregation · Medium · 25 coins for your first accepted solve

For every category, return the number of items and their avg_price rounded to 2 decimals.

Add one more row with the category All that covers every item. Row order does not matter.

Schema

CREATE TABLE items (
  id        INT PRIMARY KEY,
  name      TEXT NOT NULL,
  category  TEXT NOT NULL,
  price     NUMERIC(8,2) NOT NULL
);

Write your query in the browser, run it on the sample data, then submit it against hidden test data.

Previous: Country Roster · Next: Guild Hoppers · All problems