Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select *
- from
- (
- select
- c.concept_code,
- c.concept_name,
- coalesce (c1.concept_code, c2.concept_code) as target_code,
- coalesce (c1.concept_name, c2.concept_name) as target_name
- from concept_stage c
- join concept_relationship_stage r on
- c.concept_class_id = 'Drug Product' and
- r.relationship_id = 'Maps to' and
- c.concept_code = r.concept_code_1
- left join concept c1 on
- c1.concept_code = r.concept_code_2 and
- c1.vocabulary_id = r.vocabulary_id_2
- left join concept_stage c2 on
- c2.concept_code = r.concept_code_2 and
- c2.vocabulary_id = r.vocabulary_id_2
- ) new
- join
- (
- select
- c.concept_code,
- c.concept_name,
- coalesce (c1.concept_code, c2.concept_code) as target_code,
- coalesce (c1.concept_name, c2.concept_name) as target_name
- from concept_stage_old c
- join concept_relationship_stage_old r on
- c.concept_class_id = 'Drug Product' and
- r.relationship_id = 'Maps to' and
- c.concept_code = r.concept_code_1
- left join concept c1 on
- c1.concept_code = r.concept_code_2 and
- c1.vocabulary_id = r.vocabulary_id_2
- left join concept_stage_old c2 on
- c2.concept_code = r.concept_code_2 and
- c2.vocabulary_id = r.vocabulary_id_2
- ) old
- on
- new.concept_code = old.concept_code and
- new.target_name != old.target_name
Advertisement
Add Comment
Please, Sign In to add comment