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



Bill,

Adding "as" to denote the derived field name yields the same results:
prod/tran not found in specified tables. Elvis Budimlic suggested
removing the AS qualifier. My original queries used them.

Again, the problem is not using a CTE itself, as I can select * from the
CTE. The problem is using derived columns in the CTE and referencing
them in the final select statement.

Thanks for the suggestion though.

Loyd

Loyd Goodbar
Senior programmer/analyst
BorgWarner
TS Water Valley
662-473-5713
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Bill
Sent: Monday, March 19, 2007 18:28
To: midrange-l@xxxxxxxxxxxx
Subject: Re: iSeries and Microsoft Query (Excel)

Lloyd,

I use MSQuery all the time and have used derived tables a number of
times.

lgoodbar@xxxxxxxxxxxxxx wrote:
Sorry about PRODO. Following your suggestion, starting with:

with temp as
(select nxkjdt, nxjpt2, sum(NXS7FQ) tran
from VNGDBDTA.DBNXCPP
where nxkjdt between 1070301 and 1070307
group by nxkjdt, nxjpt2),
temp2 as
(select dmatdt, dmekcd, sum(dmgzfq) prod
from VNGDBDTA.DBDMREP
where dmqwtx = 'SFR' and dmcdcd = ';MRCT' and
dmatdt between 1070301 and 1070307
group by dmatdt, dmekcd
)
select dmatdt, dmekcd, prod, tran
from temp2
left outer join temp on dmatdt = nxkjdt and dmekcd = nxjpt2
order by 1,2

I think the answer is the same for all of your examples:

Change this line:
select nxkjdt, nxjpt2, sum(NXS7FQ) tran
        to
select nxkjdt, nxjpt2, sum(NXS7FQ) as tran

and you should be fine.

Bill 




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.