SQL Database Conditional Flow Quiz
A 35-question quiz exploring conditional logic, CASE expressions, value mapping, multi-branch logic, derived classifications, and conditional aggregation.
Question 1
An analyst wants to convert numeric ratings into labels such as 'Low', 'Medium', and 'High' when producing a report. Which structure enables grouping values into categories?
Question 2
A team wants to show 'Active' for customers with recent purchases and 'Dormant' otherwise. What feature allows returning different labels depending on conditions?
Question 3
A reviewer wants to label orders as 'Large' when quantity is above 50 and 'Standard' otherwise. Which CASE pattern fits this?
Question 4
A finance report displays 'Premium Tier' for balances above a threshold and 'Standard Tier' otherwise. Which CASE structure supports fallback logic?
Question 5
A table stores status codes like 1, 2, and 3. A designer wants readable labels such as 'Pending', 'Approved', and 'Rejected'. What technique allows mapping discrete numeric values?
Question 6
A merch team wants to show 'Sale Item' if discount is non-zero, else show 'Regular'. Which logic allows evaluation based on a boolean-like condition?
Question 7
A designer wants to show different greetings based on user language preference. What structure handles multiple mutually exclusive options?
Question 8
A system displays different shipping messages depending on region. Why might CASE be preferred over storing region names directly in the message column?
Question 9
A company wants to classify products as 'Overstocked', 'Balanced', or 'Low Stock'. What does CASE help them achieve?
Question 10
A designer needs to generate custom sort order, placing VIP customers at the top and others afterwards. What advantage does CASE provide inside ORDER BY?
Question 11
A restaurant app displays 'Lunch Menu' or 'Dinner Menu' based on time of day. Why is CASE appropriate?
Question 12
In reporting, an analyst wants NULL scores to be displayed as 'No Score'. Which CASE feature supports this?
Question 13
A product page displays 'Out of Stock' when quantity is zero. Why is CASE preferable to storing this text permanently?
Question 14
A team wants to categorize transactions over $1000 as 'High Value'. What CASE form supports conditions that involve comparison operators?
Question 15
A user wants to display different category labels depending on product type, using direct equality checks. Which CASE variation is suitable?
Question 16
Analysts reviewing survey scores want to map groups such as 1–3 as 'Low', 4–7 as 'Medium', and 8–10 as 'High'. What characteristic of CASE makes this possible?
Question 17
A report wants to switch between two values depending on a single condition—if overdue, show 'Late'; otherwise show 'On Time'. Which simplified CASE structure fits?
Question 18
A dashboard displays accounts as 'Inactive' if last login is more than one year ago. Which CASE feature helps evaluate date-based conditions?
Question 19
A data analyst wants a label for every region except one, which should display a special message. Why does CASE help maintain this exception?
Question 20
A system assigns risk levels to transactions based on multiple attributes like amount, location, and time. Which CASE feature makes this easier?
Question 21
A category label depends on whether a numeric field falls within certain ranges. Why must CASE branches be ordered carefully?
Question 22
This logic labels orders depending on quantity. What output appears when quantity is 80?
SELECT CASE
WHEN quantity > 50 THEN 'Large'
ELSE 'Standard'
END AS size_label;Question 23
This expression maps role codes to readable labels. What label is returned for code = 2?
SELECT CASE role
WHEN 1 THEN 'Admin'
WHEN 2 THEN 'Staff'
ELSE 'Guest'
END;Question 24
What does this CASE produce if stock is NULL?
SELECT CASE
WHEN stock = 0 THEN 'Empty'
ELSE 'Available'
END;Question 25
What category does this CASE assign when score = 5?
SELECT CASE
WHEN score >= 8 THEN 'High'
WHEN score >= 4 THEN 'Medium'
ELSE 'Low'
END;Question 26
This CASE uses direct equality. What is returned when type = 'B'?
SELECT CASE item_type
WHEN 'A' THEN 'Priority'
WHEN 'B' THEN 'Regular'
ELSE 'Other'
END;Question 27
For price = 0, what does this CASE produce?
SELECT CASE
WHEN price > 0 THEN 'Paid'
ELSE 'Free'
END;Question 28
This CASE handles text states. What is returned for state = 'C'?
SELECT CASE state
WHEN 'A' THEN 'Open'
WHEN 'B' THEN 'Pending'
ELSE 'Closed'
END;Question 29
What label appears when units = 12?
SELECT CASE
WHEN units >= 20 THEN 'Bulk'
WHEN units >= 10 THEN 'Standard'
ELSE 'Small'
END;Question 30
For rating = 9, which label appears?
SELECT CASE
WHEN rating < 3 THEN 'Poor'
WHEN rating < 7 THEN 'Average'
ELSE 'Excellent'
END;Question 31
When views = NULL, what is produced?
SELECT CASE
WHEN views > 1000 THEN 'Popular'
ELSE 'Normal'
END;Question 32
What value is returned here for dept = 'HR'?
SELECT CASE dept
WHEN 'HR' THEN 'Admin'
WHEN 'IT' THEN 'Tech'
ELSE 'Other'
END;Question 33
What happens when salary = 3000?
SELECT CASE
WHEN salary > 5000 THEN 'High'
WHEN salary > 2000 THEN 'Medium'
ELSE 'Low'
END;Question 34
For level = 0, what does this return?
SELECT CASE
WHEN level >= 5 THEN 'Expert'
WHEN level >= 1 THEN 'Intermediate'
ELSE 'New'
END;Question 35
For points = 15, what label is assigned?
SELECT CASE
WHEN points >= 20 THEN 'Gold'
WHEN points >= 10 THEN 'Silver'
ELSE 'Bronze'
END;