select distinct b.name from custom_tests_results a join students b on a.student_id = b.student_id join group_custom_tests c on a.custom_test_id = c.id where c.group_id = 69 and c.format = 'Пробные тесты ЕНТ' and a.subject_id = 1 GROUP BY a.test_date, a.id, b.student_id, c.id select distinct a.test_date from custom_tests_results a join students b on a.student_id = b.student_id join group_custom_tests c on a.custom_test_id = c.id where c.group_id = 69 and c.format = 'Пробные тесты ЕНТ' and a.subject_id = 1 GROUP BY a.test_date, a.id, b.student_id, c.id