
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
15 questions
LIQUID LIQUID EXTRACTION
Quiz
•
University - Professi...
11 questions
Funny Military Trivia
Quiz
•
Professional Development
20 questions
WCS 1105-1 - Knowledge Assessment
Quiz
•
Professional Development
15 questions
Embedded Systems Q1
Quiz
•
Professional Development
10 questions
Imagery
Quiz
•
10th Grade - Professi...
10 questions
Verificación - notas internas
Quiz
•
Professional Development
10 questions
NSD Quiz 2!
Quiz
•
Professional Development
10 questions
Computerised Accounting
Quiz
•
Professional Development
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
Discover more resources for Other
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
25 questions
Christmas Movies
Quiz
•
Professional Development
20 questions
Christmas Trivia
Quiz
•
Professional Development
15 questions
Fun Holiday Trivia
Quiz
•
Professional Development
25 questions
Name That Tune - Christmas
Quiz
•
Professional Development
29 questions
Christmas Song Emoji Pictionary
Quiz
•
Professional Development
9 questions
Holiday Movie Trivia
Lesson
•
Professional Development
34 questions
Winter Trivia
Quiz
•
Professional Development
