条件是A,B两表,A中有ID,同一ID有两值,以它更新时间为区别,现在要取的是最新的ID那个值,并且关联到B中的一属性。SQL不太好,留在这里以后继续学习
SELECT Distinct tab1.CUSTOMER_ID, ACV.LAST_NAME,tab1.maxla
FROM AR_CONTACTS_V ACV,
(SELECT RC.CUSTOMER_ID CUSTOMER_ID, MAX(ACV.LAST_UPDATE_DATE) MAXLA
FROM AR_CONTACTS_V ACV, RA_CUSTOMERS RC
WHERE ACV.CUSTOMER_ID(+) = RC.CUSTOMER_ID
GROUP BY RC.CUSTOMER_ID) TAB1
WHERE ACV.CUSTOMER_ID(+) = TAB1.CUSTOMER_ID
AND ACV.LAST_UPDATE_DATE(+) = TAB1.MAXLA