db_name
stringclasses 146
values | prompt
stringlengths 310
4.81k
|
|---|---|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# List all information about the assessment notes sorted by date in ascending order.
#
### SQL:
#
# SELECT * FROM Assessment_Notes ORDER BY date_of_notes ASC
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# List all cities of addresses in alphabetical order.
#
### SQL:
#
# SELECT city FROM Addresses ORDER BY city
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the first names and last names of teachers in alphabetical order of last name.
#
### SQL:
#
# SELECT first_name , last_name FROM Teachers ORDER BY last_name
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find all information about student addresses, and sort by monthly rental in descending order.
#
### SQL:
#
# SELECT * FROM Student_Addresses ORDER BY monthly_rental DESC
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the id and first name of the student that has the most number of assessment notes?
#
### SQL:
#
# SELECT T1.student_id , T2.first_name FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the ids and first names of the 3 teachers that have the most number of assessment notes?
#
### SQL:
#
# SELECT T1.teacher_id , T2.first_name FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 3
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the id and last name of the student that has the most behavior incidents?
#
### SQL:
#
# SELECT T1.student_id , T2.last_name FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the id and last name of the teacher that has the most detentions with detention type code "AFTER"?
#
### SQL:
#
# SELECT T1.teacher_id , T2.last_name FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T1.detention_type_code = "AFTER" GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the id and first name of the student whose addresses have the highest average monthly rental?
#
### SQL:
#
# SELECT T1.student_id , T2.first_name FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY AVG(monthly_rental) DESC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the id and city of the student address with the highest average monthly rental.
#
### SQL:
#
# SELECT T2.address_id , T1.city FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id ORDER BY AVG(monthly_rental) DESC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the code and description of the most frequent behavior incident type?
#
### SQL:
#
# SELECT T1.incident_type_code , T2.incident_type_description FROM Behavior_Incident AS T1 JOIN Ref_Incident_Type AS T2 ON T1.incident_type_code = T2.incident_type_code GROUP BY T1.incident_type_code ORDER BY count(*) DESC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the code and description of the least frequent detention type ?
#
### SQL:
#
# SELECT T1.detention_type_code , T2.detention_type_description FROM Detention AS T1 JOIN Ref_Detention_Type AS T2 ON T1.detention_type_code = T2.detention_type_code GROUP BY T1.detention_type_code ORDER BY count(*) ASC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the dates of assessment notes for students with first name "Fanny".
#
### SQL:
#
# SELECT T1.date_of_notes FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.first_name = "Fanny"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the texts of assessment notes for teachers with last name "Schuster".
#
### SQL:
#
# SELECT T1.text_of_notes FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schuster"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the start and end dates of behavior incidents of students with last name "Fahey".
#
### SQL:
#
# SELECT T1.date_incident_start , date_incident_end FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.last_name = "Fahey"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the start and end dates of detentions of teachers with last name "Schultz".
#
### SQL:
#
# SELECT T1.datetime_detention_start , datetime_detention_end FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schultz"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the id and zip code of the address with the highest monthly rental?
#
### SQL:
#
# SELECT T2.address_id , T1.zip_postcode FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id ORDER BY monthly_rental DESC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What is the cell phone number of the student whose address has the lowest monthly rental?
#
### SQL:
#
# SELECT T2.cell_mobile_number FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id ORDER BY T1.monthly_rental ASC LIMIT 1
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the monthly rentals of student addresses in Texas state?
#
### SQL:
#
# SELECT T2.monthly_rental FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Texas"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the first names and last names of students with address in Wisconsin state?
#
### SQL:
#
# SELECT T2.first_name , T2.last_name FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Wisconsin"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the line 1 and average monthly rentals of all student addresses?
#
### SQL:
#
# SELECT T1.line_1 , avg(T2.monthly_rental) FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What is the zip code of the address where the teacher with first name "Lyla" lives?
#
### SQL:
#
# SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = "Lyla"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the email addresses of teachers whose address has zip code "918"?
#
### SQL:
#
# SELECT T2.email_address FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T1.zip_postcode = "918"
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# How many students are not involved in any behavior incident?
#
### SQL:
#
# SELECT count(*) FROM STUDENTS WHERE student_id NOT IN ( SELECT student_id FROM Behavior_Incident )
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# Find the last names of teachers who are not involved in any detention.
#
### SQL:
#
# SELECT last_name FROM Teachers EXCEPT SELECT T1.last_name FROM Teachers AS T1 JOIN Detention AS T2 ON T1.teacher_id = T2.teacher_id
#
### End.
|
behavior_monitoring
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Address_Types ( address_type_code, address_type_description )
# Ref_Detention_Type ( detention_type_code, detention_type_description )
# Ref_Incident_Type ( incident_type_code, incident_type_description )
# Addresses ( address_id, line_1, line_2, line_3, city, zip_postcode, state_province_county, country, other_address_details )
# Students ( student_id, address_id, first_name, middle_name, last_name, cell_mobile_number, email_address, date_first_rental, date_left_university, other_student_details )
# Teachers ( teacher_id, address_id, first_name, middle_name, last_name, gender, cell_mobile_number, email_address, other_details )
# Assessment_Notes ( notes_id, student_id, teacher_id, date_of_notes, text_of_notes, other_details )
# Behavior_Incident ( incident_id, incident_type_code, student_id, date_incident_start, date_incident_end, incident_summary, recommendations, other_details )
# Detention ( detention_id, detention_type_code, teacher_id, datetime_detention_start, datetime_detention_end, detention_summary, other_details )
# Student_Addresses ( student_id, address_id, date_address_from, date_address_to, monthly_rental, other_details )
# Students_in_Detention ( student_id, detention_id, incident_id )
#
# Students.address_id can be joined with Addresses.address_id
# Teachers.address_id can be joined with Addresses.address_id
# Assessment_Notes.teacher_id can be joined with Teachers.teacher_id
# Assessment_Notes.student_id can be joined with Students.student_id
# Behavior_Incident.student_id can be joined with Students.student_id
# Behavior_Incident.incident_type_code can be joined with Ref_Incident_Type.incident_type_code
# Detention.teacher_id can be joined with Teachers.teacher_id
# Detention.detention_type_code can be joined with Ref_Detention_Type.detention_type_code
# Student_Addresses.student_id can be joined with Students.student_id
# Student_Addresses.address_id can be joined with Addresses.address_id
# Students_in_Detention.student_id can be joined with Students.student_id
# Students_in_Detention.detention_id can be joined with Detention.detention_id
# Students_in_Detention.incident_id can be joined with Behavior_Incident.incident_id
#
### Question:
#
# What are the line 1 of addresses shared by some students and some teachers?
#
### SQL:
#
# SELECT T1.line_1 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id INTERSECT SELECT T1.line_1 FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail.
#
### SQL:
#
# SELECT T1.asset_id , T1.asset_details FROM Assets AS T1 JOIN Asset_Parts AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING count(*) = 2 INTERSECT SELECT T1.asset_id , T1.asset_details FROM Assets AS T1 JOIN Fault_Log AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING count(*) < 2
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# How many assets does each maintenance contract contain? List the number and the contract id.
#
### SQL:
#
# SELECT count(*) , T1.maintenance_contract_id FROM Maintenance_Contracts AS T1 JOIN Assets AS T2 ON T1.maintenance_contract_id = T2.maintenance_contract_id GROUP BY T1.maintenance_contract_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# How many assets does each third party company supply? List the count and the company id.
#
### SQL:
#
# SELECT count(*) , T1.company_id FROM Third_Party_Companies AS T1 JOIN Assets AS T2 ON T1.company_id = T2.supplier_company_id GROUP BY T1.company_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name.
#
### SQL:
#
# SELECT T1.company_id , T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Engineers AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING count(*) >= 2 UNION SELECT T3.company_id , T3.company_name FROM Third_Party_Companies AS T3 JOIN Maintenance_Contracts AS T4 ON T3.company_id = T4.maintenance_contract_company_id GROUP BY T3.company_id HAVING count(*) >= 2
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers?
#
### SQL:
#
# SELECT T1.staff_name , T1.staff_id FROM Staff AS T1 JOIN Fault_Log AS T2 ON T1.staff_id = T2.recorded_by_staff_id EXCEPT SELECT T3.staff_name , T3.staff_id FROM Staff AS T3 JOIN Engineer_Visits AS T4 ON T3.staff_id = T4.contact_staff_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which engineer has visited the most times? Show the engineer id, first name and last name.
#
### SQL:
#
# SELECT T1.engineer_id , T1.first_name , T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 GROUP BY T1.engineer_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which parts have more than 2 faults? Show the part name and id.
#
### SQL:
#
# SELECT T1.part_name , T1.part_id FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_id HAVING count(*) > 2
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# List all every engineer's first name, last name, details and coresponding skill description.
#
### SQL:
#
# SELECT T1.first_name , T1.last_name , T1.other_details , T3.skill_description FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# For all the faults of different parts, what are all the decriptions of the skills required to fix them? List the name of the faults and the skill description.
#
### SQL:
#
# SELECT T1.fault_short_name , T3.skill_description FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# How many assets can each parts be used in? List the part name and the number.
#
### SQL:
#
# SELECT T1.part_name , count(*) FROM Parts AS T1 JOIN Asset_Parts AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# What are all the fault descriptions and the fault status of all the faults recoreded in the logs?
#
### SQL:
#
# SELECT T1.fault_description , T2.fault_status FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# How many engineer visits are required at most for a single fault log? List the number and the log entry id.
#
### SQL:
#
# SELECT count(*) , T1.fault_log_entry_id FROM Fault_Log AS T1 JOIN Engineer_Visits AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# What are all the distinct last names of all the engineers?
#
### SQL:
#
# SELECT DISTINCT last_name FROM Maintenance_Engineers
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# How many fault status codes are recorded in the fault log parts table?
#
### SQL:
#
# SELECT DISTINCT fault_status FROM Fault_Log_Parts
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which engineers have never visited to maintain the assets? List the engineer first name and last name.
#
### SQL:
#
# SELECT first_name , last_name FROM Maintenance_Engineers WHERE engineer_id NOT IN (SELECT engineer_id FROM Engineer_Visits)
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# List the asset id, details, make and model for every asset.
#
### SQL:
#
# SELECT asset_id , asset_details , asset_make , asset_model FROM Assets
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# When was the first asset acquired?
#
### SQL:
#
# SELECT asset_acquired_date FROM Assets ORDER BY asset_acquired_date ASC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which part fault requires the most number of skills to fix? List part id and name.
#
### SQL:
#
# SELECT T1.part_id , T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id JOIN Skills_Required_To_Fix AS T3 ON T2.part_fault_id = T3.part_fault_id GROUP BY T1.part_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which kind of part has the least number of faults? List the part name.
#
### SQL:
#
# SELECT T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name ORDER BY count(*) ASC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name.
#
### SQL:
#
# SELECT T1.engineer_id , T1.first_name , T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 ON T1.engineer_id = T2.engineer_id GROUP BY T1.engineer_id ORDER BY count(*) ASC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which staff have contacted which engineers? List the staff name and the engineer first name and last name.
#
### SQL:
#
# SELECT T1.staff_name , T3.first_name , T3.last_name FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id JOIN Maintenance_Engineers AS T3 ON T2.engineer_id = T3.engineer_id
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which fault log included the most number of faulty parts? List the fault log id, description and record time.
#
### SQL:
#
# SELECT T1.fault_log_entry_id , T1.fault_description , T1.fault_log_entry_datetime FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which skill is used in fixing the most number of faults? List the skill id and description.
#
### SQL:
#
# SELECT T1.skill_id , T1.skill_description FROM Skills AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.skill_id = T2.skill_id GROUP BY T1.skill_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# What are all the distinct asset models?
#
### SQL:
#
# SELECT DISTINCT asset_model FROM Assets
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# List the all the assets make, model, details by the disposed date ascendingly.
#
### SQL:
#
# SELECT asset_make , asset_model , asset_details FROM Assets ORDER BY asset_disposed_date ASC
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which part has the least chargeable amount? List the part id and amount.
#
### SQL:
#
# SELECT part_id , chargeable_amount FROM Parts ORDER BY chargeable_amount ASC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which company started the earliest the maintenance contract? Show the company name.
#
### SQL:
#
# SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id ORDER BY T2.contract_start_date ASC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# What is the description of the type of the company who concluded its contracts most recently?
#
### SQL:
#
# SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id JOIN Ref_Company_Types AS T3 ON T1.company_type_code = T3.company_type_code ORDER BY T2.contract_end_date DESC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which gender makes up the majority of the staff?
#
### SQL:
#
# SELECT gender FROM staff GROUP BY gender ORDER BY count(*) DESC LIMIT 1
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# How many engineers did each staff contact? List both the contact staff name and number of engineers contacted.
#
### SQL:
#
# SELECT T1.staff_name , count(*) FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id GROUP BY T1.staff_name
#
### End.
|
assets_maintenance
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Third_Party_Companies ( company_id, company_type, company_name, company_address, other_company_details )
# Maintenance_Contracts ( maintenance_contract_id, maintenance_contract_company_id, contract_start_date, contract_end_date, other_contract_details )
# Parts ( part_id, part_name, chargeable_yn, chargeable_amount, other_part_details )
# Skills ( skill_id, skill_code, skill_description )
# Staff ( staff_id, staff_name, gender, other_staff_details )
# Assets ( asset_id, maintenance_contract_id, supplier_company_id, asset_details, asset_make, asset_model, asset_acquired_date, asset_disposed_date, other_asset_details )
# Asset_Parts ( asset_id, part_id )
# Maintenance_Engineers ( engineer_id, company_id, first_name, last_name, other_details )
# Engineer_Skills ( engineer_id, skill_id )
# Fault_Log ( fault_log_entry_id, asset_id, recorded_by_staff_id, fault_log_entry_datetime, fault_description, other_fault_details )
# Engineer_Visits ( engineer_visit_id, contact_staff_id, engineer_id, fault_log_entry_id, fault_status, visit_start_datetime, visit_end_datetime, other_visit_details )
# Part_Faults ( part_fault_id, part_id, fault_short_name, fault_description, other_fault_details )
# Fault_Log_Parts ( fault_log_entry_id, part_fault_id, fault_status )
# Skills_Required_To_Fix ( part_fault_id, skill_id )
#
# Maintenance_Contracts.maintenance_contract_company_id can be joined with Third_Party_Companies.company_id
# Assets.supplier_company_id can be joined with Third_Party_Companies.company_id
# Assets.maintenance_contract_id can be joined with Maintenance_Contracts.maintenance_contract_id
# Asset_Parts.asset_id can be joined with Assets.asset_id
# Asset_Parts.part_id can be joined with Parts.part_id
# Maintenance_Engineers.company_id can be joined with Third_Party_Companies.company_id
# Engineer_Skills.skill_id can be joined with Skills.skill_id
# Engineer_Skills.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Fault_Log.recorded_by_staff_id can be joined with Staff.staff_id
# Fault_Log.asset_id can be joined with Assets.asset_id
# Engineer_Visits.contact_staff_id can be joined with Staff.staff_id
# Engineer_Visits.engineer_id can be joined with Maintenance_Engineers.engineer_id
# Engineer_Visits.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Part_Faults.part_id can be joined with Parts.part_id
# Fault_Log_Parts.fault_log_entry_id can be joined with Fault_Log.fault_log_entry_id
# Fault_Log_Parts.part_fault_id can be joined with Part_Faults.part_fault_id
# Skills_Required_To_Fix.skill_id can be joined with Skills.skill_id
# Skills_Required_To_Fix.part_fault_id can be joined with Part_Faults.part_fault_id
#
### Question:
#
# Which assets did not incur any fault log? List the asset model.
#
### SQL:
#
# SELECT asset_model FROM Assets WHERE asset_id NOT IN (SELECT asset_id FROM Fault_Log)
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# list the local authorities and services provided by all stations.
#
### SQL:
#
# SELECT local_authority , services FROM station
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# show all train numbers and names ordered by their time from early to late.
#
### SQL:
#
# SELECT train_number , name FROM train ORDER BY TIME
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Give me the times and numbers of all trains that go to Chennai, ordered by time.
#
### SQL:
#
# SELECT TIME , train_number FROM train WHERE destination = 'Chennai' ORDER BY TIME
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# How many trains have 'Express' in their names?
#
### SQL:
#
# SELECT count(*) FROM train WHERE name LIKE "%Express%"
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find the number and time of the train that goes from Chennai to Guruvayur.
#
### SQL:
#
# SELECT train_number , TIME FROM train WHERE origin = 'Chennai' AND destination = 'Guruvayur'
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find the number of trains starting from each origin.
#
### SQL:
#
# SELECT origin , count(*) FROM train GROUP BY origin
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find the name of the train whose route runs through greatest number of stations.
#
### SQL:
#
# SELECT t1.name FROM train AS t1 JOIN route AS t2 ON t1.id = t2.train_id GROUP BY t2.train_id ORDER BY count(*) DESC LIMIT 1
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find the number of trains for each station, as well as the station network name and services.
#
### SQL:
#
# SELECT count(*) , t1.network_name , t1.services FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id GROUP BY t2.station_id
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# What is the average high temperature for each day of week?
#
### SQL:
#
# SELECT avg(high_temperature) , day_of_week FROM weekly_weather GROUP BY day_of_week
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Give me the maximum low temperature and average precipitation at the Amersham station.
#
### SQL:
#
# SELECT max(t1.low_temperature) , avg(t1.precipitation) FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id WHERE t2.network_name = "Amersham"
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find names and times of trains that run through stations for the local authority Chiltern.
#
### SQL:
#
# SELECT t3.name , t3.time FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id JOIN train AS t3 ON t2.train_id = t3.id WHERE t1.local_authority = "Chiltern"
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# How many different services are provided by all stations?
#
### SQL:
#
# SELECT count(DISTINCT services) FROM station
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find the id and local authority of the station with has the highest average high temperature.
#
### SQL:
#
# SELECT t2.id , t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id ORDER BY avg(high_temperature) DESC LIMIT 1
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find the id and local authority of the station whose maximum precipitation is higher than 50.
#
### SQL:
#
# SELECT t2.id , t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id HAVING max(t1.precipitation) > 50
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# show the lowest low temperature and highest wind speed in miles per hour.
#
### SQL:
#
# SELECT min(low_temperature) , max(wind_speed_mph) FROM weekly_weather
#
### End.
|
station_weather
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# train ( id, train_number, name, origin, destination, time, interval )
# station ( id, network_name, services, local_authority )
# route ( train_id, station_id )
# weekly_weather ( station_id, day_of_week, high_temperature, low_temperature, precipitation, wind_speed_mph )
#
# route.station_id can be joined with station.id
# route.train_id can be joined with train.id
# weekly_weather.station_id can be joined with station.id
#
### Question:
#
# Find the origins from which more than 1 train starts.
#
### SQL:
#
# SELECT origin FROM train GROUP BY origin HAVING count(*) > 1
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# Find the number of professors in accounting department.
#
### SQL:
#
# SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many professors are in the accounting dept?
#
### SQL:
#
# SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many professors are teaching class with code ACCT-211?
#
### SQL:
#
# SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many professors teach a class with the code ACCT-211?
#
### SQL:
#
# SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What is the first and last name of the professor in biology department?
#
### SQL:
#
# SELECT T3.EMP_FNAME , T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = "Biology"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What are the first and last name of all biology professors?
#
### SQL:
#
# SELECT T3.EMP_FNAME , T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = "Biology"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What are the first names and date of birth of professors teaching course ACCT-211?
#
### SQL:
#
# SELECT DISTINCT T1.EMP_FNAME , T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = "ACCT-211"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What are the first names and birthdates of the professors in charge of ACCT-211?
#
### SQL:
#
# SELECT DISTINCT T1.EMP_FNAME , T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = "ACCT-211"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many classes are professor whose last name is Graztevski has?
#
### SQL:
#
# SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many classes does the professor whose last name is Graztevski teach?
#
### SQL:
#
# SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What is the code of the school where the accounting department belongs to?
#
### SQL:
#
# SELECT school_code FROM department WHERE dept_name = "Accounting"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What is the school code of the accounting department?
#
### SQL:
#
# SELECT school_code FROM department WHERE dept_name = "Accounting"
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many credits does course CIS-220 have, and what its description?
#
### SQL:
#
# SELECT crs_credit , crs_description FROM course WHERE crs_code = 'CIS-220'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What is the description for the CIS-220 and how many credits does it have?
#
### SQL:
#
# SELECT crs_credit , crs_description FROM course WHERE crs_code = 'CIS-220'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# what is the address of history department?
#
### SQL:
#
# SELECT dept_address FROM department WHERE dept_name = 'History'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# Where is the history department?
#
### SQL:
#
# SELECT dept_address FROM department WHERE dept_name = 'History'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many different locations does the school with code BUS has?
#
### SQL:
#
# SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What are the different locations of the school with the code BUS?
#
### SQL:
#
# SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many different locations does each school have?
#
### SQL:
#
# SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# Count different addresses of each school.
#
### SQL:
#
# SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# Find the description and credit for the course QM-261?
#
### SQL:
#
# SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# What is the course description and number of credits for QM-261?
#
### SQL:
#
# SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261'
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# Find the number of departments in each school.
#
### SQL:
#
# SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many departments are in each school?
#
### SQL:
#
# SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# Find the number of different departments in each school whose number of different departments is less than 5.
#
### SQL:
#
# SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code HAVING count(DISTINCT dept_name) < 5
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many different departments are there in each school that has less than 5 apartments?
#
### SQL:
#
# SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code HAVING count(DISTINCT dept_name) < 5
#
### End.
|
college_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# CLASS ( CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM )
# COURSE ( CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT )
# DEPARTMENT ( DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION )
# EMPLOYEE ( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB )
# ENROLL ( CLASS_CODE, STU_NUM, ENROLL_GRADE )
# PROFESSOR ( EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE )
# STUDENT ( STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM )
#
# CLASS.PROF_NUM can be joined with EMPLOYEE.EMP_NUM
# CLASS.CRS_CODE can be joined with COURSE.CRS_CODE
# COURSE.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# DEPARTMENT.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# ENROLL.STU_NUM can be joined with STUDENT.STU_NUM
# ENROLL.CLASS_CODE can be joined with CLASS.CLASS_CODE
# PROFESSOR.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
# PROFESSOR.EMP_NUM can be joined with EMPLOYEE.EMP_NUM
# STUDENT.DEPT_CODE can be joined with DEPARTMENT.DEPT_CODE
#
### Question:
#
# How many sections does each course has?
#
### SQL:
#
# SELECT count(*) , crs_code FROM CLASS GROUP BY crs_code
#
### End.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.