select distinct $id_column from $main_table_name where [join $date_clause_list "\nand "] select distinct $id_column from $main_table_name where [join $date_clause_list "\nand "]