SELECT e.entity_ref, d.department_ref, pg.product_group_ref, l.transaction_ref, c2.cpty_ref, c3.country_ref, f.status, f.facility_ref, f.action_status, f.start_date, f.expiry_date, f.facility_id, f.initial_facility_id, f.parent_facility_id, lh.*, l.* FROM limit_history lh WITH(NOLOCK) left join [limit] l on l.limit_id = lh.limit_id left join facility f on f.facility_id = l.facility_id left join cpty c2 on c2.cpty_id=f.cpty_id left join country c3 on c3.country_id = f.country_id left join entity e on e.entity_id = l.entity_id left join department d on d.department_id = l.department_id left join product_group pg on pg.product_group_id=l.product_group_id left join product p on p.product_id=l.product_id left join currency c on c.currency_id=l.currency_id WHERE c2.cpty_ref in ('ICBKCN-ICBC-BAN','TCMBTR-CBTR-GRP') or c3.country_ref in ('CH','TR') ORDER BY f.facility_ref, l.limit_id