Hi,
Hope someone can help....my SQL is not the best.
Below is my SQL to retrieve information from the Audit history but returns all the entries fro each defect. I am after the last entry only.... I am not sure how to incorporate the MAX function into my query.
SELECT BG_BUG_ID as "DEFECT ID", BG_STATUS AS "STATUS", BG_SUMMARY as "SUMMARY", TO_CHAR(BG_DETECTION_DATE,'dd/mm/yyyy')as "DATE RAISED", BG_SEVERITY as "SEVERITY", BG_PRIORITY as "PRIORITY", AUDIT_PROPERTIES.AP_OLD_VALUE as "OLD Assignee" , AUDIT_PROPERTIES.AP_NEW_VALUE as "NEW Assignee" , TO_CHAR(AUDIT_LOG.AU_TIME,'dd/mm/yyyy')as "DATE CHANGED" , RCYC_NAME as "Location", AL_DESCRIPTION as "Subject", Targets.Target_Cycle as "Assigned to Cycle", BG_RESPONSIBLE as "Assigned To", TRUNC(SYSDATE - BG_DETECTION_DATE) as "DAYS OPEN" FROM BUG inner join AUDIT_LOG on AU_ENTITY_ID = BG_BUG_ID inner join AUDIT_PROPERTIES on AP_ACTION_ID = AU_ACTION_ID INNER JOIN release_cycles on bg_detected_in_rcyc = rcyc_id LEFT OUTER JOIN all_lists on bg_subject = al_item_id LEFT OUTER JOIN (SELECT bg_bug_id as Defect_ID, rcyc_name as Target_Cycle from bug, release_cycles where bg_target_rcyc = rcyc_id ) Targets on Targets.Defect_ID = bg_bug_id where bg_detected_in_rel in (1212) and RCYC_NAME in ('<<<cycle name>>>>','<<<cycle name>>>>') and BG_STATUS <> 'Closed' and AUDIT_LOG.AU_ENTITY_TYPE = 'BUG' and AUDIT_PROPERTIES.AP_FIELD_NAME = 'BG_RESPONSIBLE' order by bg_bug_id,bg_detection_date,AUDIT_LOG.AU_TIME asc
Any help would be grand
Cheers
Justin