SQL practice: CASE WHEN: If/Else Inside a Query

Chapter 8 · 8 questions · included in full access

  1. Question 1 · easy

    Label employees 'Senior' if salary ≥ 80000, else 'Junior'.

    Solve it in your browser
  2. Question 2 · easy

    Label orders 'Done' if status is Delivered, else 'Not Done'.

    Solve it in your browser
  3. Question 3 · medium

    Label products 'Thick' if thickness is 4.0 or more, 'Thin' if less, and 'Not a sheet' if thickness is empty.

    Solve it in your browser
  4. Question 4 · medium

    Give each branch a label by region: North → 'Up North', South → 'Down South', everything else → 'Other'.

    Solve it in your browser
  5. Question 5 · medium

    For each product, show a margin_health column: 'Good' if profit (price − cost) is above 700, 'OK' if above 400, else 'Thin'.

    Solve it in your browser
  6. Question 6 · medium

    For each customer, show 'Old customer' if they signed up before 2019, 'Newer' otherwise, and 'Unknown' if the date is empty. (Order your WHENs carefully.)

    Solve it in your browser
  7. Question 7 · hard

    Show each employee with a band column: '80k+', '40k-80k', or 'under 40k'.

    Solve it in your browser
  8. Question 8 · hard

    Label each product 'Premium' (3000 or more), 'Standard' (1000 or more) or 'Budget'. No product ever comes out Premium. Fix it.

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing