   cvt.effective_end_date
   cm.enterprise_id
 from
-  argusmart.rm_case_master as cm,
-  argusmart.case_version_table as cvt
+  rm_case_master as cm,
+  case_version_table as cvt
 where
   (cvt.case_id = cm.case_id) and
   (cvt.effective_start_date >= convert(cm.effective_start_date,timestamp)) and

  b.effective_end_date,
  a.enterprise_id
from
  argusmart.rm_case_assess as a,
  argusmart.case_version_table as b
where
  (a.case_id = b.case_id) and
  (a.enterprise_id = b.enterprise_id) and
  (a.deleted_flag = convert(0,bigdecimal)) and
  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
  (convert(a.effective_end_date,timestamp) > b.effective_start_date)

--------------------

select
  a.enterprise_id,
  a.enterprise_id,

  a.first_dose_partial
  a.last_dose_partial
from
  rm_case_prod_drugs as a,
  case_version_table as b
where
  (a.case_id = b.case_id) and
  (a.enterprise_id = b.enterprise_id) and
