SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table Allowance ( id int, Title varchar(24), value int ); insert into Allowance values (1, 'Transport', 2000), (2, 'Housing', 1000), (3, 'Housing', 1000); create table Salaries ( id int, Salary int ); insert into Salaries values (1, 2000), (2, 1000), (3, 3000); select s.id, s.Salary, s.Salary + coalesce(a.value, 0) SalaryAndHousing from Salaries s left join Allowance a on a.id = s.id and a.Title = 'Housing' order by s.id;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear