SQLize Online / PHPize Online

A A A
Share      Blog   Popular
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(case when income is not null then income else outcome end) over(partition by trans_id order by posting_datatime) as total from t order by posting_datatime;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy