CASE Clauses Flashcards

1
Q

Return first_name, salary, and a column which says “UNDER PAID” if salary is < 1000000, “PAID WELL” if salary is > 100000, and “UNPAID” if there is no salary value from the employees table

A
SELECT first_name, salary,
CASE 
  WHEN salary < 100000 THEN 'UNDER PAID'
  WHEN salary > 100000 THEN 'PAID WELL'
  ELSE 'UNPAID'
END
FROM employees
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is CASE used for in a query statement?

A

It’s a means of creating conditional statements in a query statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly