|
This is query created from SEQUEL.
I think I need a CTE for the following scenario.
we have an order with 3 rows, the first has 'RO' in LCTYPE, the next 2 have
LC. I suspect the RO amt, is getting zero'd by the LC statement. so would
like have a flag here is the prev row had an RO - don't zero out. what is
the way to do this here?
SELECT olsrom, olorno, olline, olprdc, oldesc,
olrqty COLHDG("Qty Rec") LEN(11,0), WDATA(lctype),
SUM(olamou/olrqty) LEN(11,2) NAME(unit) COLHDG("Unit Price"),
CASE WHEN lctype='RO' THEN ROUND(SUM(totalland/olrqty),2) ELSE 0
END NAME(roytotal) COLHDG("Royalties") LEN(11,2),
CASE WHEN lctype='LC' THEN ROUND(SUM(totalland/olrqty),2) ELSE 0
END NAME(lctotal) COLHDG("Add-on Cost") LEN(11,2),
(roytotal+lctotal+unit) COLHDG("Landed Cost") NAME(totallc)
LEN(11,2)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.