sql server - Left Join multiple tables on a parent table and subtract one column from the parent table -
i have 3 tables (donor_detail
, items
& store
) left joined on 1 parent table (donated_items
), there column quantity
in parent table wish subtract table's column issued_donation.issued_quantity
here sql left joins not understanding how should subtract column. i.e. donated_items.quantity
- issued_donation.issued_quantity
select t1.*, t2.donor_name,t2.id, t3.id,t3.item_name, t4.store_name, t4.id donated_items t1 left join donor_detail t2 on t1.donor_id = t2.id left join items t3 on t1.item_id = t3.id left join stores t4 on t1.store_id = t4.id
your question isn't clear, suspect you're talking subtracting values, not columns. if i'm right, have join other table (issued_donation
) , can add selected fields t1.quantity - t5.issued_quantity remainingquantity
.
Comments
Post a Comment