Skip to content
RED SAGSkills

Account Balance Tiers

A digital wallet labels each account by its current balance:

- NULL balance: unknown - below 0: overdrawn - 0 up to (but not including) 1000: standard - 1000 or more: premium

Return columns account_id, tier. Row order does not matter.

Schema

CREATE TABLE accounts (
  account_id INTEGER PRIMARY KEY,
  holder TEXT NOT NULL,
  balance REAL
);

Sample data

accounts

account_idholderbalance
1Layla2500
2Marco-40.25
3Nadia999.99
4OscarNULL
5Pooja0
6Rami1000
Hint 1

CASE checks its WHEN branches top to bottom and stops at the first match.

Hint 2

Put the NULL check first. A NULL balance fails every comparison and would otherwise fall through to ELSE.

Good practice for: Data Analyst, Backend Developer, Business Analyst

SQL (SQLite)

Run checks your query on the sample data (Ctrl + '). Submit also checks hidden databases.