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
List the id of students who attended some courses?
assistant
SELECT student_id FROM student_course_attendance
human
what are the first name and last name of all candidates?
assistant
SELECT T2.first_name , T2.last_name FROM candidates AS T1 JOIN people AS T2 ON T1.candidate_id = T2.person_id
human
Find id of the candidate whose email is stanley.monahan@example.org?
assistant
SELECT T2.candidate_id FROM people AS T1 JOIN candidates AS T2 ON T1.person_id = T2.candidate_id WHERE T1.email_address = 'stanley.monahan@example.org'
human
List the first names of people in alphabetical order?
assistant
SELECT first_name FROM people ORDER BY first_name
human
Find distinct cities of address of students?
assistant
SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id JOIN students AS T3 ON T2.person_id = T3.student_id
human
Find distinct cities of addresses of people?
assistant
SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id ;