   join relationship_to_concept m on m.concept_code_1=r.concept_code_2 -- left join if not 
 ) q_df on q_df.concept_code_1=m.q_dcode 
 left join (
-  select r.concept_id_1, r.concept_id_2 from devv5.concept_relationship r
-  join devv5.concept on concept_id=r.concept_id_2 and concept_class_id ='Dose Form' -- Dose Form of r
+  select r.concept_id_1, r.concept_id_2 from concept_relationship r
+  join concept on concept_id=r.concept_id_2 and concept_class_id ='Dose Form' -- Dose Form of r
   where r.invalid_reason is null and r.relationship_id='RxNorm has dose form'
 ) r_df on r_df.concept_id_1=m.r_did
 -- get Brand Name for q and r

    r_ds.numerator_value, r_ds.numerator_unit_concept_id,
    nvl(r_ds.denominator_value, 1) as denominator_value, -- Quantified have a value in the denominator, the others haven't.
    r_ds.denominator_unit_concept_id
  from devv5.drug_strength r_ds 
)
-- Create variables div as r amount / q amount, and unit as 1 for matching and 0 as non-matching 
select 

select r_did, q_dcode, count(*) as cnt from match group by r_did, q_dcode
;
-- Set all counts for Clinical Drug Comp to null, so in comparisons it can match whatever number necessary. Reason is that, like ingredients, Clinical Drug Comp is always only one ingredient
update shared_ing set cnt=null where r_did in (select concept_id from concept where concept_class_id in ('Clinical Drug Comp', 'Ingredient'));

-- Create table that matches drugs q to r, based on Ingredient, Dose Form and Brand Name (if exist). Dose, box size or quantity are not yet compared
create table q_to_r_anydose nologging as
