Oracle SQL - Combine two select statements -
select qi.qtyonhand + qd.delqty teste, qi.itemname qitem qi, qdel qd qi.itemname = qd.itemname , qd.deptname = 'recreation'; select qi.qtyonhand - qs.saleqty teste, qi.itemname qsale qs, qitem qi qi.itemname = qs.itemname , qs.deptname = 'recreation';
i'm trying update qitem
quantity count adding qdel
table's quantity , subtracting qsale
table's quantity. i'm trying put 1 column, there may not items in qdel
table department name of "recreation"
when try put select statements one, leaves out items qitems
.
how this? if not give desired result, can show sample data better explain need?
select qi.qtyonhand + nvl(qd.delqty,0) + nvl(qa.saleqty,0) teste, qi.itemname qitem qi left outer join (select * qdel deptname = 'recreation') qd on qi.itemname = qd.itemname left outer join (select * qsale deptname = 'recreation') qs on qi.itemname = qs.itemname (qd.delqty not null or qs.saleqty not null)
(there may simpler way it, if qitem
has deptname
column.)
Comments
Post a Comment