Which CASE expression assigns 'high' for score > 80, 'medium' for >=50, else 'low'?

Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

Which CASE expression assigns 'high' for score > 80, 'medium' for >=50, else 'low'?

Explanation:
This question tests how a CASE expression maps numeric values to labeled categories using ordered conditions. The first WHEN checks score > 80, so any score strictly above 80 becomes 'high'. If that isn’t true, the next WHEN handles scores that are at least 50, capturing values from 50 up to 80 (since those above 80 were already handled). If neither condition applies, the ELSE yields 'low'. This ordering ensures the categories match the specification: above 80 is high, 50 through 80 is medium, and anything below 50 is low. The important point is that the first true condition determines the result, so using > 80 for high and >= 50 for medium places 80 and 50 exactly where intended (80 goes to medium, 50 goes to medium, 49 goes to low).

This question tests how a CASE expression maps numeric values to labeled categories using ordered conditions. The first WHEN checks score > 80, so any score strictly above 80 becomes 'high'. If that isn’t true, the next WHEN handles scores that are at least 50, capturing values from 50 up to 80 (since those above 80 were already handled). If neither condition applies, the ELSE yields 'low'. This ordering ensures the categories match the specification: above 80 is high, 50 through 80 is medium, and anything below 50 is low. The important point is that the first true condition determines the result, so using > 80 for high and >= 50 for medium places 80 and 50 exactly where intended (80 goes to medium, 50 goes to medium, 49 goes to low).

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy