Bird
0
0

Which SQL feature best supports this flexible reuse without creating permanent objects?

hard📝 Application Q8 of 15
SQL - Common Table Expressions (CTEs)
You need to frequently generate reports showing total sales by region, but sometimes want to filter regions with sales over 10000. Which SQL feature best supports this flexible reuse without creating permanent objects?
ACreate a permanent view with the sales aggregation and filter in the reports
BUse a Common Table Expression (CTE) to define total sales and apply filters as needed
CWrite nested subqueries each time with the filter applied
DUse a temporary table to store sales data and filter it
Step-by-Step Solution
Solution:
  1. Step 1: Identify need for flexible reuse without permanent objects

    CTEs provide temporary named result sets reusable within a query.
  2. Step 2: Evaluate options

    Permanent views create stored objects; nested subqueries reduce readability; temporary tables require extra management.
  3. Final Answer:

    Use a Common Table Expression (CTE) to define total sales and apply filters as needed -> Option B
  4. Quick Check:

    CTEs enable flexible, temporary reusable query parts [OK]
Quick Trick: CTEs allow flexible filtering without permanent objects [OK]
Common Mistakes:
  • Choosing views which are permanent
  • Rewriting nested subqueries repeatedly
  • Using temporary tables unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes