-- Online PostgreSQL (a real Postgres 18 running in your browser)
-- Sample tables: customers, products, orders. Try \dt or \d orders
SELECT category,
count(*) AS products,
round(avg(price), 2) AS avg_price,
string_agg(name, ', ' ORDER BY name) AS names
FROM products
GROUP BY category
ORDER BY products DESC;
Press ▶ Run or Ctrl/⌘ + Enter to run your code.
Sample tables: customers, products, orders. psql commands like \dt and \d orders work too.