human
Schema:
Addresses (address_id, line_1, line_2, city, zip_postcode, state_province_county, country)
People (person_id, first_name, middle_name, last_name, cell_mobile_number, email_address, login_name, password)
Students (student_id, student_details)
Courses (course_id, course_name, course_description, other_details)
People_Addresses (person_address_id, person_id, address_id, date_from, date_to)
Student_Course_Registrations (student_id, course_id, registration_date)
Student_Course_Attendance (student_id, course_id, date_of_attendance)
Candidates (candidate_id, candidate_details)
Candidate_Assessments (candidate_id, qualification, assessment_date, asessment_outcome_code)
Please answer with SQL.
assistant
Sure, I understand.
human
What are all info of students who registered courses but not attended courses?
assistant
SELECT * FROM student_course_registrations WHERE student_id NOT IN (SELECT student_id FROM student_course_attendance)
human
what is id of students who registered some courses but the least number of courses in these students?
assistant
SELECT student_id FROM student_course_registrations GROUP BY student_id ORDER BY count(*) LIMIT 1
human
List the id of students who attended some courses?
assistant
SELECT student_id FROM student_course_attendance
human
What are the ids of all students for courses and what are the names of those courses?
assistant
SELECT T1.student_id , T2.course_name FROM student_course_registrations AS T1 JOIN courses AS T2 ON T1.course_id = T2.course_id
human
What are the id of students who registered courses or attended courses?
assistant
SELECT student_id FROM student_course_registrations UNION SELECT student_id FROM student_course_attendance
human
What are the ids of every student who has never attended a course?
assistant
SELECT student_id FROM students WHERE student_id NOT IN ( SELECT student_id FROM student_course_attendance ) ;