runtime
76 / 139

task Rolling windows & frames · hard

Predict: a frame that includes peers

Predict the running total ordered by posting date (not time) for account 1 in late January.

what to return

Columns
transaction_idposted_dayamount_centsrunning in this order
Rows
in the order asked
Watch for
Use only the sample rows shown. NULL is not zero or empty text. Keep duplicate rows.
Skill
Reason about the exact result of a fixed SQL query. Refresher: FIRST_VALUE, LAST_VALUE & frames →

data you can query

Finance / Payments dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.

posting_sample3 columns · 5 rows
transaction_idposted_daydateamount_cents
81492025-01-23-7655
90152025-01-24155222
92732025-01-24-8599
113962025-01-30-6852
122032025-01-30-5771
transaction_id
8149
posted_daydate
2025-01-23
amount_cents
-7655
transaction_id
9015
posted_daydate
2025-01-24
amount_cents
155222
transaction_id
9273
posted_daydate
2025-01-24
amount_cents
-8599
transaction_id
11396
posted_daydate
2025-01-30
amount_cents
-6852
transaction_id
12203
posted_daydate
2025-01-30
amount_cents
-5771

all 5 rows

predict.sql
SELECT
  transaction_id,
  posted_day,
  amount_cents,
  SUM(amount_cents) OVER (ORDER BY posted_day) AS running
FROM posting_sample
ORDER BY posted_day, transaction_id
Read the query · predict its result
SELECT transaction_id, posted_day, amount_cents, SUM(amount_cents) OVER (ORDER BY posted_day) AS running FROM posting_sample ORDER BY posted_day, transaction_id

Look at the sample tables and SQL. Enter the rows you think the query returns, in this column order: transaction_id, posted_day, amount_cents, running. Put each row in square brackets, then wrap all rows in another pair of brackets (JSON format). For example, [[1,null,null,null]] is one row with 4 values. Replace these with your predicted values. Use numbers without quotes, text in double quotes, and null for SQL NULL. Keep repeated rows. Use [] for no rows. Keep rows in the order specified by ORDER BY.

Hints and the answer are always available. Using them counts the question as solved with help.

Predict: a frame that includes peers — SQL practice · Runtime