Courseiva

PDE Preparing and Using Data for Analysis Practice Question

Which BigQuery function can be used to retrieve the value of a column from the previous row within a partition, ordered by a timestamp?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

LAG()

LAG() is a window function that returns the value of a column from a row that is a specified number of rows before the current row within the partition. LEAD() retrieves from a following row.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    LAG()

    Why this is correct

    LAG() is a navigation window function that returns a column's value from a preceding row within the same partition, evaluated by the ORDER BY timestamp. It satisfies the stem's requirement to retrieve the previous row's value, unlike LEAD(), which looks forward.

  • ✗

    FIRST_VALUE()

    Why it's wrong here

    FIRST_VALUE() returns the value from the first row of the window frame, not the immediately preceding row. It is tempting because it is an analytic function sharing the OVER clause. FIRST_VALUE() is correct when the earliest value in each partition, such as a cohort's initial timestamp, is required.

  • ✗

    ROW_NUMBER()

    Why it's wrong here

    ROW_NUMBER() assigns a sequential integer to each row within the partition; it returns a position, not a column value from another row. It is tempting because it also uses OVER(PARTITION BY... ORDER BY...). ROW_NUMBER() is correct for deduplication or ranking, not for accessing prior-row data.

  • ✗

    LEAD()

    Why it's wrong here

    LEAD() returns the value from the following row within the window frame, so it looks forward rather than backward. It is tempting because it shares the same OVER(PARTITION BY... ORDER BY...) syntax as the required function. LEAD() would be correct when the next row's timestamp or value is needed.

About these practice questions

This PDE question is part of Courseiva's 747-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PDE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PDE exam.