SQL
stringlengths
18
577
question
stringlengths
317
11.5k
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the ids and first names of the 3 teachers that have the most number of assessment notes?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the id and last name of the student that has the most behavior incidents?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the id and last name of the teacher that has the most detentions with detention type code "AFTER"?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the id and first name of the student whose addresses have the highest average monthly rental?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the id and city of the student address with the highest average monthly rental.
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the code and description of the most frequent behavior incident type?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the code and description of the least frequent detention type ?
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"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the dates of assessment notes for students with first name "Fanny".
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"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the texts of assessment notes for teachers with last name "Schuster".
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"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the start and end dates of behavior incidents of students with last name "Fahey".
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"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the start and end dates of detentions of teachers with last name "Schultz".
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the id and zip code of the address with the highest monthly rental?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the cell phone number of the student whose address has the lowest monthly rental?
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"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the monthly rentals of student addresses in Texas state?
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"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the first names and last names of students with address in Wisconsin state?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the line 1 and average monthly rentals of all student addresses?
SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = "Lyla"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the zip code of the address where the teacher with first name "Lyla" lives?
SELECT T2.email_address FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T1.zip_postcode = "918"
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the email addresses of teachers whose address has zip code "918"?
SELECT count(*) FROM STUDENTS WHERE student_id NOT IN ( SELECT student_id FROM Behavior_Incident )
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many students are not involved in any behavior incident?
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the last names of teachers who are not involved in any detention.
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
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the line 1 of addresses shared by some students and some teachers?
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many assets does each maintenance contract contain? List the number and the contract id.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many assets does each third party company supply? List the count and the company id.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers?
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which engineer has visited the most times? Show the engineer id, first name and last name.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which parts have more than 2 faults? Show the part name and id.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. List all every engineer's first name, last name, details and coresponding skill description.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. 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.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many assets can each parts be used in? List the part name and the number.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are all the fault descriptions and the fault status of all the faults recoreded in the logs?
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many engineer visits are required at most for a single fault log? List the number and the log entry id.
SELECT DISTINCT last_name FROM Maintenance_Engineers
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are all the distinct last names of all the engineers?
SELECT DISTINCT fault_status FROM Fault_Log_Parts
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many fault status codes are recorded in the fault log parts table?
SELECT first_name , last_name FROM Maintenance_Engineers WHERE engineer_id NOT IN (SELECT engineer_id FROM Engineer_Visits)
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which engineers have never visited to maintain the assets? List the engineer first name and last name.
SELECT asset_id , asset_details , asset_make , asset_model FROM Assets
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. List the asset id, details, make and model for every asset.
SELECT asset_acquired_date FROM Assets ORDER BY asset_acquired_date ASC LIMIT 1
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. When was the first asset acquired?
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which part fault requires the most number of skills to fix? List part id and name.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which kind of part has the least number of faults? List the part name.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which staff have contacted which engineers? List the staff name and the engineer first name and last name.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which fault log included the most number of faulty parts? List the fault log id, description and record time.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which skill is used in fixing the most number of faults? List the skill id and description.
SELECT DISTINCT asset_model FROM Assets
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are all the distinct asset models?
SELECT asset_make , asset_model , asset_details FROM Assets ORDER BY asset_disposed_date ASC
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. List the all the assets make, model, details by the disposed date ascendingly.
SELECT part_id , chargeable_amount FROM Parts ORDER BY chargeable_amount ASC LIMIT 1
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which part has the least chargeable amount? List the part id and amount.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which company started the earliest the maintenance contract? Show the company name.
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the description of the type of the company who concluded its contracts most recently?
SELECT gender FROM staff GROUP BY gender ORDER BY count(*) DESC LIMIT 1
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which gender makes up the majority of the staff?
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
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many engineers did each staff contact? List both the contact staff name and number of engineers contacted.
SELECT asset_model FROM Assets WHERE asset_id NOT IN (SELECT asset_id FROM Fault_Log)
Given the Table third party companies having columns as company_id has datatype number, company_type has datatype text, company_name has datatype text, company_address has datatype text, other_company_details has datatype text which has company_id and Given the Table maintenance contracts having columns as maintenance_contract_id has datatype number, maintenance_contract_company_id has datatype number, contract_start_date has datatype time, contract_end_date has datatype time, other_contract_details has datatype text which has maintenance_contract_id and Given the Table parts having columns as part_id has datatype number, part_name has datatype text, chargeable_yn has datatype text, chargeable_amount has datatype text, other_part_details has datatype text which has part_id and Given the Table skills having columns as skill_id has datatype number, skill_code has datatype text, skill_description has datatype text which has skill_id and Given the Table staff having columns as staff_id has datatype number, staff_name has datatype text, gender has datatype text, other_staff_details has datatype text which has staff_id and Given the Table assets having columns as asset_id has datatype number, maintenance_contract_id has datatype number, supplier_company_id has datatype number, asset_details has datatype text, asset_make has datatype text, asset_model has datatype text, asset_acquired_date has datatype time, asset_disposed_date has datatype time, other_asset_details has datatype text which has asset_id and Given the Table asset parts having columns as asset_id has datatype number, part_id has datatype number which has engineer_id and Given the Table maintenance engineers having columns as engineer_id has datatype number, company_id has datatype number, first_name has datatype text, last_name has datatype text, other_details has datatype text which has fault_log_entry_id and Given the Table engineer skills having columns as engineer_id has datatype number, skill_id has datatype number which has engineer_visit_id and Given the Table fault log having columns as fault_log_entry_id has datatype number, asset_id has datatype number, recorded_by_staff_id has datatype number, fault_log_entry_datetime has datatype time, fault_description has datatype text, other_fault_details has datatype text which has part_fault_id and Given the Table engineer visits having columns as engineer_visit_id has datatype number, contact_staff_id has datatype number, engineer_id has datatype number, fault_log_entry_id has datatype number, fault_status has datatype text, visit_start_datetime has datatype time, visit_end_datetime has datatype time, other_visit_details has datatype text which has NO_PRIMARY_KEY and Given the Table part faults having columns as part_fault_id has datatype number, part_id has datatype number, fault_short_name has datatype text, fault_description has datatype text, other_fault_details has datatype text which has NO_PRIMARY_KEY and Given the Table fault log parts having columns as fault_log_entry_id has datatype number, part_fault_id has datatype number, fault_status has datatype text which has NO_PRIMARY_KEY and Given the Table skills required to fix having columns as part_fault_id has datatype number, skill_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Which assets did not incur any fault log? List the asset model.
SELECT local_authority , services FROM station
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. list the local authorities and services provided by all stations.
SELECT train_number , name FROM train ORDER BY TIME
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. show all train numbers and names ordered by their time from early to late.
SELECT TIME , train_number FROM train WHERE destination = 'Chennai' ORDER BY TIME
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Give me the times and numbers of all trains that go to Chennai, ordered by time.
SELECT count(*) FROM train WHERE name LIKE "%Express%"
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. How many trains have 'Express' in their names?
SELECT train_number , TIME FROM train WHERE origin = 'Chennai' AND destination = 'Guruvayur'
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find the number and time of the train that goes from Chennai to Guruvayur.
SELECT origin , count(*) FROM train GROUP BY origin
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find the number of trains starting from each origin.
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
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find the name of the train whose route runs through greatest number of stations.
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
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find the number of trains for each station, as well as the station network name and services.
SELECT avg(high_temperature) , day_of_week FROM weekly_weather GROUP BY day_of_week
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. What is the average high temperature for each day of week?
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"
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Give me the maximum low temperature and average precipitation at the Amersham station.
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"
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find names and times of trains that run through stations for the local authority Chiltern.
SELECT count(DISTINCT services) FROM station
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. How many different services are provided by all stations?
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
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find the id and local authority of the station with has the highest average high temperature.
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
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find the id and local authority of the station whose maximum precipitation is higher than 50.
SELECT min(low_temperature) , max(wind_speed_mph) FROM weekly_weather
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. show the lowest low temperature and highest wind speed in miles per hour.
SELECT origin FROM train GROUP BY origin HAVING count(*) > 1
Given the Table train having columns as id has datatype number, train_number has datatype number, name has datatype text, origin has datatype text, destination has datatype text, time has datatype text, interval has datatype text which has id and Given the Table station having columns as id has datatype number, network_name has datatype text, services has datatype text, local_authority has datatype text which has id and Given the Table route having columns as train_id has datatype number, station_id has datatype number which has train_id and Given the Table weekly weather having columns as station_id has datatype number, day_of_week has datatype text, high_temperature has datatype number, low_temperature has datatype number, precipitation has datatype number, wind_speed_mph has datatype number which has station_id. Answer the question by writing the appropriate SQL code. Find the origins from which more than 1 train starts.
SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the number of professors in accounting department.
SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many professors are in the accounting dept?
SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many professors are teaching class with code ACCT-211?
SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many professors teach a class with the code ACCT-211?
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"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the first and last name of the professor in biology department?
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"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the first and last name of all biology professors?
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"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the first names and date of birth of professors teaching course ACCT-211?
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"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the first names and birthdates of the professors in charge of ACCT-211?
SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many classes are professor whose last name is Graztevski has?
SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many classes does the professor whose last name is Graztevski teach?
SELECT school_code FROM department WHERE dept_name = "Accounting"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the code of the school where the accounting department belongs to?
SELECT school_code FROM department WHERE dept_name = "Accounting"
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the school code of the accounting department?
SELECT crs_credit , crs_description FROM course WHERE crs_code = 'CIS-220'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many credits does course CIS-220 have, and what its description?
SELECT crs_credit , crs_description FROM course WHERE crs_code = 'CIS-220'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the description for the CIS-220 and how many credits does it have?
SELECT dept_address FROM department WHERE dept_name = 'History'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. what is the address of history department?
SELECT dept_address FROM department WHERE dept_name = 'History'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Where is the history department?
SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many different locations does the school with code BUS has?
SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different locations of the school with the code BUS?
SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many different locations does each school have?
SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Count different addresses of each school.
SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the description and credit for the course QM-261?
SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261'
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the course description and number of credits for QM-261?
SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the number of departments in each school.
SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many departments are in each school?
SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code HAVING count(DISTINCT dept_name) < 5
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the number of different departments in each school whose number of different departments is less than 5.
SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code HAVING count(DISTINCT dept_name) < 5
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many different departments are there in each school that has less than 5 apartments?
SELECT count(*) , crs_code FROM CLASS GROUP BY crs_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many sections does each course has?
SELECT count(*) , crs_code FROM CLASS GROUP BY crs_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many sections does each course have?
SELECT sum(crs_credit) , dept_code FROM course GROUP BY dept_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the total credit does each department offer?
SELECT sum(crs_credit) , dept_code FROM course GROUP BY dept_code
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many credits does the department offer?
SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the number of classes offered for all class rooms that held at least 2 classes.
SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2
Given the Table class having columns as CLASS_CODE has datatype text, CRS_CODE has datatype text, CLASS_SECTION has datatype text, CLASS_TIME has datatype text, CLASS_ROOM has datatype text, PROF_NUM has datatype number which has CLASS_CODE and Given the Table course having columns as CRS_CODE has datatype text, DEPT_CODE has datatype text, CRS_DESCRIPTION has datatype text, CRS_CREDIT has datatype number which has CRS_CODE and Given the Table department having columns as DEPT_CODE has datatype text, DEPT_NAME has datatype text, SCHOOL_CODE has datatype text, EMP_NUM has datatype number, DEPT_ADDRESS has datatype text, DEPT_EXTENSION has datatype text which has DEPT_CODE and Given the Table employee having columns as EMP_NUM has datatype number, EMP_LNAME has datatype text, EMP_FNAME has datatype text, EMP_INITIAL has datatype text, EMP_JOBCODE has datatype text, EMP_HIREDATE has datatype time, EMP_DOB has datatype time which has EMP_NUM and Given the Table enroll having columns as CLASS_CODE has datatype text, STU_NUM has datatype number, ENROLL_GRADE has datatype text which has STU_NUM and Given the Table professor having columns as EMP_NUM has datatype number, DEPT_CODE has datatype text, PROF_OFFICE has datatype text, PROF_EXTENSION has datatype text, PROF_HIGH_DEGREE has datatype text which has NO_PRIMARY_KEY and Given the Table student having columns as STU_NUM has datatype number, STU_LNAME has datatype text, STU_FNAME has datatype text, STU_INIT has datatype text, STU_DOB has datatype time, STU_HRS has datatype number, STU_CLASS has datatype text, STU_GPA has datatype number, STU_TRANSFER has datatype number, DEPT_CODE has datatype text, STU_PHONE has datatype text, PROF_NUM has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. For each classroom with at least 2 classes, how many classes are offered?