Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: How many engineer visits are required at most for a single fault log? List the number and the log entry id. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

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

Output: SELECT DISTINCT last_name FROM Maintenance_Engineers;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: How many fault status codes are recorded in the fault log parts table? [/INST]

Output: SELECT DISTINCT fault_status FROM Fault_Log_Parts;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which engineers have never visited to maintain the assets? List the engineer first name and last name. [/INST]

Output: SELECT first_name ,  last_name FROM Maintenance_Engineers WHERE engineer_id NOT IN (SELECT engineer_id FROM Engineer_Visits);


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: List the asset id, details, make and model for every asset. [/INST]

Output: SELECT asset_id ,  asset_details ,  asset_make ,  asset_model FROM Assets;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: When was the first asset acquired? [/INST]

Output: SELECT asset_acquired_date FROM Assets ORDER BY asset_acquired_date ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which part fault requires the most number of skills to fix? List part id and name. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which kind of part has the least number of faults? List the part name. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which staff have contacted which engineers? List the staff name and the engineer first name and last name. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which fault log included the most number of faulty parts? List the fault log id, description and record time. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which skill is used in fixing the most number of faults? List the skill id and description. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

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

Output: SELECT DISTINCT asset_model FROM Assets;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: List the all the assets make, model, details by the disposed date ascendingly. [/INST]

Output: SELECT asset_make ,  asset_model ,  asset_details FROM Assets ORDER BY asset_disposed_date ASC;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which part has the least chargeable amount? List the part id and amount. [/INST]

Output: SELECT part_id ,  chargeable_amount FROM Parts ORDER BY chargeable_amount ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which company started the earliest the maintenance contract? Show the company name. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: What is the description of the type of the company who concluded its contracts most recently? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which gender makes up the majority of the staff? [/INST]

Output: SELECT gender FROM staff GROUP BY gender ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: How many engineers did each staff contact? List both the contact staff name and number of engineers contacted. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which assets did not incur any fault log? List the asset model. [/INST]

Output: SELECT asset_model FROM Assets WHERE asset_id NOT IN (SELECT asset_id FROM Fault_Log);


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: list the local authorities and services provided by all stations. [/INST]

Output: SELECT local_authority ,  services FROM station;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: show all train numbers and names ordered by their time from early to late. [/INST]

Output: SELECT train_number ,  name FROM train ORDER BY TIME;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Give me the times and numbers of all trains that go to Chennai, ordered by time. [/INST]

Output: SELECT TIME ,  train_number FROM train WHERE destination  =  'Chennai' ORDER BY TIME;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: How many trains have 'Express' in their names? [/INST]

Output: SELECT count(*) FROM train WHERE name LIKE "%Express%";


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find the number and time of the train that goes from Chennai to Guruvayur. [/INST]

Output: SELECT train_number ,  TIME FROM train WHERE origin  =  'Chennai' AND destination  =  'Guruvayur';


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find the number of trains starting from each origin. [/INST]

Output: SELECT origin ,  count(*) FROM train GROUP BY origin;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find the name of the train whose route runs through greatest number of stations. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find the number of trains for each station, as well as the station network name and services. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: What is the average high temperature for each day of week? [/INST]

Output: SELECT avg(high_temperature) ,  day_of_week FROM weekly_weather GROUP BY day_of_week;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Give me the maximum low temperature and average precipitation at the Amersham station. [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find names and times of trains that run through stations for the local authority Chiltern. [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: How many different services are provided by all stations? [/INST]

Output: SELECT count(DISTINCT services) FROM station;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find the id and local authority of the station with has the highest average high temperature. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find the id and local authority of the station whose maximum precipitation is higher than 50. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: show the lowest low temperature and highest wind speed in miles per hour. [/INST]

Output: SELECT min(low_temperature) ,  max(wind_speed_mph) FROM weekly_weather;


Input:
[INST] Here is a database schema:
train :
id [ INT ] primary_key
train_number [ INT ]
name [ TEXT ]
origin [ TEXT ]
destination [ TEXT ]
time [ TEXT ]
interval [ TEXT ]

station :
id [ INT ] primary_key
network_name [ TEXT ]
services [ TEXT ]
local_authority [ TEXT ]

route :
train_id [ INT ] primary_key route.train_id = train.id
station_id [ INT ] route.station_id = station.id

weekly_weather :
station_id [ INT ] primary_key weekly_weather.station_id = station.id
day_of_week [ TEXT ]
high_temperature [ INT ]
low_temperature [ INT ]
precipitation [ INT ]
wind_speed_mph [ INT ]

Please write me a SQL statement that answers the following question: Find the origins from which more than 1 train starts. [/INST]

Output: SELECT origin FROM train GROUP BY origin HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: Find the number of professors in accounting department. [/INST]

Output: SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code  =  T2.dept_code WHERE DEPT_NAME  =  "Accounting";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: How many professors are in the accounting dept? [/INST]

Output: SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code  =  T2.dept_code WHERE DEPT_NAME  =  "Accounting";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: How many professors are teaching class with code ACCT-211? [/INST]

Output: SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE  =  "ACCT-211";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: How many professors teach a class with the code ACCT-211? [/INST]

Output: SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE  =  "ACCT-211";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: What is the first and last name of the professor in biology department? [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: What are the first and last name of all biology professors? [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: What are the first names and date of birth of professors teaching course ACCT-211? [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: What are the first names and birthdates of the professors in charge of ACCT-211? [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: How many classes are professor whose last name is Graztevski has? [/INST]

Output: SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM  =  T2.PROF_NUM WHERE T1.EMP_LNAME  =  'Graztevski';


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: How many classes does the professor whose last name is Graztevski teach? [/INST]

Output: SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM  =  T2.PROF_NUM WHERE T1.EMP_LNAME  =  'Graztevski';


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: What is the code of the school where the accounting department belongs to? [/INST]

Output: SELECT school_code FROM department WHERE dept_name  =  "Accounting";


Input:
[INST] Here is a database schema:
CLASS :
CLASS_CODE [ TEXT ] primary_key
CRS_CODE [ TEXT ] CLASS.CRS_CODE = COURSE.CRS_CODE
CLASS_SECTION [ TEXT ]
CLASS_TIME [ TEXT ]
CLASS_ROOM [ TEXT ]
PROF_NUM [ INT ] CLASS.PROF_NUM = EMPLOYEE.EMP_NUM

COURSE :
CRS_CODE [ TEXT ] primary_key
DEPT_CODE [ TEXT ] COURSE.DEPT_CODE = DEPARTMENT.DEPT_CODE
CRS_DESCRIPTION [ TEXT ]
CRS_CREDIT [ INT ]

DEPARTMENT :
DEPT_CODE [ TEXT ] primary_key
DEPT_NAME [ TEXT ]
SCHOOL_CODE [ TEXT ]
EMP_NUM [ INT ] DEPARTMENT.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_ADDRESS [ TEXT ]
DEPT_EXTENSION [ TEXT ]

EMPLOYEE :
EMP_NUM [ INT ] primary_key
EMP_LNAME [ TEXT ]
EMP_FNAME [ TEXT ]
EMP_INITIAL [ TEXT ]
EMP_JOBCODE [ TEXT ]
EMP_HIREDATE [ TEXT ]
EMP_DOB [ TEXT ]

ENROLL :
CLASS_CODE [ TEXT ] ENROLL.CLASS_CODE = CLASS.CLASS_CODE
STU_NUM [ INT ] ENROLL.STU_NUM = STUDENT.STU_NUM
ENROLL_GRADE [ TEXT ]

PROFESSOR :
EMP_NUM [ INT ] PROFESSOR.EMP_NUM = EMPLOYEE.EMP_NUM
DEPT_CODE [ TEXT ] PROFESSOR.DEPT_CODE = DEPARTMENT.DEPT_CODE
PROF_OFFICE [ TEXT ]
PROF_EXTENSION [ TEXT ]
PROF_HIGH_DEGREE [ TEXT ]

STUDENT :
STU_NUM [ INT ] primary_key
STU_LNAME [ TEXT ]
STU_FNAME [ TEXT ]
STU_INIT [ TEXT ]
STU_DOB [ TEXT ]
STU_HRS [ INT ]
STU_CLASS [ TEXT ]
STU_GPA [ INT ]
STU_TRANSFER [ INT ]
DEPT_CODE [ TEXT ] STUDENT.DEPT_CODE = DEPARTMENT.DEPT_CODE
STU_PHONE [ TEXT ]
PROF_NUM [ INT ]

Please write me a SQL statement that answers the following question: What is the school code of the accounting department? [/INST]

Output: SELECT school_code FROM department WHERE dept_name  =  "Accounting";