Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the completion dates of all the tests that have result "Fail"? [/INST]

Output: SELECT T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id  =  T2.registration_id WHERE T2.test_result  =  "Fail";


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Return the completion date for all the tests that have "Fail" result. [/INST]

Output: SELECT T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id  =  T2.registration_id WHERE T2.test_result  =  "Fail";


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: List the dates of enrollment and completion of the student with personal name "Karson". [/INST]

Output: SELECT T1.date_of_enrolment ,  T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id WHERE T2.personal_name  =  "Karson";


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: On what dates did the student whose personal name is "Karson" enroll in and complete the courses? [/INST]

Output: SELECT T1.date_of_enrolment ,  T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id WHERE T2.personal_name  =  "Karson";


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: List the dates of enrollment and completion of the student with family name "Zieme" and personal name "Bernie". [/INST]

Output: SELECT T1.date_of_enrolment ,  T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id WHERE T2.family_name  =  "Zieme" AND T2.personal_name  =  "Bernie";


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: On what dates did the student with family name "Zieme" and personal name "Bernie" enroll in and complete the courses? [/INST]

Output: SELECT T1.date_of_enrolment ,  T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id WHERE T2.family_name  =  "Zieme" AND T2.personal_name  =  "Bernie";


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Find the student ID and login name of the student with the most course enrollments [/INST]

Output: SELECT T1.student_id ,  T2.login_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the student ID and login name of the student who are enrolled in the most courses? [/INST]

Output: SELECT T1.student_id ,  T2.login_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Find the student ID and personal name of the student with at least two enrollments. [/INST]

Output: SELECT T1.student_id ,  T2.personal_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING COUNT(*)  >=  2;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Which student are enrolled in at least two courses? Give me the student ID and personal name. [/INST]

Output: SELECT T1.student_id ,  T2.personal_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING COUNT(*)  >=  2;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Find the student ID and middle name for all the students with at most two enrollments. [/INST]

Output: SELECT T1.student_id ,  T2.middle_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING COUNT(*)  <=  2;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the student IDs and middle names of the students enrolled in at most two courses? [/INST]

Output: SELECT T1.student_id ,  T2.middle_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id HAVING COUNT(*)  <=  2;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Find the personal names of students not enrolled in any course. [/INST]

Output: SELECT personal_name FROM Students EXCEPT SELECT T1.personal_name FROM Students AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.student_id  =  T2.student_id;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Which students not enrolled in any course? Find their personal names. [/INST]

Output: SELECT personal_name FROM Students EXCEPT SELECT T1.personal_name FROM Students AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.student_id  =  T2.student_id;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: How many students did not have any course enrollment? [/INST]

Output: SELECT count(*) FROM Students WHERE student_id NOT IN (SELECT student_id FROM Student_Course_Enrolment);


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of students who did not enroll in any course. [/INST]

Output: SELECT count(*) FROM Students WHERE student_id NOT IN (SELECT student_id FROM Student_Course_Enrolment);


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Find the common login name of course authors and students. [/INST]

Output: SELECT login_name FROM Course_Authors_and_Tutors INTERSECT SELECT login_name FROM Students;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the login names used both by some course authors and some students? [/INST]

Output: SELECT login_name FROM Course_Authors_and_Tutors INTERSECT SELECT login_name FROM Students;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: Find the common personal name of course authors and students. [/INST]

Output: SELECT personal_name FROM Course_Authors_and_Tutors INTERSECT SELECT personal_name FROM Students;


Input:
[INST] Here is a database schema:
Course_Authors_and_Tutors :
author_id [ INT ] primary_key
author_tutor_ATB [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]
gender_mf [ TEXT ]
address_line_1 [ TEXT ]

Students :
student_id [ INT ] primary_key
date_of_registration [ TEXT ]
date_of_latest_logon [ TEXT ]
login_name [ TEXT ]
password [ TEXT ]
personal_name [ TEXT ]
middle_name [ TEXT ]
family_name [ TEXT ]

Subjects :
subject_id [ INT ] primary_key
subject_name [ TEXT ]

Courses :
course_id [ INT ] primary_key
author_id [ INT ] Courses.author_id = Course_Authors_and_Tutors.author_id
subject_id [ INT ] Courses.subject_id = Subjects.subject_id
course_name [ TEXT ]
course_description [ TEXT ]

Student_Course_Enrolment :
registration_id [ INT ] primary_key
student_id [ INT ] Student_Course_Enrolment.student_id = Students.student_id
course_id [ INT ] Student_Course_Enrolment.course_id = Courses.course_id
date_of_enrolment [ TEXT ]
date_of_completion [ TEXT ]

Student_Tests_Taken :
registration_id [ INT ] Student_Tests_Taken.registration_id = Student_Course_Enrolment.registration_id
date_test_taken [ TEXT ]
test_result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the personal names used both by some course authors and some students? [/INST]

Output: SELECT personal_name FROM Course_Authors_and_Tutors INTERSECT SELECT personal_name FROM Students;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which claims caused more than 2 settlements or have the maximum claim value? List the date the claim was made and the claim id. [/INST]

Output: SELECT T1.Date_Claim_Made ,  T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id GROUP BY T1.Claim_id HAVING count(*)  >  2 UNION SELECT T1.Date_Claim_Made ,  T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id WHERE T1.Amount_Claimed  =  ( SELECT max(Amount_Claimed) FROM Claims );


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the claims that led to more than two settlements or have the maximum claim value. For each of them, return the date the claim was made and the id of the claim. [/INST]

Output: SELECT T1.Date_Claim_Made ,  T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id GROUP BY T1.Claim_id HAVING count(*)  >  2 UNION SELECT T1.Date_Claim_Made ,  T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id WHERE T1.Amount_Claimed  =  ( SELECT max(Amount_Claimed) FROM Claims );


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which customer had at least 2 policies but did not file any claims? List the customer details and id. [/INST]

Output: SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.customer_id GROUP BY T1.customer_id HAVING count(*)  >=  2 EXCEPT SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.customer_id JOIN Claims AS T3 ON T2.policy_id  =  T3.policy_id;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Give me the the customer details and id for the customers who had two or more policies but did not file any claims. [/INST]

Output: SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.customer_id GROUP BY T1.customer_id HAVING count(*)  >=  2 EXCEPT SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.customer_id JOIN Claims AS T3 ON T2.policy_id  =  T3.policy_id;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: List the method, date and amount of all the payments, in ascending order of date. [/INST]

Output: SELECT Payment_Method_Code ,  Date_Payment_Made ,  Amount_Payment FROM Payments ORDER BY Date_Payment_Made ASC;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What are the method, date and amount of each payment? Sort the list in ascending order of date. [/INST]

Output: SELECT Payment_Method_Code ,  Date_Payment_Made ,  Amount_Payment FROM Payments ORDER BY Date_Payment_Made ASC;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Among all the claims, what is the settlement amount of the claim with the largest claim amount? List both the settlement amount and claim amount. [/INST]

Output: SELECT Amount_Settled ,  Amount_Claimed FROM Claims ORDER BY Amount_Claimed DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the settlement amount of the claim with the largest claim amount. Show both the settlement amount and claim amount. [/INST]

Output: SELECT Amount_Settled ,  Amount_Claimed FROM Claims ORDER BY Amount_Claimed DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Among all the claims, what is the amount claimed in the claim with the least amount settled? List both the settlement amount and claim amount. [/INST]

Output: SELECT Amount_Settled ,  Amount_Claimed FROM Claims ORDER BY Amount_Settled ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the claimed amount in the claim with the least amount settled. Show both the settlement amount and claim amount. [/INST]

Output: SELECT Amount_Settled ,  Amount_Claimed FROM Claims ORDER BY Amount_Settled ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Among all the claims, which claims have a claimed amount larger than the average? List the date the claim was made and the date it was settled. [/INST]

Output: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Claims WHERE Amount_Claimed  >  ( SELECT avg(Amount_Claimed) FROM Claims );


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Give me the claim date, settlement date for all the claims whose claimed amount is larger than the average. [/INST]

Output: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Claims WHERE Amount_Claimed  >  ( SELECT avg(Amount_Claimed) FROM Claims );


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Among all the claims, which settlements have a claimed amount that is no more than the average? List the claim start date. [/INST]

Output: SELECT Date_Claim_Made FROM Claims WHERE Amount_Settled  <=  ( SELECT avg(Amount_Settled) FROM Claims );


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Return the claim start date for the claims whose claimed amount is no more than the average [/INST]

Output: SELECT Date_Claim_Made FROM Claims WHERE Amount_Settled  <=  ( SELECT avg(Amount_Settled) FROM Claims );


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: How many settlements does each claim correspond to? List the claim id and the number of settlements. [/INST]

Output: SELECT T1.Claim_id ,  count(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id  =  T2.claim_id GROUP BY T1.claim_id;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the number of settlements each claim corresponds to. Show the number together with the claim id. [/INST]

Output: SELECT T1.Claim_id ,  count(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id  =  T2.claim_id GROUP BY T1.claim_id;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which claim incurred the most number of settlements? List the claim id, the date the claim was made, and the number. [/INST]

Output: SELECT T1.claim_id ,  T1.date_claim_made ,  count(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id  =  T2.claim_id GROUP BY T1.claim_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the claim id and claim date of the claim that incurred the most settlement count. Also tell me the count. [/INST]

Output: SELECT T1.claim_id ,  T1.date_claim_made ,  count(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id  =  T2.claim_id GROUP BY T1.claim_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: How many settlements were made on the claim with the most recent claim settlement date? List the number and the claim id. [/INST]

Output: SELECT count(*) ,  T1.claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id  =  T2.claim_id GROUP BY T1.claim_id ORDER BY T1.Date_Claim_Settled DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the claim id and the number of settlements made for the claim with the most recent settlement date. [/INST]

Output: SELECT count(*) ,  T1.claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id  =  T2.claim_id GROUP BY T1.claim_id ORDER BY T1.Date_Claim_Settled DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Of all the claims, what was the earliest date when any claim was made? [/INST]

Output: SELECT Date_Claim_Made FROM Claims ORDER BY Date_Claim_Made ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Tell me the the date when the first claim was made. [/INST]

Output: SELECT Date_Claim_Made FROM Claims ORDER BY Date_Claim_Made ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What is the total amount of settlement made for all the settlements? [/INST]

Output: SELECT sum(Amount_Settled) FROM Settlements;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Compute the total amount of settlement across all the settlements. [/INST]

Output: SELECT sum(Amount_Settled) FROM Settlements;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Who are the customers that had more than 1 policy? List the customer details and id. [/INST]

Output: SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.Customer_id GROUP BY T1.customer_id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the the customer details and id for the customers who had more than one policy. [/INST]

Output: SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.Customer_id GROUP BY T1.customer_id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What are the claim dates and settlement dates of all the settlements? [/INST]

Output: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Settlements;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Tell me the the claim date and settlement date for each settlement case. [/INST]

Output: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Settlements;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What is the most popular payment method? [/INST]

Output: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which payment method is used the most often? [/INST]

Output: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: With which kind of payment method were the least number of payments processed? [/INST]

Output: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What is the payment method that were used the least often? [/INST]

Output: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What is the total amount of payment? [/INST]

Output: SELECT sum(Amount_Payment) FROM Payments;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Compute the total amount of payment processed. [/INST]

Output: SELECT sum(Amount_Payment) FROM Payments;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What are all the distinct details of the customers? [/INST]

Output: SELECT DISTINCT customer_details FROM Customers;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Return the distinct customer details. [/INST]

Output: SELECT DISTINCT customer_details FROM Customers;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which kind of policy type was chosen by the most customers? [/INST]

Output: SELECT Policy_Type_Code FROM Customer_Policies GROUP BY Policy_Type_Code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the policy type the most customers choose. [/INST]

Output: SELECT Policy_Type_Code FROM Customer_Policies GROUP BY Policy_Type_Code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: How many settlements are there in total? [/INST]

Output: SELECT count(*) FROM Settlements;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Count the total number of settlements made. [/INST]

Output: SELECT count(*) FROM Settlements;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which Payments were processed with Visa? List the payment Id, the date and the amount. [/INST]

Output: SELECT Payment_ID ,  Date_Payment_Made ,  Amount_Payment FROM Payments WHERE Payment_Method_Code  =  'Visa';


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Give me the payment Id, the date and the amount for all the payments processed with Visa. [/INST]

Output: SELECT Payment_ID ,  Date_Payment_Made ,  Amount_Payment FROM Payments WHERE Payment_Method_Code  =  'Visa';


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: List the details of the customers who do not have any policies. [/INST]

Output: SELECT customer_details FROM Customers EXCEPT SELECT T1.customer_details FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.customer_id  =  T2.customer_id;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which customers do not have any policies? Find the details of these customers. [/INST]

Output: SELECT customer_details FROM Customers EXCEPT SELECT T1.customer_details FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.customer_id  =  T2.customer_id;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: List the date the claim was made, the date it was settled and the amount settled for all the claims which had exactly one settlement. [/INST]

Output: SELECT T1.claim_id ,  T1.date_claim_made ,  T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id GROUP BY T1.claim_id HAVING count(*)  =  1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Which claims had exactly one settlement? For each, tell me the the date the claim was made, the date it was settled and the amount settled. [/INST]

Output: SELECT T1.claim_id ,  T1.date_claim_made ,  T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id GROUP BY T1.claim_id HAVING count(*)  =  1;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: Find the total claimed amount of all the claims. [/INST]

Output: SELECT sum(Amount_Claimed) FROM Claims;


Input:
[INST] Here is a database schema:
Customers :
Customer_ID [ INT ] primary_key
Customer_Details [ TEXT ]

Customer_Policies :
Policy_ID [ INT ] primary_key
Customer_ID [ INT ] Customer_Policies.Customer_ID = Customers.Customer_ID
Policy_Type_Code [ TEXT ]
Start_Date [ TEXT ]
End_Date [ TEXT ]

Claims :
Claim_ID [ INT ] primary_key
Policy_ID [ INT ] Claims.Policy_ID = Customer_Policies.Policy_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]

Settlements :
Settlement_ID [ INT ] primary_key
Claim_ID [ INT ] Settlements.Claim_ID = Claims.Claim_ID
Date_Claim_Made [ TEXT ]
Date_Claim_Settled [ TEXT ]
Amount_Claimed [ INT ]
Amount_Settled [ INT ]
Customer_Policy_ID [ INT ]

Payments :
Payment_ID [ INT ] primary_key
Settlement_ID [ INT ] Payments.Settlement_ID = Settlements.Settlement_ID
Payment_Method_Code [ TEXT ]
Date_Payment_Made [ TEXT ]
Amount_Payment [ INT ]

Please write me a SQL statement that answers the following question: What is total amount claimed summed across all the claims? [/INST]

Output: SELECT sum(Amount_Claimed) FROM Claims;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Which department has the largest number of employees? [/INST]

Output: SELECT name FROM department GROUP BY departmentID ORDER BY count(departmentID) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the department with the most employees. [/INST]

Output: SELECT name FROM department GROUP BY departmentID ORDER BY count(departmentID) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What is the employee id of the head whose department has the least number of employees? [/INST]

Output: SELECT head FROM department GROUP BY departmentID ORDER BY count(departmentID) LIMIT 1;