I have a table such as following
RevNo RevContent PIC Created
----- --------------- ------- ----------
00 Testing Purpose Smith 2008-01-11
01 Testing Purpose Windsor 2008-02-01
02 Test Thorn 2008-01-05
02 Testing Baker 2008-03-01
03 Testing only Sykes 2008-01-20
I want the output like below, it display the latest date for each rev no. and other details
RevNo RevContent PIC Created
----- --------------- ------- ----------
00 Testing Purpose Windsor 2008-02-01
01 Testing Baker 2008-03-01
02 Testing only Sykes 2008-01-20
But when I run the sql, it display the value with the latest date only like below, I want it display the latest date for each rev no. and it based on department(session).
RevNo RevContent PIC Created
----- ---------- ----- ----------
01 Testing Baker 2008-03-01
What I have tried:
SELECT CCSMASTERLISTREVNO, CCSREVCONTENT, CCSPREPAREDREV, CCSREVEFFECTIVEDATE
FROM CCS2_TBL_MASTERLIST a
WHERE CCSEQUIPMENTDPMT = :DPMT
AND CCSREVEFFECTIVEDATE = (SELECT MAX(CCSREVEFFECTIVEDATE) FROM CCS2_TBL_MASTERLIST GROUP BY CCSMASTERLISTREVNO HAVING CCSMASTERLISTREVNO =a.CCSMASTERLISTREVNO)
ORDER BY CCSMASTERLISTREVNO DESC;