Row with latest value by customer and month [duplicate]
问题 This question already has answers here : Fetch a record on maximum date of every month (3 answers) Closed last month . I have a table that keeps track of changes in customer profiles. Here's a simplified version: CREATE TABLE HISTORY ( CUSTOMER_ID NUMBER(9,0), DATE_CHANGED DATE, ACCOUNT_TYPE VARCHAR2(20), CONSTRAINT HISTORY_PK PRIMARY KEY (CUSTOMER_ID, DATE_CHANGED) ); INSERT INTO HISTORY (CUSTOMER_ID, DATE_CHANGED, ACCOUNT_TYPE) VALUES (200, TO_DATE('05/01/2013 00:00:00','DD/MM/RRRR HH24:MI