
SQL CASE Statement MCQs
Quiz
•
Other
•
Professional Development
•
Practice Problem
•
Hard
Dinesh Kumar
FREE Resource
Enhance your content in a minute
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What does the following CASE statement do? SQL: SELECT OrderID, CASE WHEN Sales > 500 THEN 'High' ELSE 'Low' END AS SalesCategory FROM Orders;
Classifies sales into multiple bands
Returns NULL for Sales < 500
Categorizes each order as 'High' or 'Low' based on sales
Updates Sales values
Answer explanation
The CASE statement categorizes each order based on the Sales value. If Sales is greater than 500, it labels the order as 'High'; otherwise, it labels it as 'Low'. Thus, it effectively categorizes orders into 'High' or 'Low'.
2.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
Which SQL clause can include a CASE statement?
SELECT
WHERE
ORDER BY
All of the above
Answer explanation
The CASE statement can be used in various SQL clauses, including SELECT for conditional column values, WHERE for filtering, and ORDER BY for sorting based on conditions. Therefore, the correct answer is 'All of the above'.
3.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What does the following query return? SQL: SELECT Region, CASE WHEN AVG(Sales) > 1000 THEN 'High Sales Region' ELSE 'Low Sales Region' END AS RegionCategory FROM Orders GROUP BY Region;
Error
Categorizes regions based on total orders
Labels regions by average sales
Filters regions
Answer explanation
The query results in an error because the AVG(Sales) function is used without a proper aggregation context in the GROUP BY clause. It does not categorize regions correctly.
4.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What is the output of this query? SQL: SELECT OrderID, CASE Profit WHEN 0 THEN 'No Profit' ELSE 'Some Profit' END AS ProfitStatus FROM Orders;
Returns error
Uses simple CASE to check Profit = 0
Categorizes into profit ranges
Complex condition evaluation
Answer explanation
The query uses a simple CASE statement to evaluate the Profit column. It checks if Profit equals 0 and returns 'No Profit'; otherwise, it returns 'Some Profit'. Thus, the correct choice is that it uses simple CASE to check Profit = 0.
5.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
Identify the type of CASE used below: SQL: SELECT OrderID, CASE WHEN Profit > 1000 THEN 'Excellent' WHEN Profit > 500 THEN 'Good' ELSE 'Average' END AS ProfitBand FROM Orders;
Simple CASE
Searched CASE
Nested CASE
Invalid syntax
Answer explanation
The SQL uses a Searched CASE because it evaluates multiple conditions (Profit > 1000, Profit > 500) rather than a single expression. This allows for more complex logic compared to a Simple CASE.
6.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
How many WHEN clauses can a CASE statement have?
Only one
Up to 2
Unlimited
Exactly 3
Answer explanation
A CASE statement can have an unlimited number of WHEN clauses, allowing for multiple conditions to be evaluated. This flexibility makes it a powerful tool for conditional logic in SQL.
7.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What does this query do? SQL: SELECT CustomerID, CASE WHEN EXISTS ( SELECT 1 FROM Returns WHERE Returns.CustomerID = Orders.CustomerID ) THEN 'Returned' ELSE 'Not Returned' END AS ReturnStatus FROM Orders;
Error due to EXISTS
Uses correlated subquery inside CASE
Uses HAVING clause
Filters only returned orders
Answer explanation
The query uses a correlated subquery within the CASE statement to check if a customer has any returns. It assigns 'Returned' or 'Not Returned' based on the existence of records in the Returns table for each CustomerID.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Let's Uncover our Knowledge!!!
Quiz
•
Professional Development
20 questions
Extreme Harry Potter Quiz - 20 Spell-tastic Questions!
Quiz
•
3rd Grade - Professio...
18 questions
Winter Joy
Quiz
•
KG - Professional Dev...
10 questions
RESILIENCE QUIZ ONE
Quiz
•
KG - Professional Dev...
15 questions
Selling Skills
Quiz
•
Professional Development
14 questions
Google Level 1
Quiz
•
Professional Development
20 questions
MEGA QUIZ-Pension Plans & Annuity Plans
Quiz
•
Professional Development
10 questions
Clause 4~7 How well did you pick up the contents?
Quiz
•
Professional Development
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for Other
10 questions
How to Email your Teacher
Quiz
•
Professional Development
6 questions
3RD GRADE DECLARATION OF INDEPENDENCE EXIT TICKET
Quiz
•
Professional Development
19 questions
Black History Month Trivia
Quiz
•
6th Grade - Professio...
22 questions
Multiplying Exponents with the Same Base
Quiz
•
9th Grade - Professio...
40 questions
Flags of the World
Quiz
•
KG - Professional Dev...
