take only one record of select

Posted by jack.cap.rooney on Stack Overflow See other posts from Stack Overflow or by jack.cap.rooney
Published on 2012-03-21T15:39:15Z Indexed on 2012/03/21 17:29 UTC
Read the original article Hit count: 184

Filed under:
|
|

I need to fetch only first record (because I need last date) of resultset, at the moment I have this resultset from this sql tring:

SELECT BCACC,FLDAT
FROM ANAGEFLF
ORDER BY FLDAT DESC

and I see this record:

A.M.T. AUTOTRASPORTI SRL        20080220
A.M.T. AUTOTRASPORTI SRL        20080123
A.M.T. AUTOTRASPORTI SRL        20070731
APOFRUIT ITALIA                 20080414
APOFRUIT ITALIA                 20080205
APOFRUIT ITALIA                 20071210
APOFRUIT ITALIA                 20070917
APOFRUIT ITALIA                 20070907

now I need to take only one record (first) for every BCACC, I would take this resultset:

A.M.T. AUTOTRASPORTI SRL        20080220
APOFRUIT ITALIA                 20080414

I've just try group it for BCACC but I receive an sql error, I'm workin on DB2 ibmI

© Stack Overflow or respective owner

Related posts about sql

Related posts about db2