Bird
0
0

Which of the following is the correct syntax to use the LEAD function to get the next row's salary ordered by employee_id?

easy📝 Syntax Q12 of 15
SQL - Advanced Window Functions
Which of the following is the correct syntax to use the LEAD function to get the next row's salary ordered by employee_id?
ALEAD(salary) OVER (ORDER BY employee_id)
BLEAD(salary ORDER BY employee_id)
CLEAD(salary) ORDER BY employee_id
DLEAD(salary) BY employee_id
Step-by-Step Solution
Solution:
  1. Step 1: Recall LEAD function syntax

    The LEAD function requires an OVER clause with an ORDER BY to define the row order for accessing the next row.
  2. Step 2: Match syntax with options

    LEAD(salary) OVER (ORDER BY employee_id) correctly uses LEAD(salary) OVER (ORDER BY employee_id). Options A, B, and D have incorrect syntax.
  3. Final Answer:

    LEAD(salary) OVER (ORDER BY employee_id) -> Option A
  4. Quick Check:

    LEAD + OVER + ORDER BY = correct syntax [OK]
Quick Trick: LEAD needs OVER(ORDER BY ...) syntax [OK]
Common Mistakes:
  • Omitting OVER clause
  • Placing ORDER BY inside LEAD parentheses
  • Using BY instead of ORDER BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes