This question evaluates SQL data-manipulation skills including aggregation, conditional filtering, NULL handling, grouping, and deterministic ordering, and sits in the Data Manipulation (SQL/Python) domain with an emphasis on practical application of query writing rather than purely conceptual design.

You have two tables. Schema:
purchase purchase_id | product_id | price | stars 10 | 1 | 999.00 | 5 11 | 1 | 1099.00| 3 12 | 2 | 1299.00| 4 13 | 3 | 49.00 | 5 14 | 3 | 39.00 | 2 15 | 4 | 199.00 | 4 16 | 4 | 179.00 | NULL 17 | 5 | 299.00 | NULL Expected output on the sample: category | price Apple | 999.00 Banana | 49.00 Orange | 0 Pear | 0 Write a single SQL query (PostgreSQL or MySQL compatible) that produces the required output on all inputs, handling: categories with no purchases at all; multiple qualifying purchases per category; and ensuring numeric 0 (not NULL) when no stars > 4 exist.