Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Query Results

Run a query to see results.

Database Schema

Schema undefined.
Code Editor

Almost every programming language has a way to represent "if, then, else", or conditional logic. In SQL, we represent this logic with the CASE statement, as follows:

SELECT CASE WHEN elevation < 500 THEN 'Low' WHEN elevation BETWEEN 500 AND 1999 THEN 'Medium' WHEN elevation >= 2000 THEN 'High' ELSE 'Unknown' END AS elevation_tier , COUNT(*) FROM airports GROUP BY 1;

In the above statement, END is required to terminate the statement, but ELSE is optional. If ELSE is not included, the result will be NULL. Also notice the shorthand method of referencing columns to use in GROUP BY, so we don't have to rewrite the entire Case Statement.

Report a Bug
If you see a bug or any other issue with this page, please report it here.