Solutionunvalidated
Use a union of two event rows per order (createdat with val=0 and doneat with val=price when status='completed' else 0), then compute sum(val) over (partition by userid order by event time, keep desc) and filter to the created rows to produce the cumulative total at placement.
c19b7eeb-4e78-4090-9939-f91cad7575ea
Use a union of two event rows per order (createdat with val=0 and doneat with val=price when status='completed' else 0), then compute sum(val) over (partition by userid order by event time, keep desc) and filter to the created rows to produce the cumulative total at placement.