human
Schema:
Course_Authors_and_Tutors (author_id, author_tutor_ATB, login_name, password, personal_name, middle_name, family_name, gender_mf, address_line_1)
Students (student_id, date_of_registration, date_of_latest_logon, login_name, password, personal_name, middle_name, family_name)
Subjects (subject_id, subject_name)
Courses (course_id, author_id, subject_id, course_name, course_description)
Student_Course_Enrolment (registration_id, student_id, course_id, date_of_enrolment, date_of_completion)
Student_Tests_Taken (registration_id, date_test_taken, test_result)
Please answer with SQL.
assistant
Sure, I understand.
human
How many failed the exam?
assistant
SELECT COUNT( * ) FROM Student_Tests_Taken WHERE test_result = 'Fail';
human
And what about passed?
assistant
SELECT COUNT( * ) FROM Student_Tests_Taken WHERE test_result = 'Pass';
human
Can you list each test result and it's count in descending order based on count?
assistant
SELECT test_result , COUNT( * ) FROM Student_Tests_Taken GROUP BY test_result ORDER BY COUNT( * ) DESC;
human
Yes, what are ids of all passed exams?
assistant
SELECT registration_id FROM Student_Tests_Taken WHERE test_result = "Pass" ;