QuizzesLEAD & LAG — Concept Check
intermediate
sql

LEAD & LAG — Concept Check

Questions on LEAD & LAG. LAG accesses the value of a column from a previous row; LEAD accesses a future row — both within the current partition — enabling period-over-period comparisons without self-joins.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on LEAD & LAG — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A report shows the monthly revenue and its month-over-month change. Which SQL function would you use to access the previous month's revenue for comparison?

    • ALEAD
    • BLAG
    • CSUM
    • DAVG
  2. 2.In a dataset of user orders, you need to find users who placed orders on consecutive days. Which SQL function helps you identify the previous order date for each user?

    • AROW_NUMBER
    • BLAG
    • CLEAD
    • DRANK
  3. 3.You want to calculate the time gap between consecutive orders for each user. Which SQL function would you use to access the next order date?

    • ALAG
    • BDATEDIFF
    • CLEAD
    • DTIMESTAMPDIFF
  4. 4.A developer uses LEAD to find gaps in a sequence. What will LEAD return when there is no next row and no default value is provided?

    • A0
    • BAn error
    • CThe last row's value
    • DNULL
  5. 5.When using LAG to detect status changes in a dataset, what happens if there is no previous row?

    • AReturns NULL
    • BCauses an error
    • CReturns the current row's value
    • DReturns 0
  6. 6.A report shows a sudden drop in monthly revenue change percentage. Which SQL function can help verify if the previous month's revenue was unusually high?

    • ALAG
    • BMIN
    • CLEAD
    • DMAX
  7. 7.You need to fill in missing values in a sequence by looking at the next available value. Which function is appropriate?

    • ALEAD
    • BNVL
    • CCOALESCE
    • DLAG
  8. 8.A developer believes LEAD can only look one row ahead. Which parameter allows you to specify how many rows ahead LEAD should look?

    • APartition
    • BOffset
    • COrder
    • DWindow