Courseiva

PDE Preparing and Using Data for Analysis Practice Question

You have a BigQuery table `orders` with columns `order_id` (STRING), `customer_id` (STRING), `order_date` (DATE), and `amount` (NUMERIC). You need to create a view that shows, for each order, the cumulative sum of `amount` for that customer, ordered by `order_date` ascending. Which SQL window function or clause should you use?

⚠ Common exam trap

Many exam-takers confuse ROWS and RANGE frames; RANGE includes peers with the same ORDER BY value, which can inflate the running total when multiple orders share the same date.

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

✓

SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

To compute a cumulative sum per customer ordered by date, you need a window function with PARTITION BY customer_id and ORDER BY order_date, and an explicit frame that includes all preceding rows up to the current row. The ROWS frame ensures that each row's sum includes only rows up to that point, avoiding grouping of same-date orders. This yields a true running total for each order.

Answer analysis

Option-by-option breakdown

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

  • ✓

    SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

    Why this is correct

    This window function correctly partitions by customer_id, orders by order_date, and defines the frame from the start of the partition to the current row, producing a running total per customer. The ROWS clause ensures cumulative sum includes all previous rows and the current row, which is exactly what is needed for each order.

  • ✗

    SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

    Why it's wrong here

    Using RANGE instead of ROWS with ORDER BY order_date will include all rows with the same order_date as the current row, even if they are not yet processed. This can cause incorrect cumulative sums when multiple orders share the same date, as it sums them all at once rather than sequentially.

  • ✗

    SUM(amount) OVER (ORDER BY order_date PARTITION BY customer_id)

    Why it's wrong here

    The syntax is invalid because PARTITION BY must come before ORDER BY in the OVER clause. BigQuery will reject this query. Even if corrected, without an explicit frame, the default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which may include peers and not give a strict running total.

  • ✗

    SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date) WITH TIES

    Why it's wrong here

    The WITH TIES clause is used with TOP or FETCH FIRST to include additional rows that tie with the last row in the ordered result set. It is not valid in a window function specification. This option is syntactically incorrect and will not execute in BigQuery.

About these practice questions

One of 747 original PDE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Google Cloud exam blueprint

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.