Modified SQL: added parameterization, dropped cohort_param table, changed DELETE to SELECT.