SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table HT (num int, qty int); create table DT (num int, seq int, qty int); insert into HT values(1, 0); insert into HT values(2, null); insert into HT values(3, 10); insert into DT values(1, 1, 10); insert into DT values(1, 2, 20); insert into DT values(1, 3, 30); insert into DT values(2, 1, 15); update HT set qty = (select CASE WHEN sum(DT.qty) is not null THEN sum(DT.qty) ELSE 0 END from DT where DT.num = HT.num); select * from HT;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear