runtime
77 / 88

task LAG / LEAD · medium

Predict: the previous member within a team

Predict each member’s previous credits within their team, in id order. A team’s first member has no previous row.

what to return

Columns
idprevious_credits in this order
Rows
4 rows · in the order asked
Watch for
Use the sample data shown here. NULL is not zero or empty text. Keep duplicate result rows.
Skill
Reason about the exact result of a fixed SQL query. Refresher: Compare rows with LAG →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result4 rows · in this order
idprevious_credits
1NULL
280
3NULL

first 3 of 4 rows

data you can query

Sample rows from each table. Each column shows its type underneath; → marks a link to another table.

studio_members4 columns · 4 rows
idinteger · keynametextteamtextcreditsinteger
1LuzRed80
2KitRed80
3RemyBlue50
4SolBlueNULL

all 4 rows

studio_bookings4 columns · 4 rows
idinteger · keymember_idinteger → studio_membersfeeintegerbooked_attext
111202026-04-01
121302026-04-30
132NULL2026-05-01
14NULL202026-04-15

all 4 rows

This question asks you to predict an output. The prototype covers write and debug questions; open it in the current app.

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