sql - Comparing two dates and avoiding duplication -
i working on hp alm try perform query :
select one.id, one.num_qc_edf, one.statut, two.proprietaire, one.changedate (select b.bg_bug_id id, b.bg_user_15 num_qc_edf, ap.ap_new_value statut, bg_responsible proprietaire, al.au_time changedate 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 , al.au_entity_type = 'bug' , al.au_action_id= ap.ap_action_id , ap_field_name= 'bg_status')one, (select b.bg_bug_id id,b.bg_user_15 num_qc_edf, ap.ap_new_value proprietaire , bg_status statut , al.au_time changedate 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 , al.au_entity_type = 'bug' , al.au_action_id= ap.ap_action_id , ap.ap_field_name = 'bg_responsible' , b.bg_status = 'tu leger ok')two, bug b one.id= two.id , one.num_qc_edf= two.num_qc_edf , one.statut= two.statut , one.proprietaire= two.proprietaire , two.changedate <= one.changedate order bg_bug_id, num_qc_edf, proprietaire, changedate
i compare changedate situated in second sub query 1 in first sub query must <= ,also whole query must'nt return duplicated rows in result of (ps: distinct doesn't work in nested queries)
i asking help.
firstly, added bug b
doesnt join other 2 sub-query tables one
, two
. so, hell lot of duplicates.
without knowing table structure, not possible alter query.
in case, dont want change query , still want unique records, can following:
select distinct aa.* (*your entire query*) aa;
above solution not recomended, need join bug b
other 2 tables.
Comments
Post a Comment