SQL最新的变化

时间:2017-06-19 02:06:17

标签: sql

我需要对FIELD_NAME col进行最新更改。例如下面,在col key_2,3332P6下; Field_Name'提交',在我的提取日期内被修改了3次。虽然没有重复,但我只需要最新的修改,即UNIQUE_RID 47271398。这可能吗?

enter image description here

select Key_2,
       LEFT (REPLACE(KEY_2, '&', ''), 4) PROJECT_CODE,
       (CASE WHEN LEN(REPLACE(KEY_2, '&', ''))  >4 THEN RIGHT(REPLACE(KEY_2, '&', ''), 2)    ELSE ''
        END as PROJECT_PHASE,

        FIELD_NAME, AUDIT_OLD_VALUE, AUDIT_NEW_VALUE,
        UNIQUE_RID, AUDIT_DATE, AUDIT_TIME

 FROM TBADT_AUDIT_TRAIL 
 WHERE Key_1 like 'WKSCHART' AND
       Audit_Date between '2017-06-13' and '2017-06-16'
 ORDER BY Key_2, FIELD_NAME

我知道它在VBA中有效,但我对SQL很新。感谢您的帮助。

0 个答案:

没有答案