Introduction
1. Introduction
Simple CASE WHEN
Searched CASE WHEN
CASE WHEN with aggregates
CASE WHEN with GROUP BY
Revision

## Instruction

Hello for the seventh time in this course! Today, we're going to learn a powerful construction in SQL, namely CASE WHEN … THEN … ELSE … END (in short: CASE WHEN). Just by looking at the keywords, you may already guess that we're going to introduce conditional statements to our SQL queries: if A happens, then do B.

The CASE WHEN statement isn't a new function in SQL, it's a completely new construction in SQL. It is very commonly used with various aggregate functions, so we decided to include it in this course.

But first things first. Today, we're going to help a university which is currently accepting students for five brand-new degree courses. Want to find out what they are? Well, let's check that!

## Exercise

Select all the information from the table course.

We've got an id, a name and place_limit which describes the number of students that can be accepted.

Then we've got a boolean column (scholarship) which tells us whether it is possible to get a national scholarship for that course.

The final column, graduate_satisfaction, shows the results of a survey among graduates with a maximal score of 100. Some scores are NULL because the courses are new and we don't know the opinion yet.

Oh, and by the way, these are authentic degree courses offered around the world!

Code editor

TableConsole