Count orders by status.
Section: aggregation and grouping
Group rows and count them
sql
sql
SELECT status, COUNT(*) AS total
FROM orders
GROUP BY status
ORDER BY total DESC;Explanation
A common reporting pattern for order states, ticket states, and similar grouped data.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing aggregation and grouping