Bird
0
0

Why does this query fail?

medium📝 Debug Q7 of 15
PostgreSQL - Indexing Strategies
Why does this query fail?
SELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan > 100 ORDER BY idx_scan DESC LIMIT;
Aidx_scan cannot be used in ORDER BY
BORDER BY cannot be used with LIMIT
CLIMIT requires a number specifying how many rows to return
DMissing WHERE clause condition
Step-by-Step Solution
Solution:
  1. Step 1: Check LIMIT syntax

    LIMIT must be followed by a number indicating how many rows to return.
  2. Step 2: Identify the error

    The query has LIMIT without a number, causing a syntax error.
  3. Final Answer:

    LIMIT requires a number specifying how many rows to return -> Option C
  4. Quick Check:

    LIMIT needs a count number [OK]
Quick Trick: Always specify a number after LIMIT [OK]
Common Mistakes:
  • Omitting number after LIMIT
  • Thinking ORDER BY and LIMIT conflict
  • Misusing idx_scan in ORDER BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes