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



----- Original Message ----- From: "HauserBirgitta" <Hauser@xxxxxxxxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Thursday, November 02, 2006 10:34 PM
Subject: Re: Can this be done in SQL instead of traditional 'CHAIN'?


With x as (Select ItemNo as xItemNo, Max(MyDate) as xMyDate
            from MyTable
            where branch = ' '
            Group By ItemNo)
Select a.*
  from MyTable a join x on    ItemNo = xItemNo
                           and MyDate = xMyDate;

*****
I am a big fan of the TemporaryTable/CTE. Much better performance than a subselect.

That said, if this is something you will do a lot you can use Interactive SQL to create a permanent view of item, max(date) in your files library. That way your program will not have to wait for the temp table to be built each time it runs.

JD

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.