|
I don't think that you can do it in interactive SQL (I tried "strsql" and "wrkqry") but you can do it in a "cursor" as follows: C/EXEC SQL DECLARE TOP10 CURSOR FOR C+ SELECT DISTINCT THID FROM QQTEST C+ WHERE WHATEVER = :HostVar C+ ORDER BY THID DESC C+ FETCH FIRST 10 ROWS ONLY C/END-EXEC C* and then in your process loop C/EXEC SQL C+ FETCH TOP10 INTO C+ :HostTHID C/END-EXEC Or conversely use a counter in your loop to stop at 10 HTH Gord Royle Cott Corporation -----Original Message----- From: Dennis Munro [mailto:DMunro@badgerminingcorp.com] Sent: Wednesday, September 26, 2001 6:13 PM To: Midrange List (E-mail) Subject: SQL Question I've got an Access database that uses the following statement & I am wondering if there is a way to do the same with SQL from the AS/400. Running V4R5M0 & one cum back. "Select Top 10 QQTEST.THID From QQTEST" with a Where & Order By clause. Thanks - Dennis. Dennis Munro "I love deadlines. I especially like the whooshing sound they make as they go flying by." Dilbert's Words Of Wisdom: Badger Mining Corporation www.badgerminingcorp.com dmunro@badgerminingcorp.com (920) 361-2388 _______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l or email: MIDRANGE-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l. Cott - The Leader in Premium Retailer Brand Beverage Innovation.
As an Amazon Associate we earn from qualifying purchases.
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.