updated some queries in flat_cohort_table