Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
BryanRodrigues
Starting Member
1 Post |
Posted - 2008-09-09 : 15:23:07
|
Hi,having a problem selecting data from an AS400 DB.I basically need to collect Quantity (F01.PRUORG), Product(F01.PRLITM), GLDate (F01.PRDGL) and SupplierID (F01.PRAN8) for the most recent receivable transaction that occered.The query below gives all transaction data, where i only want the data from the last transtaction. Select F01.PRDCTO,F01.PRLITM,MAX(F01.PRDGL) AS GLDATE, F01.PRUORG, F01.PRAN8From F43121 F01,F4101 F02 Where(F01.PRLITM=F02.IMLITM) And (F01.PRDCT='OV' And F01.PRDCTO='OP' And F02.IMPRP4='800')Group By F01.PRDCTO, PRLITM, PRUORG, PRAN8Examaple of a single product transactions.PRDCTO PRLITM GLDATE PRUORG PRAN8OP 0000000001 11/22/2002 10 5895OP 0000000001 3/30/2007 20 5895OP 0000000001 6/12/2008 25 5895 *need values from this rowOP 0000000001 4/30/2008 30 5895 OP 0000000001 9/11/1982 6 5895OP 0000000001 5/30/2001 14 5895OP 0000000001 8/4/2000 50 5895ThanksBryan |
|
|
|
|