I want to merge two queries in order to get informations of sub tab 'Audit Log' situated under 'History' tab in Defect module. This query must return the requested columns following those restrictions : * The BG_RESPONSIBILITY returned must be the new value affected after change .
* The BG_STATUS must show the old and new value of each change.
I performed this query but it doesn't return the suggested result of the BG_RESPONSIBLE column . I doubt that the sub query under AP_FIELD_NAME column doesn't fit . Any help for me please.
this is my query:
SELECT B.BG_BUG_ID as ID ,BG_USER_15 as Num_QC_EDF, BG_RESPONSIBLE as Proprietaire, BG_STATUS as Statut, BG_PRIORITY as Priorite, BG_SEVERITY as Severite, BG_DETECTION_DATE as Date_Soumission, AP.AP_OLD_VALUE as OLD_STATUS , AP.AP_NEW_VALUE AS NEW_STATUS, AL.AU_TIME as ChangeDate, AU_TIME - BG_DETECTION_DATE as NumberOfDays FROM BUG B
INNER JOIN AUDIT_LOG AL
ON AL.AU_ENTITY_ID = B.BG_BUG_ID
INNER JOIN AUDIT_PROPERTIES AP
ON AL.AU_ACTION_ID = AP.AP_ACTION_ID
AND AL.AU_ENTITY_TYPE = 'BUG'
AND AL.AU_ACTION_ID= AP.AP_ACTION_ID
AND AP_FIELD_NAME IN ('BG_STATUS', '"BG_RESPONSIBLE" = "SELECT AP_NEW_VALUE as Proprieratire FROM BUG B INNER JOIN AUDIT_LOG AL ON AL.AU_ENTITY_ID = B.BG_BUG_ID INNER JOIN AUDIT_PROPERTIES AP ON AL.AU_ACTION_ID = AP.AP_ACTION_ID AND AL.AU_ENTITY_TYPE = "BUG" AND AL.AU_ACTION_ID = AP.AP_ACTION_ID AND AP_FIELD_NAME ="BG_RESPONSIBLE" ORDER BY BG_BUG_ID, AU_TIME DESC" ')
AND BG_STATUS NOT IN('Annulé', 'Clôturé', 'Livré')
ORDER BY BG_BUG_ID, AU_TIME DESC