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



OK you SQL gurus;

I have searched for the last couple of hours, but not finding the solution I
want. I have a file that I want the latest date from, so I am using the
max() to get the latest date. I want to update a 2nd file date field with
the results of the first file. I am wanting to do this all in the query, and
not create actual temporary files.

Am I on the right track with the following code? I am getting and error
"Keyword UPDATE not expected." I'm on V5R4.

I have something like this;

with T1 as
(select Key1, max(datefield) as Max_Date
from filea
where a_code = 'K45'
group by Key1
order by Key1)

update File2
set Date01 = (select max_date from t1
where Key1 = Key2)
where exists(select 1 from t1
where Key1 = Key2)

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.