Your organization stores order data in different relational database engines, including PostgreSQL 16, MySQL 8 and Microsoft SQL Server 2022. You have been asked to deliver a single ANSI-SQL query that will run unchanged in all three systems. The query must calculate a column named order_type that returns the string "Bulk" when the quantity column is greater than 500 and "Regular" for all other rows. Which logical function or construct should you use inside the SELECT list to create that column while meeting the portability requirement?
The SQL-standard CASE expression is supported by every major relational database, so a single query such as
SELECT
CASE WHEN quantity > 500 THEN 'Bulk' ELSE 'Regular' END AS order_type,
...
FROM orders;
works the same way in PostgreSQL, MySQL and SQL Server. IIF is only available in SQL Server (introduced in 2012) and Microsoft Access, so it would fail on PostgreSQL or MySQL. DECODE and NVL are proprietary Oracle functions; neither is recognized by the three target platforms. Therefore, choosing CASE is the only option that satisfies the cross-platform requirement.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is an ANSI-SQL CASE expression?
Open an interactive chat with Bash
Why can't the IIF function be used for cross-database queries?
Open an interactive chat with Bash
What are DECODE and NVL functions, and why aren’t they portable?
Open an interactive chat with Bash
CompTIA Data+ DA0-002 (V2)
Data Analysis
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .