× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



To use your example, modified;
With

item_received as
( SELECT DISTINCT PRICDE, PRSIZE FROM pmdbfa.pmppr WHERE PRHREC >= 39294
),

results as
( select distinct synonm,synref,synrf2,mndesc,plus.* from item_received,
cadbfa.synonym hcpc,cadbfa.manfilpf prod,mmcust120.pluscharge plus where
syndsc = 'HCPC' and (item_received.pricde = hcpc.synref and
item_received.prsize = hcpc.synrf2) and (item_received.pricde =
prod.mnmfg#and item_received.prsize =
prod.mnsize) and (synonm = plus.proc_code)
)

Select * from results, another_table where ......


The first CTE creates the table Item_Received. The 2nd CDT uses that table
and others to create table Results. The query uses Results and
another_table for the final result.

HTH

Jim
On Tue, Mar 25, 2008 at 4:55 PM, Hatzenbeler, Tim <
thatzenbeler@xxxxxxxxxxxxx> wrote:

Is there a way to do a with within a with?

Ie:

// this works..
with item_received as
( SELECT DISTINCT PRICDE, PRSIZE FROM pmdbfa.pmppr WHERE PRHREC >=
39294 )
select distinct synonm,synref,synrf2,mndesc,plus.* from
item_received, cadbfa.synonym hcpc,cadbfa.manfilpf prod,
mmcust120.pluscharge plus where syndsc = 'HCPC' and (item_received.pricde
= hcpc.synref and item_received.prsize = hcpc.synrf2) and
(item_received.pricde = prod.mnmfg# and item_received.prsize = prod.mnsize)
and (synonm = plus.proc_code)



// but I would like to use the results of this query to do another
select/join from it, without creating a view or temp table.

With results as (

with item_received as
( SELECT DISTINCT PRICDE, PRSIZE FROM pmdbfa.pmppr WHERE PRHREC >= 39294
)
select distinct synonm,synref,synrf2,mndesc,plus.* from item_received,
cadbfa.synonym hcpc,cadbfa.manfilpf prod,mmcust120.pluscharge plus where
syndsc = 'HCPC' and (item_received.pricde = hcpc.synref and
item_received.prsize = hcpc.synrf2) and (item_received.pricde =
prod.mnmfg# and item_received.prsize = prod.mnsize) and (synonm =
plus.proc_code)

)

Select * from results, another_table where ......



------------------------------------------------------------------------------
This e-mail message, including any attachments, is for the
sole use of the intended recipient(s) and may contain
confidential or privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If
you are not the intended recipient, please contact the
sender by reply e-mail and destroy the message.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.