Bird
0
0

Why is calculating running totals without window functions generally less efficient than using window functions?

hard📝 Conceptual Q10 of 15
SQL - Advanced Query Patterns
Why is calculating running totals without window functions generally less efficient than using window functions?
ABecause running totals cannot be calculated without window functions.
BBecause window functions do not support ordering.
CBecause window functions require temporary tables.
DBecause correlated subqueries or self-joins require repeated scanning of rows for each row processed.
Step-by-Step Solution
Solution:
  1. Step 1: Understand how running totals are calculated without window functions

    They use correlated subqueries or self-joins that scan rows repeatedly for each row.
  2. Step 2: Compare with window functions

    Window functions calculate running totals in a single pass efficiently using internal optimizations.
  3. Final Answer:

    Because correlated subqueries or self-joins require repeated scanning of rows for each row processed. -> Option D
  4. Quick Check:

    Repeated scanning = Less efficient than window functions [OK]
Quick Trick: Correlated subqueries scan rows repeatedly, slowing queries [OK]
Common Mistakes:
  • Thinking window functions lack ordering
  • Believing running totals need window functions
  • Assuming window functions use temporary tables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes