|
Why would you have a sub-select in the from clause of the final select
statement?
Why not simply using a second CTE?
Something like this:
with list as (select line, ndcupc, gppc
from tempsav.cmw
left outer join medispan.mf2ndc on ndc = ndcupc ),
LowPrc as (select ndcupc, idescr,
olsmlprg.calccustacqcost(decimal(150,6,0), iitnbr) as acq_cost, gppc
from medispan.mlitems M
left outer join olsdta.ioritemmst using (iitnbr)
where gppc = m.gppc
order by 3
fetch first row only)
select * from list L
left outer join lowprc
on L.gppc = lowprc.gppc
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von
Charles Wilt
Gesendet: Thursday, 16.7 2015 19:41
An: Midrange Systems Technical Discussion
Betreff: Correlated Subqueries in the FROM clause
Can I have a correlated subquery in the FROM clause for DB2 for i?
This doesn't seem to be working...
with list as (select line, ndcupc, gppc
from tempsav.cmw
left outer join medispan.mf2ndc on ndc = ndcupc )
select * from list L
left outer join (select ndcupc, idescr
, olsmlprg.calccustacqcost(decimal(150,6,0),
iitnbr) as acq_cost
, gppc
from medispan.mlitems M
left outer join
olsdta.ioritemmst using (iitnbr)
where gppc = m.gppc
order by 3
fetch first row only) as lowprc
on L.gppc = lowprc.gppc
;
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe,
or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
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.