I would like to know what should be an SQL statement (for ORACLE DBMS) that will return unique (by CUSTOMER_ID, VEHICLE_ID, DEALER_ID and EVENT_TYPE_ID) rows, but it will also return the last date (EVENT_INITIATED_DATE) for this row, I tried DISTINCT and GROUP BY, but could not figure out how to handle EVENT_INITIATED_DATE (this is a DATE data type).
CUSTOMER_ID VEHICLE_ID DEALER_ID EVENT_TYPE_ID EVENT_INITIATED_DATE
---------------------- ---------------------- ---------- ---------------------- -------------------------
22197630 23093399 6040 20 11-JAN-07
22197630 23093399 6040 5 11-JAN-07
22197630 23093399 6040 4 11-JAN-07
22197630 23093399 6040 3 11-JAN-07
22197630 23093399 6040 4 19-JAN-06
source
share