Real data is rarely uniform. In the orders table most orders are paid, and only a few are returned. A query planner needs to know this distribution (a histogram of values) to judge how selective a filter is: status = 'returned' matches few rows, status = 'paid' matches most.
Write a query returning, for every status, the number of orders as row_count and the share of all orders as pct (a percentage rounded to 1 decimal place). Order by row_count descending, then by status.
status, row_count, pctpct = 100 × row_count ÷ total orders, rounded to 1 decimalrow_count descending, then statusGroup by status and divide each count by (SELECT COUNT(*) FROM orders).
Use 100.0 * (not 100 *) so the division is not an integer division.
No results yet
Run your code to check it against the examples, or submit to run every test.