Problem
When building a product filter sidebar, the front-end needs a list of every category that exists so it can render checkboxes or dropdown options. Rather than hardcoding the list in the UI, engineers query the database at load time so the filter always reflects the current catalogue. Using the products table, return each distinct category in alphabetical order.
Schema
products
| column | type |
|---|
| id | INTEGER |
| name | TEXT |
| category | TEXT |
| price | NUMERIC |
Sample Data
| id | name | category | price |
|---|
| 1 | Widget | Tools | 9.99 |
| 2 | Gadget | Electronics | 149.99 |
| 3 | Gizmo | Electronics | 79.99 |
| 4 | Doohickey | Tools | 24.99 |
| 5 | Bracelet | Accessories | 19.99 |
Expected Output
| category |
|---|
| Accessories |
| Electronics |
| Tools |