Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
create table t(account_no varchar(10),trans_id varchar(1000),posting_datatime datetime,Income int, Outcome int); insert into t select '001','11111111','2021-12-01 00:00',100 ,null union all select '001','11112331','2021-12-04 04:00',10 ,null union all select '021','11111031','2021-12-04 04:23',1200 ,null union all select '001','11111231','2021-12-08 07:44',null ,40 union all select '001','00011231','2021-12-20 11:59',200 ,null; select account_no ,trans_id ,posting_datatime ,income ,outcome ,sum(income) over(partition by trans_id order by posting_datatime) as total from t order by posting_datatime;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear