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

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
prediction.json

Enter the rows you think the query returns, column order transaction_id, posted_day, amount_cents, running. JSON array of rows — numbers bare, text in quotes, null for NULL. Example: [ [ 1, null, null, null ] ]. Keep ORDER BY order.

 
Output

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