SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table Iden(ide int, order_id int); insert into Iden(ide,order_id) values(1,1),(2,1),(3,3),(4,2),(5,2),(6,2),(7,6); create table Orders(order_id int, quantity int); insert into Orders(order_id,quantity) values(1,100),(1,150),(2,250),(2,250),(2,260),(3,325),(4,444); --select O.order_id, O.quantity from Iden I left outer join Orders O on I.order_id = O.order_id select * from Orders; select distinct on (I.ide) ide , O.order_id, O.quantity from Iden I left join Orders O on I.order_id = O.order_id

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear