|
I think you have to somewhat join or relate FILE1 to FILE2 with the second select statement. e.g Select acctno1 from FILE1 where acctno in(select distinct(acctno2) from FILE2 where acctno1=acctno2 and fldz<20000000 order by fldz Desc) Hope this help. ----- Original Message ----- From: <Gade_R_Reddy@consecofinance.com> To: <RPG400-L@midrange.com> Sent: Wednesday, December 15, 1999 3:41 PM Subject: Re: Sql Question > > Thanks for the Sql statement but your sql statement would get me multiple > records of the same acctno number. I don't need that. > > I am thinking more like this. > > select acctno from file1 where acctno in (select distinct(acctno) from > file2 where FldZ < 20000000 order by FldZ Desc) > > The problem is i cannot give a order by in this sql statement. > > Please let me know how can i go for it. > > Thanks. > Gade. > > > > > > > Rob Berendt <rob@dekko.com>@midrange.com on 12/15/99 01:59:33 PM > > Please respond to RPG400-L@midrange.com > > Sent by: owner-rpg400-l@midrange.com > > > To: RPG400-L@midrange.com > cc: > Subject: Re: Sql Question > > > select acctno,fldz from file 2 where acctno in(select acctno from file1) > and fldz<2000000But I was assuming that you didn't mean "if no record in file2 has FldZ > value > 20000000" since you did have a sample retrived row. I assumed you > meant that > "if the record in file2 has FldZ value > 20000000" > > > > > Gade_R_Reddy@consecofinance.com on 12/15/99 02:41:18 PM > Please respond to RPG400-L@midrange.com@Internet > To: RPG400-L@midrange.com@Internet > cc: > Fax to: > Subject: Sql Question > > > Hey Guys, > > I got a question in SQL which i want to run from my RPGLE program. > > I have two files.. > > File1 > Acctno Fld1 Fld2 Fld3 > 123 a a a > 456 b b b > > File2 > Acctno FldX FldY FldZ > 123 a1 b1 19991011 > 123 a1 b1 19991105 > 123 a1 b1 20020106 > 456 a2 b2 19991001 > 456 a2 b2 19991231 > > > Now i want to write a Sql which does the following.. > > - Want to print all the Acctno & FldZ where Acctno matches in both the > files and only if no record in file2 has FldZ value > 20000000 > > So if i run the sql statement with the above data i want the output to be > > AcctNo FldZ > 456 19991231 ( because the two records has FldZ value < 20000000 but > in acctno 123 we have one record whose FldZ value > 20000000 ) > > > Any suggestions please. > > Gade. > > > > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: > david@midrange.com > +--- > > > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: > david@midrange.com > +--- > > > > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: david@midrange.com > +--- +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.