← All Exercises

SQL CASE Expressions

intermediatesql~15min

Background

CASE expressions provide if-then-else logic in SQL, enabling conditional values and transformations.

Problem

Write a SQL query that categorizes employees by salary range using CASE WHEN expressions.

Input

An employees table with id, name, salary columns.

Output

Employees with a salary_category column: Low, Medium, or High.

Sample tests

Sample 1

Input: salaries: 30000, 60000, 90000
Expected: Low, Medium, High

Your solution

Learning objective

Learn searched CASE, simple CASE, and conditional value assignment in SQL.