status='EAVIS' and ((DEST_USER = @user) OR (DEST_USER IN (select user_id from users_entities WHERE entity_id = @my_primary_entity) or DESTINATION in (@subentities[@my_primary_entity]))) and res_id IN (SELECT res_id FROM listinstance WHERE item_mode = 'avis' and difflist_type = 'entity_id' and process_date is not NULL and res_view_letterbox.res_id = res_id group by res_id)