Bucketing and Labeling Data
Turn values into categories.
What Is Bucketing?
Bucketing means grouping raw values into named categories — turning numbers, dates, or codes into human-readable labels.
Instead of showing a score of 87, you show "Good". Instead of showing an age of 14, you show "Teen". The CASE expression is your main tool for this.
Sample Table: Orders
We will use an orders table throughout this lesson. Each row has an order amount and a status code.
Run the query below to see the data we are working with.
SELECT id, customer, amount, status
FROM orders
ORDER BY id;All lessons in this course
- The CASE Expression
- Searched vs Simple CASE
- Bucketing and Labeling Data
- CASE in ORDER BY and Aggregates