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
2
Q
What is CASE used for in a query statement?
A
It’s a means of creating conditional statements in a query statement