Question: Lesson 2 9 : CASE You can use a CASE statement to return certain values when certain scenarios are true. A CASE statement takes the

Lesson 29: CASE
You can use a CASE statement to return certain values when certain scenarios are true.
A CASE statement takes the following form:
CASE WHEN THEN WHEN * second thing is true* THEN
ELSE END
For example, in order to return the number of legs for each row in friends_of_pickles, you could run:
SELECT *,
CASE WHEN species = 'human' THEN 2 ELSE 4 END AS num_legs
FROM friends_of_pickles;
Can you return the results with a column named sound that returns "talk" for humans, "bark" for dogs, and "meow" for cats?
 Lesson 29: CASE You can use a CASE statement to return

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!