× 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.



Thanks

ps its not a missing comma - I was changing the field name.


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of DeLong, Eric
Sent: Thursday, November 29, 2012 11:44 AM
To: Midrange Systems Technical Discussion
Subject: RE: change SQL select CTE to insert

Insert into table-name should be fine... Might be a syntax issue...

Insert into qtemp/newtable

with MISCCHGSRC as
(select * from miscchg A
where exists
(select * from miscchgplg b
where a.ASHPNBR = b.ashpnbr
and a.ABLDNGD = b.ABLDNGD
)
union all
select * from miscchgplg
)

select ASHPNBR,ABLDNGD,APLSQNB,AMSCHRG,sum(AMSCHRG2) chgamt,
CTLTEXT1, ChgDesc
from miscchgsrc
left outer join tcmisdb/ctltable
on CTLTABLE = 'MISCCHG' and AMSCHRG = CTLELEMENT
group by ASHPNBR,ABLDNGD,APLSQNB,AMSCHRG,CTLTEXT1


There was a missing comma before ChgDesc...

-Eric DeLong



-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Stone, Joel
Sent: Thursday, November 29, 2012 11:31 AM
To: 'Midrange Systems Technical Discussion'
Subject: change SQL select CTE to insert

I have a complex SELECT stmt that I would like to use to copy (insert) records into another table.

I tried placing "INSERT INTO table-name" in front but that doesn't work.

How can I change this SELECT to insert the result set into a different file?

Thanks





with MISCCHGSRC as (
select * from miscchg A
where exists
(select * from miscchgplg b
where
a.ASHPNBR = b.ashpnbr
and a.ABLDNGD = b.ABLDNGD )
union all
select * from miscchgplg
)
select ASHPNBR,ABLDNGD,APLSQNB,AMSCHRG,sum(AMSCHRG2) chgamt,
CTLTEXT1 ChgDesc
from miscchgsrc
left outer join tcmisdb/ctltable
on CTLTABLE = 'MISCCHG' and AMSCHRG = CTLELEMENT
group by ASHPNBR,ABLDNGD,APLSQNB,AMSCHRG,CTLTEXT1

______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs Skyscan service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

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.