I've below SQL join expression and would like to have one more additional calculted field involving two of the tables:
SALESORDERLINES left outer join salesorders on omlsalesorderid = ompsalesorderid Left Outer JOIN (select smlsalesorderid, smlsalesorderlineid, max(smlshipmentid) as shipid FROM shipmentlines group by smlsalesorderid, smlsalesorderlineid) as test on omlsalesorderid = smlsalesorderid and omlsalesorderlineid = smlsalesorderlineid Left Outer JOIN (select ralsalesorderid, ralsalesorderlineid, sum(ralextendedprice) as returnvalue FROM rmaclaimlines group by ralsalesorderid, ralsalesorderlineid) as test1 on omlsalesorderid = ralsalesorderid and omlsalesorderlineid = ralsalesorderlineid left outer join organizations on ompshiporganizationid = cmoorganizationid
calculated value would be:
(Salesorderlines.omlextendedpricebase - test1.returnvalue)
How and where can I add to this query?
Many Thanks in advance.
SALESORDERLINES left outer join salesorders on omlsalesorderid = ompsalesorderid Left Outer JOIN (select smlsalesorderid, smlsalesorderlineid, max(smlshipmentid) as shipid FROM shipmentlines group by smlsalesorderid, smlsalesorderlineid) as test on omlsalesorderid = smlsalesorderid and omlsalesorderlineid = smlsalesorderlineid Left Outer JOIN (select ralsalesorderid, ralsalesorderlineid, sum(ralextendedprice) as returnvalue FROM rmaclaimlines group by ralsalesorderid, ralsalesorderlineid) as test1 on omlsalesorderid = ralsalesorderid and omlsalesorderlineid = ralsalesorderlineid left outer join organizations on ompshiporganizationid = cmoorganizationid
calculated value would be:
(Salesorderlines.omlextendedpricebase - test1.returnvalue)
How and where can I add to this query?
Many Thanks in advance.