GCGrowCarrer

Conditionals and Branching

Locked

Lesson 4 of 25 · Syntax · Easy

Finish these first:Operators and Comparisons →Or pass the tests below to unlock it now.

1

The big idea

In SQL, you make an if / else decision using CASE WHEN ... THEN ...

Think of it like this: Think of SQL's `CASE WHEN ... THEN ... ELSE ... END` like reading an `if / else` sentence out loud in plain English.
Key words (tap to learn):
2

Read the lesson

In SQL, you make an if / else decision using CASE WHEN ... THEN ... ELSE ... END:

SELECT CASE
  WHEN 92 >= 90 THEN 'A'
  ELSE 'B'
END;

SQL checks the WHEN rule first. If it is true, it gives back the THEN value; otherwise it gives back the ELSE value. Always close CASE with END.

3

Quick check

Which keyword finishes a SQL `CASE` expression?

4

Your challenge

1 sample test, 1 hidden

Write a SQL CASE check that returns 'adult' when 20 >= 18 and 'minor' otherwise (type SELECT CASE WHEN 20 >= 18 THEN 'adult' ELSE 'minor' END;).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to python.conditionals (92% overlap). Branching control flow: if/else and switch/match expressions.

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Conditionals and Branching.

Mastery0%

Learn this first