Question: Find the id and city of the student address with the highest average monthly rental.

Context: CREATE TABLE Student_Addresses (address_id VARCHAR); CREATE TABLE Addresses (city VARCHAR, address_id VARCHAR)

SELECT T2.address_id, T1.city FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id ORDER BY AVG(monthly_rental) DESC LIMIT 1


Question: What are the code and description of the most frequent behavior incident type?

Context: CREATE TABLE Ref_Incident_Type (incident_type_description VARCHAR, incident_type_code VARCHAR); CREATE TABLE Behavior_Incident (incident_type_code VARCHAR)

SELECT T1.incident_type_code, T2.incident_type_description FROM Behavior_Incident AS T1 JOIN Ref_Incident_Type AS T2 ON T1.incident_type_code = T2.incident_type_code GROUP BY T1.incident_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the code and description of the least frequent detention type ?

Context: CREATE TABLE Ref_Detention_Type (detention_type_description VARCHAR, detention_type_code VARCHAR); CREATE TABLE Detention (detention_type_code VARCHAR)

SELECT T1.detention_type_code, T2.detention_type_description FROM Detention AS T1 JOIN Ref_Detention_Type AS T2 ON T1.detention_type_code = T2.detention_type_code GROUP BY T1.detention_type_code ORDER BY COUNT(*) LIMIT 1


Question: Find the dates of assessment notes for students with first name "Fanny".

Context: CREATE TABLE Students (student_id VARCHAR, first_name VARCHAR); CREATE TABLE Assessment_Notes (date_of_notes VARCHAR, student_id VARCHAR)

SELECT T1.date_of_notes FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.first_name = "Fanny"


Question: Find the texts of assessment notes for teachers with last name "Schuster".

Context: CREATE TABLE Assessment_Notes (text_of_notes VARCHAR, teacher_id VARCHAR); CREATE TABLE Teachers (teacher_id VARCHAR, last_name VARCHAR)

SELECT T1.text_of_notes FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schuster"


Question: Find the start and end dates of behavior incidents of students with last name "Fahey".

Context: CREATE TABLE Behavior_Incident (date_incident_start VARCHAR, student_id VARCHAR); CREATE TABLE Students (student_id VARCHAR, last_name VARCHAR)

SELECT T1.date_incident_start, date_incident_end FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.last_name = "Fahey"


Question: Find the start and end dates of detentions of teachers with last name "Schultz".

Context: CREATE TABLE Detention (datetime_detention_start VARCHAR, teacher_id VARCHAR); CREATE TABLE Teachers (teacher_id VARCHAR, last_name VARCHAR)

SELECT T1.datetime_detention_start, datetime_detention_end FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schultz"


Question: What are the id and zip code of the address with the highest monthly rental?

Context: CREATE TABLE Student_Addresses (address_id VARCHAR); CREATE TABLE Addresses (zip_postcode VARCHAR, address_id VARCHAR)

SELECT T2.address_id, T1.zip_postcode FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id ORDER BY monthly_rental DESC LIMIT 1


Question: What is the cell phone number of the student whose address has the lowest monthly rental?

Context: CREATE TABLE Students (cell_mobile_number VARCHAR, student_id VARCHAR); CREATE TABLE Student_Addresses (student_id VARCHAR, monthly_rental VARCHAR)

SELECT T2.cell_mobile_number FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id ORDER BY T1.monthly_rental LIMIT 1


Question: What are the monthly rentals of student addresses in Texas state?

Context: CREATE TABLE Addresses (address_id VARCHAR, state_province_county VARCHAR); CREATE TABLE Student_Addresses (monthly_rental VARCHAR, address_id VARCHAR)

SELECT T2.monthly_rental FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Texas"


Question: What are the first names and last names of students with address in Wisconsin state?

Context: CREATE TABLE Addresses (address_id VARCHAR, state_province_county VARCHAR); CREATE TABLE Students (first_name VARCHAR, last_name VARCHAR, address_id VARCHAR)

SELECT T2.first_name, T2.last_name FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Wisconsin"


Question: What are the line 1 and average monthly rentals of all student addresses?

Context: CREATE TABLE Addresses (line_1 VARCHAR, address_id VARCHAR); CREATE TABLE Student_Addresses (monthly_rental INTEGER, address_id VARCHAR)

SELECT T1.line_1, AVG(T2.monthly_rental) FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id


Question: What is the zip code of the address where the teacher with first name "Lyla" lives?

Context: CREATE TABLE Teachers (address_id VARCHAR, first_name VARCHAR); CREATE TABLE Addresses (zip_postcode VARCHAR, address_id VARCHAR)

SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = "Lyla"


Question: What are the email addresses of teachers whose address has zip code "918"?

Context: CREATE TABLE Addresses (address_id VARCHAR, zip_postcode VARCHAR); CREATE TABLE Teachers (email_address VARCHAR, address_id VARCHAR)

SELECT T2.email_address FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T1.zip_postcode = "918"


Question: How many students are not involved in any behavior incident?

Context: CREATE TABLE STUDENTS (student_id VARCHAR); CREATE TABLE Behavior_Incident (student_id VARCHAR)

SELECT COUNT(*) FROM STUDENTS WHERE NOT student_id IN (SELECT student_id FROM Behavior_Incident)


Question: Find the last names of teachers who are not involved in any detention.

Context: CREATE TABLE Teachers (last_name VARCHAR); CREATE TABLE Teachers (last_name VARCHAR, teacher_id VARCHAR); CREATE TABLE Detention (teacher_id VARCHAR)

SELECT last_name FROM Teachers EXCEPT SELECT T1.last_name FROM Teachers AS T1 JOIN Detention AS T2 ON T1.teacher_id = T2.teacher_id


Question: What are the line 1 of addresses shared by some students and some teachers?

Context: CREATE TABLE Teachers (address_id VARCHAR); CREATE TABLE Students (address_id VARCHAR); CREATE TABLE Addresses (line_1 VARCHAR, address_id VARCHAR)

SELECT T1.line_1 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id INTERSECT SELECT T1.line_1 FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id


Question: Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail.

Context: CREATE TABLE Assets (asset_id VARCHAR, asset_details VARCHAR); CREATE TABLE Asset_Parts (asset_id VARCHAR); CREATE TABLE Fault_Log (asset_id VARCHAR)

SELECT T1.asset_id, T1.asset_details FROM Assets AS T1 JOIN Asset_Parts AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING COUNT(*) = 2 INTERSECT SELECT T1.asset_id, T1.asset_details FROM Assets AS T1 JOIN Fault_Log AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING COUNT(*) < 2


Question: How many assets does each maintenance contract contain? List the number and the contract id.

Context: CREATE TABLE Assets (maintenance_contract_id VARCHAR); CREATE TABLE Maintenance_Contracts (maintenance_contract_id VARCHAR)

SELECT COUNT(*), T1.maintenance_contract_id FROM Maintenance_Contracts AS T1 JOIN Assets AS T2 ON T1.maintenance_contract_id = T2.maintenance_contract_id GROUP BY T1.maintenance_contract_id


Question: How many assets does each third party company supply? List the count and the company id.

Context: CREATE TABLE Assets (supplier_company_id VARCHAR); CREATE TABLE Third_Party_Companies (company_id VARCHAR)

SELECT COUNT(*), T1.company_id FROM Third_Party_Companies AS T1 JOIN Assets AS T2 ON T1.company_id = T2.supplier_company_id GROUP BY T1.company_id


Question: Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name.

Context: CREATE TABLE Maintenance_Contracts (maintenance_contract_company_id VARCHAR); CREATE TABLE Maintenance_Engineers (company_id VARCHAR); CREATE TABLE Third_Party_Companies (company_id VARCHAR, company_name VARCHAR)

SELECT T1.company_id, T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Engineers AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING COUNT(*) >= 2 UNION SELECT T3.company_id, T3.company_name FROM Third_Party_Companies AS T3 JOIN Maintenance_Contracts AS T4 ON T3.company_id = T4.maintenance_contract_company_id GROUP BY T3.company_id HAVING COUNT(*) >= 2


Question: What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers?

Context: CREATE TABLE Engineer_Visits (contact_staff_id VARCHAR); CREATE TABLE Staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE Fault_Log (recorded_by_staff_id VARCHAR)

SELECT T1.staff_name, T1.staff_id FROM Staff AS T1 JOIN Fault_Log AS T2 ON T1.staff_id = T2.recorded_by_staff_id EXCEPT SELECT T3.staff_name, T3.staff_id FROM Staff AS T3 JOIN Engineer_Visits AS T4 ON T3.staff_id = T4.contact_staff_id


Question: Which engineer has visited the most times? Show the engineer id, first name and last name.

Context: CREATE TABLE Maintenance_Engineers (engineer_id VARCHAR, first_name VARCHAR, last_name VARCHAR); CREATE TABLE Engineer_Visits (Id VARCHAR)

SELECT T1.engineer_id, T1.first_name, T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 GROUP BY T1.engineer_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Which parts have more than 2 faults? Show the part name and id.

Context: CREATE TABLE Parts (part_name VARCHAR, part_id VARCHAR); CREATE TABLE Part_Faults (part_id VARCHAR)

SELECT T1.part_name, T1.part_id FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_id HAVING COUNT(*) > 2


Question: List all every engineer's first name, last name, details and coresponding skill description.

Context: CREATE TABLE Maintenance_Engineers (first_name VARCHAR, last_name VARCHAR, other_details VARCHAR, engineer_id VARCHAR); CREATE TABLE Engineer_Skills (engineer_id VARCHAR, skill_id VARCHAR); CREATE TABLE Skills (skill_description VARCHAR, skill_id VARCHAR)

SELECT T1.first_name, T1.last_name, T1.other_details, T3.skill_description FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id


Question: For all the faults of different parts, what are all the decriptions of the skills required to fix them? List the name of the faults and the skill description.

Context: CREATE TABLE Skills_Required_To_Fix (part_fault_id VARCHAR, skill_id VARCHAR); CREATE TABLE Part_Faults (fault_short_name VARCHAR, part_fault_id VARCHAR); CREATE TABLE Skills (skill_description VARCHAR, skill_id VARCHAR)

SELECT T1.fault_short_name, T3.skill_description FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id


Question: How many assets can each parts be used in? List the part name and the number.

Context: CREATE TABLE Parts (part_name VARCHAR, part_id VARCHAR); CREATE TABLE Asset_Parts (part_id VARCHAR)

SELECT T1.part_name, COUNT(*) FROM Parts AS T1 JOIN Asset_Parts AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name


Question: What are all the fault descriptions and the fault status of all the faults recoreded in the logs?

Context: CREATE TABLE Fault_Log (fault_description VARCHAR, fault_log_entry_id VARCHAR); CREATE TABLE Fault_Log_Parts (fault_status VARCHAR, fault_log_entry_id VARCHAR)

SELECT T1.fault_description, T2.fault_status FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id


Question: How many engineer visits are required at most for a single fault log? List the number and the log entry id.

Context: CREATE TABLE Fault_Log (fault_log_entry_id VARCHAR); CREATE TABLE Engineer_Visits (fault_log_entry_id VARCHAR)

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


Question: What are all the distinct last names of all the engineers?

Context: CREATE TABLE Maintenance_Engineers (last_name VARCHAR)

SELECT DISTINCT last_name FROM Maintenance_Engineers


Question: How many fault status codes are recorded in the fault log parts table?

Context: CREATE TABLE Fault_Log_Parts (fault_status VARCHAR)

SELECT DISTINCT fault_status FROM Fault_Log_Parts


Question: Which engineers have never visited to maintain the assets? List the engineer first name and last name.

Context: CREATE TABLE Engineer_Visits (first_name VARCHAR, last_name VARCHAR, engineer_id VARCHAR); CREATE TABLE Maintenance_Engineers (first_name VARCHAR, last_name VARCHAR, engineer_id VARCHAR)

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


Question: List the asset id, details, make and model for every asset.

Context: CREATE TABLE Assets (asset_id VARCHAR, asset_details VARCHAR, asset_make VARCHAR, asset_model VARCHAR)

SELECT asset_id, asset_details, asset_make, asset_model FROM Assets


Question: When was the first asset acquired?

Context: CREATE TABLE Assets (asset_acquired_date VARCHAR)

SELECT asset_acquired_date FROM Assets ORDER BY asset_acquired_date LIMIT 1


Question: Which part fault requires the most number of skills to fix? List part id and name.

Context: CREATE TABLE Part_Faults (part_id VARCHAR, part_fault_id VARCHAR); CREATE TABLE Skills_Required_To_Fix (part_fault_id VARCHAR); CREATE TABLE Parts (part_id VARCHAR, part_name VARCHAR)

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


Question: Which kind of part has the least number of faults? List the part name.

SELECT T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name ORDER BY COUNT(*) LIMIT 1


Question: Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name.

Context: CREATE TABLE Engineer_Visits (engineer_id VARCHAR); CREATE TABLE Maintenance_Engineers (engineer_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

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(*) LIMIT 1


Question: Which staff have contacted which engineers? List the staff name and the engineer first name and last name.

Context: CREATE TABLE Engineer_Visits (contact_staff_id VARCHAR, engineer_id VARCHAR); CREATE TABLE Staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE Maintenance_Engineers (first_name VARCHAR, last_name VARCHAR, engineer_id VARCHAR)

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


Question: Which fault log included the most number of faulty parts? List the fault log id, description and record time.

Context: CREATE TABLE Fault_Log (fault_log_entry_id VARCHAR, fault_description VARCHAR, fault_log_entry_datetime VARCHAR); CREATE TABLE Fault_Log_Parts (fault_log_entry_id VARCHAR)

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


Question: Which skill is used in fixing the most number of faults? List the skill id and description.

Context: CREATE TABLE Skills (skill_id VARCHAR, skill_description VARCHAR); CREATE TABLE Skills_Required_To_Fix (skill_id VARCHAR)

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


Question: What are all the distinct asset models?

Context: CREATE TABLE Assets (asset_model VARCHAR)


Question: List the all the assets make, model, details by the disposed date ascendingly.

Context: CREATE TABLE Assets (asset_make VARCHAR, asset_model VARCHAR, asset_details VARCHAR, asset_disposed_date VARCHAR)

SELECT asset_make, asset_model, asset_details FROM Assets ORDER BY asset_disposed_date


Question: Which part has the least chargeable amount? List the part id and amount.

Context: CREATE TABLE Parts (part_id VARCHAR, chargeable_amount VARCHAR)

SELECT part_id, chargeable_amount FROM Parts ORDER BY chargeable_amount LIMIT 1


Question: Which company started the earliest the maintenance contract? Show the company name.

Context: CREATE TABLE Third_Party_Companies (company_name VARCHAR, company_id VARCHAR); CREATE TABLE Maintenance_Contracts (maintenance_contract_company_id VARCHAR, contract_start_date VARCHAR)

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 LIMIT 1


Question: What is the description of the type of the company who concluded its contracts most recently?

Context: CREATE TABLE Maintenance_Contracts (maintenance_contract_company_id VARCHAR, contract_end_date VARCHAR); CREATE TABLE Third_Party_Companies (company_name VARCHAR, company_id VARCHAR, company_type_code VARCHAR); CREATE TABLE Ref_Company_Types (company_type_code VARCHAR)

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


Question: Which gender makes up the majority of the staff?

Context: CREATE TABLE staff (gender VARCHAR)

SELECT gender FROM staff GROUP BY gender ORDER BY COUNT(*) DESC LIMIT 1


Question: How many engineers did each staff contact? List both the contact staff name and number of engineers contacted.

Context: CREATE TABLE Engineer_Visits (contact_staff_id VARCHAR); CREATE TABLE Staff (staff_name VARCHAR, staff_id VARCHAR)

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


Question: Which assets did not incur any fault log? List the asset model.

Context: CREATE TABLE Fault_Log (asset_model VARCHAR, asset_id VARCHAR); CREATE TABLE Assets (asset_model VARCHAR, asset_id VARCHAR)

SELECT asset_model FROM Assets WHERE NOT asset_id IN (SELECT asset_id FROM Fault_Log)


Question: list the local authorities and services provided by all stations.

Context: CREATE TABLE station (local_authority VARCHAR, services VARCHAR)

SELECT local_authority, services FROM station


Question: show all train numbers and names ordered by their time from early to late.

Context: CREATE TABLE train (train_number VARCHAR, name VARCHAR, TIME VARCHAR)

SELECT train_number, name FROM train ORDER BY TIME


Question: Give me the times and numbers of all trains that go to Chennai, ordered by time.

Context: CREATE TABLE train (TIME VARCHAR, train_number VARCHAR, destination VARCHAR)

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


Question: How many trains have 'Express' in their names?

Context: CREATE TABLE train (name VARCHAR)

SELECT COUNT(*) FROM train WHERE name LIKE "%Express%"


Question: Find the number and time of the train that goes from Chennai to Guruvayur.

Context: CREATE TABLE train (train_number VARCHAR, TIME VARCHAR, origin VARCHAR, destination VARCHAR)

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


Question: Find the number of trains starting from each origin.

Context: CREATE TABLE train (origin VARCHAR)

SELECT origin, COUNT(*) FROM train GROUP BY origin


Question: Find the name of the train whose route runs through greatest number of stations.

Context: CREATE TABLE route (train_id VARCHAR); CREATE TABLE train (name VARCHAR, id VARCHAR)

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


Question: Find the number of trains for each station, as well as the station network name and services.

Context: CREATE TABLE route (station_id VARCHAR); CREATE TABLE station (network_name VARCHAR, services VARCHAR, id VARCHAR)

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


Question: What is the average high temperature for each day of week?

Context: CREATE TABLE weekly_weather (day_of_week VARCHAR, high_temperature INTEGER)

SELECT AVG(high_temperature), day_of_week FROM weekly_weather GROUP BY day_of_week


Question: Give me the maximum low temperature and average precipitation at the Amersham station.

Context: CREATE TABLE weekly_weather (low_temperature INTEGER, precipitation INTEGER, station_id VARCHAR); CREATE TABLE station (id VARCHAR, network_name VARCHAR)

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"


Question: Find names and times of trains that run through stations for the local authority Chiltern.

Context: CREATE TABLE station (id VARCHAR, local_authority VARCHAR); CREATE TABLE route (station_id VARCHAR, train_id VARCHAR); CREATE TABLE train (name VARCHAR, time VARCHAR, id VARCHAR)

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"


Question: How many different services are provided by all stations?

Context: CREATE TABLE station (services VARCHAR)

SELECT COUNT(DISTINCT services) FROM station


Question: Find the id and local authority of the station with has the highest average high temperature.

Context: CREATE TABLE weekly_weather (station_id VARCHAR); CREATE TABLE station (id VARCHAR, local_authority VARCHAR)

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


Question: Find the id and local authority of the station whose maximum precipitation is higher than 50.

Context: CREATE TABLE weekly_weather (station_id VARCHAR, precipitation INTEGER); CREATE TABLE station (id VARCHAR, local_authority VARCHAR)

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


Question: show the lowest low temperature and highest wind speed in miles per hour.

Context: CREATE TABLE weekly_weather (low_temperature INTEGER, wind_speed_mph INTEGER)

SELECT MIN(low_temperature), MAX(wind_speed_mph) FROM weekly_weather


Question: Find the origins from which more than 1 train starts.

Context: CREATE TABLE train (origin VARCHAR)

SELECT origin FROM train GROUP BY origin HAVING COUNT(*) > 1


Question: Find the number of professors in accounting department.

Context: CREATE TABLE professor (dept_code VARCHAR); CREATE TABLE department (dept_code VARCHAR)

SELECT COUNT(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting"


Question: How many professors are teaching class with code ACCT-211?

Context: CREATE TABLE CLASS (PROF_NUM VARCHAR, CRS_CODE VARCHAR)

SELECT COUNT(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211"


Question: What is the first and last name of the professor in biology department?

Context: CREATE TABLE professor (dept_code VARCHAR, EMP_NUM VARCHAR); CREATE TABLE department (dept_code VARCHAR); CREATE TABLE employee (EMP_FNAME VARCHAR, EMP_LNAME VARCHAR, EMP_NUM VARCHAR)

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"


Question: What are the first names and date of birth of professors teaching course ACCT-211?

Context: CREATE TABLE CLASS (PROF_NUM VARCHAR); CREATE TABLE employee (EMP_FNAME VARCHAR, EMP_DOB VARCHAR, EMP_NUM VARCHAR)

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"


Question: How many classes are professor whose last name is Graztevski has?

Context: CREATE TABLE CLASS (PROF_NUM VARCHAR); CREATE TABLE employee (EMP_NUM VARCHAR, EMP_LNAME VARCHAR)

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


Question: What is the code of the school where the accounting department belongs to?

Context: CREATE TABLE department (school_code VARCHAR, dept_name VARCHAR)

SELECT school_code FROM department WHERE dept_name = "Accounting"


Question: How many credits does course CIS-220 have, and what its description?

Context: CREATE TABLE course (crs_credit VARCHAR, crs_description VARCHAR, crs_code VARCHAR)

SELECT crs_credit, crs_description FROM course WHERE crs_code = 'CIS-220'


Question: what is the address of history department?

Context: CREATE TABLE department (dept_address VARCHAR, dept_name VARCHAR)

SELECT dept_address FROM department WHERE dept_name = 'History'


Question: How many different locations does the school with code BUS has?

Context: CREATE TABLE department (dept_address VARCHAR, school_code VARCHAR)

SELECT COUNT(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'


Question: How many different locations does each school have?

Context: CREATE TABLE department (school_code VARCHAR, dept_address VARCHAR)

SELECT COUNT(DISTINCT dept_address), school_code FROM department GROUP BY school_code


Question: Find the description and credit for the course QM-261?

SELECT crs_credit, crs_description FROM course WHERE crs_code = 'QM-261'


Question: Find the number of departments in each school.

SELECT COUNT(DISTINCT dept_name), school_code FROM department GROUP BY school_code


Question: Find the number of different departments in each school whose number of different departments is less than 5.

SELECT COUNT(DISTINCT dept_name), school_code FROM department GROUP BY school_code HAVING COUNT(DISTINCT dept_name) < 5


Question: How many sections does each course has?

Context: CREATE TABLE CLASS (crs_code VARCHAR)

SELECT COUNT(*), crs_code FROM CLASS GROUP BY crs_code


Question: What is the total credit does each department offer?

Context: CREATE TABLE course (dept_code VARCHAR, crs_credit INTEGER)

SELECT SUM(crs_credit), dept_code FROM course GROUP BY dept_code


Question: Find the number of classes offered for all class rooms that held at least 2 classes.

Context: CREATE TABLE CLASS (class_room VARCHAR)

SELECT COUNT(*), class_room FROM CLASS GROUP BY class_room HAVING COUNT(*) >= 2


Question: Find the number of classes in each department.

Context: CREATE TABLE CLASS (crs_code VARCHAR); CREATE TABLE course (crs_code VARCHAR)

SELECT COUNT(*), dept_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code GROUP BY dept_code


Question: Find the number of classes in each school.

Context: CREATE TABLE department (school_code VARCHAR, dept_code VARCHAR); CREATE TABLE CLASS (crs_code VARCHAR); CREATE TABLE course (crs_code VARCHAR, dept_code VARCHAR)

SELECT COUNT(*), T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code


Question: What is the number of professors for different school?

Context: CREATE TABLE department (school_code VARCHAR, dept_code VARCHAR); CREATE TABLE professor (dept_code VARCHAR)

SELECT COUNT(*), T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code


Question: Find the count and code of the job has most employees.

Context: CREATE TABLE employee (emp_jobcode VARCHAR)

SELECT emp_jobcode, COUNT(*) FROM employee GROUP BY emp_jobcode ORDER BY COUNT(*) DESC LIMIT 1


Question: Which school has the smallest amount of professors?

SELECT T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code ORDER BY COUNT(*) LIMIT 1


Question: Find the number of professors with a Ph.D. degree in each department.

Context: CREATE TABLE professor (dept_code VARCHAR, prof_high_degree VARCHAR)

SELECT COUNT(*), dept_code FROM professor WHERE prof_high_degree = 'Ph.D.' GROUP BY dept_code


Question: Find the number of students for each department.

Context: CREATE TABLE student (dept_code VARCHAR)

SELECT COUNT(*), dept_code FROM student GROUP BY dept_code


Question: Find the total number of hours have done for all students in each department.

Context: CREATE TABLE student (dept_code VARCHAR, stu_hrs INTEGER)

SELECT SUM(stu_hrs), dept_code FROM student GROUP BY dept_code


Question: Find the max, average, and minimum gpa of all students in each department.

Context: CREATE TABLE student (dept_code VARCHAR, stu_gpa INTEGER)

SELECT MAX(stu_gpa), AVG(stu_gpa), MIN(stu_gpa), dept_code FROM student GROUP BY dept_code


Question: What is the name and the average gpa of department whose students have the highest average gpa?

Context: CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR); CREATE TABLE student (stu_gpa INTEGER, dept_code VARCHAR)

SELECT T2.dept_name, AVG(T1.stu_gpa) FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY AVG(T1.stu_gpa) DESC LIMIT 1


Question: how many schools exist in total?

Context: CREATE TABLE department (school_code VARCHAR)

SELECT COUNT(DISTINCT school_code) FROM department


Question: How many different classes are there?

Context: CREATE TABLE CLASS (class_code VARCHAR)

SELECT COUNT(DISTINCT class_code) FROM CLASS


Question: How many courses are offered?

Context: CREATE TABLE CLASS (crs_code VARCHAR)

SELECT COUNT(DISTINCT crs_code) FROM CLASS


Question: How many departments does the college has?

Context: CREATE TABLE department (dept_name VARCHAR)

SELECT COUNT(DISTINCT dept_name) FROM department


Question: How many courses are offered by the Computer Info. Systems department?

Context: CREATE TABLE course (dept_code VARCHAR); CREATE TABLE department (dept_code VARCHAR)

SELECT COUNT(*) FROM department AS T1 JOIN course AS T2 ON T1.dept_code = T2.dept_code WHERE dept_name = "Computer Info. Systems"


Question: How many sections does course ACCT-211 has?

Context: CREATE TABLE CLASS (class_section VARCHAR, crs_code VARCHAR)

SELECT COUNT(DISTINCT class_section) FROM CLASS WHERE crs_code = 'ACCT-211'


Question: Find the total credits of all classes offered by each department.

Context: CREATE TABLE CLASS (crs_code VARCHAR); CREATE TABLE course (dept_code VARCHAR, crs_credit INTEGER, crs_code VARCHAR)

SELECT SUM(T1.crs_credit), T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code


Question: Find the name of the department that offers the largest number of credits of all classes.

Context: CREATE TABLE CLASS (crs_code VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR); CREATE TABLE course (dept_code VARCHAR, crs_code VARCHAR, crs_credit INTEGER)

SELECT T3.dept_name FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T1.dept_code = T3.dept_code GROUP BY T1.dept_code ORDER BY SUM(T1.crs_credit) DESC LIMIT 1


Question: How many students enrolled in class ACCT-211?

Context: CREATE TABLE enroll (class_code VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR)

SELECT COUNT(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code WHERE T1.crs_code = 'ACCT-211'


Question: What is the first name of each student enrolled in class ACCT-211?

Context: CREATE TABLE student (stu_fname VARCHAR, stu_num VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE enroll (class_code VARCHAR, stu_num VARCHAR)

SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'


Question: What is the first name of students enrolled in class ACCT-211 and got grade C?

Context: CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE student (stu_fname VARCHAR, stu_num VARCHAR); CREATE TABLE enroll (class_code VARCHAR, stu_num VARCHAR, enroll_grade VARCHAR)

SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211' AND T2.enroll_grade = 'C'


Question: Find the total number of employees.

Context: CREATE TABLE employee (Id VARCHAR)


Question: How many professors do have a Ph.D. degree?

Context: CREATE TABLE professor (prof_high_degree VARCHAR)

SELECT COUNT(*) FROM professor WHERE prof_high_degree = 'Ph.D.'


Question: How many students are enrolled in the class taught by some professor from the accounting department?

Context: CREATE TABLE enroll (class_code VARCHAR); CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE course (crs_code VARCHAR, dept_code VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR)

SELECT COUNT(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code WHERE T4.dept_name = 'Accounting'


Question: What is the name of the department that has the largest number of students enrolled?

Context: CREATE TABLE enroll (class_code VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE course (dept_code VARCHAR, crs_code VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR)

SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY COUNT(*) DESC LIMIT 1


Question: list names of all departments ordered by their names.

SELECT dept_name FROM department ORDER BY dept_name


Question: List the codes of all courses that take place in room KLR209.

Context: CREATE TABLE CLASS (class_code VARCHAR, class_room VARCHAR)

SELECT class_code FROM CLASS WHERE class_room = 'KLR209'


Question: List the first name of all employees with job code PROF ordered by their date of birth.

Context: CREATE TABLE employee (emp_fname VARCHAR, emp_jobcode VARCHAR, emp_dob VARCHAR)

SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob


Question: Find the first names and offices of all professors sorted by alphabetical order of their first name.

Context: CREATE TABLE professor (prof_office VARCHAR, emp_num VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T2.emp_fname, T1.prof_office FROM professor AS T1 JOIN employee AS T2 ON T1.emp_num = T2.emp_num ORDER BY T2.emp_fname


Question: What is the first and last name of the oldest employee?

Context: CREATE TABLE employee (emp_fname VARCHAR, emp_lname VARCHAR, emp_dob VARCHAR)

SELECT emp_fname, emp_lname FROM employee ORDER BY emp_dob LIMIT 1


Question: What is the first, last name, gpa of the youngest one among students whose GPA is above 3?

Context: CREATE TABLE student (stu_fname VARCHAR, stu_lname VARCHAR, stu_gpa INTEGER, stu_dob VARCHAR)

SELECT stu_fname, stu_lname, stu_gpa FROM student WHERE stu_gpa > 3 ORDER BY stu_dob DESC LIMIT 1


Question: What is the first name of students who got grade C in any class?

Context: CREATE TABLE student (stu_num VARCHAR); CREATE TABLE enroll (stu_num VARCHAR)

SELECT DISTINCT stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num WHERE enroll_grade = 'C'


Question: What is the name of department where has the smallest number of professors?

Context: CREATE TABLE professor (dept_code VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR)

SELECT T2.dept_name FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY COUNT(*) LIMIT 1


Question: What is the name of department where has the largest number of professors with a Ph.D. degree?

Context: CREATE TABLE professor (dept_code VARCHAR, prof_high_degree VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR)

SELECT T2.dept_name, T1.dept_code FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE T1.prof_high_degree = 'Ph.D.' GROUP BY T1.dept_code ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the first names of the professors who do not teach a class.

Context: CREATE TABLE employee (emp_fname VARCHAR, emp_jobcode VARCHAR); CREATE TABLE CLASS (prof_num VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' EXCEPT SELECT T1.emp_fname FROM employee AS T1 JOIN CLASS AS T2 ON T1.emp_num = T2.prof_num


Question: What is the first names of the professors from the history department who do not teach a class.

Context: CREATE TABLE professor (emp_num VARCHAR, dept_code VARCHAR); CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE CLASS (prof_num VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T1.emp_fname FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T2.dept_code = T3.dept_code WHERE T3.dept_name = 'History' EXCEPT SELECT T4.emp_fname FROM employee AS T4 JOIN CLASS AS T5 ON T4.emp_num = T5.prof_num


Question: What is the last name and office of the professor from the history department?

Context: CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE employee (emp_lname VARCHAR, emp_num VARCHAR); CREATE TABLE professor (prof_office VARCHAR, emp_num VARCHAR, dept_code VARCHAR)

SELECT T1.emp_lname, T2.prof_office FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T2.dept_code = T3.dept_code WHERE T3.dept_name = 'History'


Question: What is department name and office for the professor whose last name is Heffington?

Context: CREATE TABLE employee (emp_num VARCHAR, emp_lname VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR); CREATE TABLE professor (prof_office VARCHAR, emp_num VARCHAR, dept_code VARCHAR)

SELECT T3.dept_name, T2.prof_office FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T2.dept_code = T3.dept_code WHERE T1.emp_lname = 'Heffington'


Question: Find the last name and hire date of the professor who is in office DRE 102.

Context: CREATE TABLE professor (emp_num VARCHAR, prof_office VARCHAR); CREATE TABLE employee (emp_lname VARCHAR, emp_hiredate VARCHAR, emp_num VARCHAR)

SELECT T1.emp_lname, T1.emp_hiredate FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num WHERE T2.prof_office = 'DRE 102'


Question: What is the code of the course which the student whose last name is Smithson took?

Context: CREATE TABLE student (stu_num VARCHAR, stu_lname VARCHAR); CREATE TABLE enroll (class_code VARCHAR, stu_num VARCHAR); CREATE TABLE CLASS (crs_code VARCHAR, class_code VARCHAR)

SELECT T1.crs_code FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T3.stu_num = T2.stu_num WHERE T3.stu_lname = 'Smithson'


Question: What are the description and credit of the course which the student whose last name is Smithson took?

Context: CREATE TABLE student (stu_num VARCHAR, stu_lname VARCHAR); CREATE TABLE course (crs_description VARCHAR, crs_credit VARCHAR, crs_code VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE enroll (class_code VARCHAR, stu_num VARCHAR)

SELECT T4.crs_description, T4.crs_credit FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T3.stu_num = T2.stu_num JOIN course AS T4 ON T4.crs_code = T1.crs_code WHERE T3.stu_lname = 'Smithson'


Question: How many professors who has a either Ph.D. or MA degree?

Context: CREATE TABLE professor (prof_high_degree VARCHAR)

SELECT COUNT(*) FROM professor WHERE prof_high_degree = 'Ph.D.' OR prof_high_degree = 'MA'


Question: How many professors who are from either Accounting or Biology department?

Context: CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE professor (dept_code VARCHAR)

SELECT COUNT(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE T2.dept_name = 'Accounting' OR T2.dept_name = 'Biology'


Question: Find the first name of the professor who is teaching two courses with code CIS-220 and QM-261.

Context: CREATE TABLE CLASS (prof_num VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T1.emp_fname FROM employee AS T1 JOIN CLASS AS T2 ON T1.emp_num = T2.prof_num WHERE crs_code = 'CIS-220' INTERSECT SELECT T1.emp_fname FROM employee AS T1 JOIN CLASS AS T2 ON T1.emp_num = T2.prof_num WHERE crs_code = 'QM-261'


Question: Find the first name of student who is taking classes from accounting and Computer Info. Systems departments

Context: CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE enroll (stu_num VARCHAR, class_code VARCHAR); CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE course (crs_code VARCHAR, dept_code VARCHAR); CREATE TABLE student (stu_fname VARCHAR, stu_num VARCHAR)

SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T2.class_code = T3.class_code JOIN course AS T4 ON T3.crs_code = T4.crs_code JOIN department AS T5 ON T5.dept_code = T4.dept_code WHERE T5.dept_name = 'Accounting' INTERSECT SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T2.class_code = T3.class_code JOIN course AS T4 ON T3.crs_code = T4.crs_code JOIN department AS T5 ON T5.dept_code = T4.dept_code WHERE T5.dept_name = 'Computer Info. Systems'


Question: What is the average gpa of the students enrolled in the course with code ACCT-211?

Context: CREATE TABLE enroll (stu_num VARCHAR, class_code VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE student (stu_gpa INTEGER, stu_num VARCHAR)

SELECT AVG(T2.stu_gpa) FROM enroll AS T1 JOIN student AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T1.class_code = T3.class_code WHERE T3.crs_code = 'ACCT-211'


Question: What is the first name, gpa and phone number of the top 5 students with highest gpa?

Context: CREATE TABLE student (stu_gpa VARCHAR, stu_phone VARCHAR, stu_fname VARCHAR)

SELECT stu_gpa, stu_phone, stu_fname FROM student ORDER BY stu_gpa DESC LIMIT 5


Question: What is the department name of the students with lowest gpa belongs to?

Context: CREATE TABLE student (dept_code VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR)

SELECT T2.dept_name FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code ORDER BY stu_gpa LIMIT 1


Question: Find the first name and gpa of the students whose gpa is lower than the average gpa of all students.

Context: CREATE TABLE student (stu_fname VARCHAR, stu_gpa INTEGER)

SELECT stu_fname, stu_gpa FROM student WHERE stu_gpa < (SELECT AVG(stu_gpa) FROM student)


Question: Find the name and address of the department that has the highest number of students.

Context: CREATE TABLE student (dept_code VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_address VARCHAR, dept_code VARCHAR)

SELECT T2.dept_name, T2.dept_address FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name, address, number of students in the departments that have the top 3 highest number of students.

SELECT T2.dept_name, T2.dept_address, COUNT(*) FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY COUNT(*) DESC LIMIT 3


Question: Find the first name and office of the professor who is in the history department and has a Ph.D. degree.

Context: CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE professor (prof_office VARCHAR, emp_num VARCHAR, dept_code VARCHAR, prof_high_degree VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T1.emp_fname, T2.prof_office FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T3.dept_code = T2.dept_code WHERE T3.dept_name = 'History' AND T2.prof_high_degree = 'Ph.D.'


Question: Find the first names of all instructors who have taught some course and the course code.

Context: CREATE TABLE CLASS (crs_code VARCHAR, prof_num VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T2.emp_fname, T1.crs_code FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num


Question: Find the first names of all instructors who have taught some course and the course description.

Context: CREATE TABLE course (crs_description VARCHAR, crs_code VARCHAR); CREATE TABLE CLASS (prof_num VARCHAR, crs_code VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T2.emp_fname, T3.crs_description FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code


Question: Find the first names and offices of all instructors who have taught some course and also find the course description.

Context: CREATE TABLE professor (prof_office VARCHAR, emp_num VARCHAR); CREATE TABLE course (crs_description VARCHAR, crs_code VARCHAR); CREATE TABLE CLASS (prof_num VARCHAR, crs_code VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T2.emp_fname, T4.prof_office, T3.crs_description FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN professor AS T4 ON T2.emp_num = T4.emp_num


Question: Find the first names and offices of all instructors who have taught some course and the course description and the department name.

Context: CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR); CREATE TABLE course (crs_description VARCHAR, crs_code VARCHAR); CREATE TABLE CLASS (prof_num VARCHAR, crs_code VARCHAR); CREATE TABLE professor (prof_office VARCHAR, emp_num VARCHAR, dept_code VARCHAR)

SELECT T2.emp_fname, T4.prof_office, T3.crs_description, T5.dept_name FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN professor AS T4 ON T2.emp_num = T4.emp_num JOIN department AS T5 ON T4.dept_code = T5.dept_code


Question: Find names of all students who took some course and the course description.

Context: CREATE TABLE enroll (stu_num VARCHAR, class_code VARCHAR); CREATE TABLE course (crs_description VARCHAR, crs_code VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE student (stu_fname VARCHAR, stu_lname VARCHAR, stu_num VARCHAR)

SELECT T1.stu_fname, T1.stu_lname, T4.crs_description FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T2.class_code = T3.class_code JOIN course AS T4 ON T3.crs_code = T4.crs_code


Question: Find names of all students who took some course and got A or C.

Context: CREATE TABLE enroll (stu_num VARCHAR, enroll_grade VARCHAR); CREATE TABLE student (stu_fname VARCHAR, stu_lname VARCHAR, stu_num VARCHAR)

SELECT T1.stu_fname, T1.stu_lname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num WHERE T2.enroll_grade = 'C' OR T2.enroll_grade = 'A'


Question: Find the first names of all professors in the Accounting department who is teaching some course and the class room.

Context: CREATE TABLE CLASS (class_room VARCHAR, prof_num VARCHAR); CREATE TABLE professor (emp_num VARCHAR, dept_code VARCHAR); CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR)

SELECT T2.emp_fname, T1.class_room FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN professor AS T3 ON T2.emp_num = T3.emp_num JOIN department AS T4 ON T4.dept_code = T3.dept_code WHERE T4.dept_name = 'Accounting'


Question: Find the first names and degree of all professors who are teaching some class in Computer Info. Systems department.

Context: CREATE TABLE professor (prof_high_degree VARCHAR, emp_num VARCHAR, dept_code VARCHAR); CREATE TABLE department (dept_code VARCHAR, dept_name VARCHAR); CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR); CREATE TABLE CLASS (prof_num VARCHAR)

SELECT DISTINCT T2.emp_fname, T3.prof_high_degree FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN professor AS T3 ON T2.emp_num = T3.emp_num JOIN department AS T4 ON T4.dept_code = T3.dept_code WHERE T4.dept_name = 'Computer Info. Systems'


Question: What is the last name of the student who got a grade A in the class with code 10018.

Context: CREATE TABLE enroll (stu_num VARCHAR, enroll_grade VARCHAR, class_code VARCHAR); CREATE TABLE student (stu_lname VARCHAR, stu_num VARCHAR)

SELECT T1.stu_lname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num WHERE T2.enroll_grade = 'A' AND T2.class_code = 10018


Question: Find the first name and office of history professor who did not get a Ph.D. degree.

SELECT T2.emp_fname, T1.prof_office FROM professor AS T1 JOIN employee AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T1.dept_code = T3.dept_code WHERE T3.dept_name = 'History' AND T1.prof_high_degree <> 'Ph.D.'


Question: Find the first names of professors who are teaching more than one class.

Context: CREATE TABLE employee (emp_fname VARCHAR, emp_num VARCHAR); CREATE TABLE CLASS (prof_num VARCHAR)

SELECT T2.emp_fname FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num GROUP BY T1.prof_num HAVING COUNT(*) > 1


Question: Find the first names of students who took exactly one class.

Context: CREATE TABLE enroll (stu_num VARCHAR); CREATE TABLE student (stu_fname VARCHAR, stu_num VARCHAR)

SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num GROUP BY T2.stu_num HAVING COUNT(*) = 1


Question: Find the name of department that offers the class whose description has the word "Statistics".

Context: CREATE TABLE course (dept_code VARCHAR, crs_description VARCHAR); CREATE TABLE department (dept_name VARCHAR, dept_code VARCHAR)

SELECT T2.dept_name FROM course AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE T1.crs_description LIKE '%Statistics%'


Question: What is the first name of the student whose last name starting with the letter S and is taking ACCT-211 class?

Context: CREATE TABLE enroll (stu_num VARCHAR, class_code VARCHAR); CREATE TABLE CLASS (class_code VARCHAR, crs_code VARCHAR); CREATE TABLE student (stu_fname VARCHAR, stu_num VARCHAR, stu_lname VARCHAR)

SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T2.class_code = T3.class_code WHERE T3.crs_code = 'ACCT-211' AND T1.stu_lname LIKE 'S%'


Question: How many clubs are there?

Context: CREATE TABLE club (Id VARCHAR)


Question: List the distinct region of clubs in ascending alphabetical order.

Context: CREATE TABLE club (Region VARCHAR)

SELECT DISTINCT Region FROM club ORDER BY Region


Question: What is the average number of gold medals for clubs?

Context: CREATE TABLE club_rank (Gold INTEGER)


Question: What are the types and countries of competitions?

Context: CREATE TABLE competition (Competition_type VARCHAR, Country VARCHAR)

SELECT Competition_type, Country FROM competition


Question: What are the distinct years in which the competitions type is not "Tournament"?

Context: CREATE TABLE competition (YEAR VARCHAR, Competition_type VARCHAR)

SELECT DISTINCT YEAR FROM competition WHERE Competition_type <> "Tournament"


Question: What are the maximum and minimum number of silver medals for clubs.

Context: CREATE TABLE club_rank (Silver INTEGER)

SELECT MAX(Silver), MIN(Silver) FROM club_rank


Question: How many clubs have total medals less than 10?

Context: CREATE TABLE club_rank (Total INTEGER)

SELECT COUNT(*) FROM club_rank WHERE Total < 10


Question: List all club names in ascending order of start year.

Context: CREATE TABLE club (name VARCHAR, Start_year VARCHAR)

SELECT name FROM club ORDER BY Start_year


Question: List all club names in descending alphabetical order.

Context: CREATE TABLE club (name VARCHAR)

SELECT name FROM club ORDER BY name DESC


Question: Please show the names and the players of clubs.

Context: CREATE TABLE club (name VARCHAR, Club_ID VARCHAR); CREATE TABLE player (Player_id VARCHAR, Club_ID VARCHAR)

SELECT T1.name, T2.Player_id FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID


Question: Show the names of clubs that have players with position "Right Wing".

Context: CREATE TABLE club (name VARCHAR, Club_ID VARCHAR); CREATE TABLE player (Club_ID VARCHAR, Position VARCHAR)

SELECT T1.name FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID WHERE T2.Position = "Right Wing"


Question: What is the average points of players from club with name "AIB".

Context: CREATE TABLE player (Points INTEGER, Club_ID VARCHAR); CREATE TABLE club (Club_ID VARCHAR, name VARCHAR)

SELECT AVG(T2.Points) FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID WHERE T1.name = "AIB"


Question: List the position of players and the average number of points of players of each position.

Context: CREATE TABLE player (POSITION VARCHAR, Points INTEGER)

SELECT POSITION, AVG(Points) FROM player GROUP BY POSITION


Question: List the position of players with average number of points scored by players of that position bigger than 20.

Context: CREATE TABLE player (POSITION VARCHAR, name VARCHAR, Points INTEGER)

SELECT POSITION FROM player GROUP BY name HAVING AVG(Points) >= 20


Question: List the types of competition and the number of competitions of each type.

Context: CREATE TABLE competition (Competition_type VARCHAR)

SELECT Competition_type, COUNT(*) FROM competition GROUP BY Competition_type


Question: List the most common type of competition.

SELECT Competition_type FROM competition GROUP BY Competition_type ORDER BY COUNT(*) DESC LIMIT 1


Question: List the types of competition that have at most five competitions of that type.

SELECT Competition_type FROM competition GROUP BY Competition_type HAVING COUNT(*) <= 5


Question: List the names of clubs that do not have any players.

Context: CREATE TABLE player (name VARCHAR, Club_ID VARCHAR); CREATE TABLE CLub (name VARCHAR, Club_ID VARCHAR)

SELECT name FROM CLub WHERE NOT Club_ID IN (SELECT Club_ID FROM player)


Question: What are the positions with both players having more than 20 points and less than 10 points.

SELECT POSITION FROM player WHERE Points > 20 INTERSECT SELECT POSITION FROM player WHERE Points < 10


Question: Show total points of all players.

Context: CREATE TABLE player (Points INTEGER)


Question: how many different positions are there?

Context: CREATE TABLE player (POSITION VARCHAR)

SELECT COUNT(DISTINCT POSITION) FROM player


Question: what are the name of players who get more than the average points.

Context: CREATE TABLE player (name VARCHAR, points INTEGER)

SELECT name FROM player WHERE points > (SELECT AVG(points) FROM player)


Question: find the number of players whose points are lower than 30 in each position.

Context: CREATE TABLE player (POSITION VARCHAR, points INTEGER)

SELECT COUNT(*), POSITION FROM player WHERE points < 30 GROUP BY POSITION


Question: which country did participated in the most number of Tournament competitions?

Context: CREATE TABLE competition (country VARCHAR, competition_type VARCHAR)

SELECT country FROM competition WHERE competition_type = 'Tournament' GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1


Question: which countries did participated in both Friendly and Tournament type competitions.

SELECT country FROM competition WHERE competition_type = 'Friendly' INTERSECT SELECT country FROM competition WHERE competition_type = 'Tournament'


Question: Find the countries that have never participated in any competition with Friendly type.

SELECT country FROM competition EXCEPT SELECT country FROM competition WHERE competition_type = 'Friendly'


Question: How many furniture components are there in total?

Context: CREATE TABLE furniture (num_of_component INTEGER)

SELECT SUM(num_of_component) FROM furniture


Question: Return the name and id of the furniture with the highest market rate.

Context: CREATE TABLE furniture (name VARCHAR, furniture_id VARCHAR, market_rate VARCHAR)

SELECT name, furniture_id FROM furniture ORDER BY market_rate DESC LIMIT 1


Question: find the total market rate of the furnitures that have the top 2 market shares.

Context: CREATE TABLE furniture (market_rate INTEGER)

SELECT SUM(market_rate) FROM furniture ORDER BY market_rate DESC LIMIT 2


Question: Find the component amounts and names of all furnitures that have more than 10 components.

Context: CREATE TABLE furniture (Num_of_Component INTEGER, name VARCHAR)

SELECT Num_of_Component, name FROM furniture WHERE Num_of_Component > 10


Question: Find the name and component amount of the least popular furniture.

Context: CREATE TABLE furniture (name VARCHAR, Num_of_Component VARCHAR, market_rate VARCHAR)

SELECT name, Num_of_Component FROM furniture ORDER BY market_rate LIMIT 1


Question: Find the names of furnitures whose prices are lower than the highest price.

Context: CREATE TABLE furniture_manufacte (Furniture_ID VARCHAR, Price_in_Dollar INTEGER); CREATE TABLE furniture (name VARCHAR, Furniture_ID VARCHAR); CREATE TABLE furniture_manufacte (Price_in_Dollar INTEGER)

SELECT t1.name FROM furniture AS t1 JOIN furniture_manufacte AS t2 ON t1.Furniture_ID = t2.Furniture_ID WHERE t2.Price_in_Dollar < (SELECT MAX(Price_in_Dollar) FROM furniture_manufacte)


Question: Which manufacturer has the most number of shops? List its name and year of opening.

Context: CREATE TABLE manufacturer (open_year VARCHAR, name VARCHAR, num_of_shops VARCHAR)

SELECT open_year, name FROM manufacturer ORDER BY num_of_shops DESC LIMIT 1


Question: Find the average number of factories for the manufacturers that have more than 20 shops.

Context: CREATE TABLE manufacturer (Num_of_Factories INTEGER, num_of_shops INTEGER)

SELECT AVG(Num_of_Factories) FROM manufacturer WHERE num_of_shops > 20


Question: List all manufacturer names and ids ordered by their opening year.

Context: CREATE TABLE manufacturer (name VARCHAR, manufacturer_id VARCHAR, open_year VARCHAR)

SELECT name, manufacturer_id FROM manufacturer ORDER BY open_year


Question: Give me the name and year of opening of the manufacturers that have either less than 10 factories or more than 10 shops.

Context: CREATE TABLE manufacturer (name VARCHAR, open_year VARCHAR, num_of_shops VARCHAR, Num_of_Factories VARCHAR)

SELECT name, open_year FROM manufacturer WHERE num_of_shops > 10 OR Num_of_Factories < 10


Question: what is the average number of factories and maximum number of shops for manufacturers that opened before 1990.

Context: CREATE TABLE manufacturer (num_of_shops INTEGER, Num_of_Factories INTEGER, open_year INTEGER)

SELECT MAX(num_of_shops), AVG(Num_of_Factories) FROM manufacturer WHERE open_year < 1990


Question: Find the id and number of shops for the company that produces the most expensive furniture.

Context: CREATE TABLE manufacturer (manufacturer_id VARCHAR, num_of_shops VARCHAR); CREATE TABLE furniture_manufacte (manufacturer_id VARCHAR, Price_in_Dollar VARCHAR)

SELECT t1.manufacturer_id, t1.num_of_shops FROM manufacturer AS t1 JOIN furniture_manufacte AS t2 ON t1.manufacturer_id = t2.manufacturer_id ORDER BY t2.Price_in_Dollar DESC LIMIT 1


Question: Find the number of funiture types produced by each manufacturer as well as the company names.

Context: CREATE TABLE furniture_manufacte (manufacturer_id VARCHAR); CREATE TABLE manufacturer (name VARCHAR, manufacturer_id VARCHAR)

SELECT COUNT(*), t1.name FROM manufacturer AS t1 JOIN furniture_manufacte AS t2 ON t1.manufacturer_id = t2.manufacturer_id GROUP BY t1.manufacturer_id


Question: Give me the names and prices of furnitures which some companies are manufacturing.

Context: CREATE TABLE furniture_manufacte (price_in_dollar VARCHAR, Furniture_ID VARCHAR); CREATE TABLE furniture (name VARCHAR, Furniture_ID VARCHAR)

SELECT t1.name, t2.price_in_dollar FROM furniture AS t1 JOIN furniture_manufacte AS t2 ON t1.Furniture_ID = t2.Furniture_ID


Question: Find the market shares and names of furnitures which no any company is producing in our records.

Context: CREATE TABLE furniture (Market_Rate VARCHAR, name VARCHAR, Furniture_ID VARCHAR); CREATE TABLE furniture_manufacte (Market_Rate VARCHAR, name VARCHAR, Furniture_ID VARCHAR)

SELECT Market_Rate, name FROM furniture WHERE NOT Furniture_ID IN (SELECT Furniture_ID FROM furniture_manufacte)


Question: Find the name of the company that produces both furnitures with less than 6 components and furnitures with more than 10 components.

Context: CREATE TABLE furniture_manufacte (Furniture_ID VARCHAR, manufacturer_id VARCHAR); CREATE TABLE manufacturer (name VARCHAR, manufacturer_id VARCHAR); CREATE TABLE furniture (Furniture_ID VARCHAR, num_of_component INTEGER)

SELECT t3.name FROM furniture AS t1 JOIN furniture_manufacte AS t2 ON t1.Furniture_ID = t2.Furniture_ID JOIN manufacturer AS t3 ON t2.manufacturer_id = t3.manufacturer_id WHERE t1.num_of_component < 6 INTERSECT SELECT t3.name FROM furniture AS t1 JOIN furniture_manufacte AS t2 ON t1.Furniture_ID = t2.Furniture_ID JOIN manufacturer AS t3 ON t2.manufacturer_id = t3.manufacturer_id WHERE t1.num_of_component > 10


Question: Display the first name and department name for each employee.

Context: CREATE TABLE departments (department_name VARCHAR, department_id VARCHAR); CREATE TABLE employees (first_name VARCHAR, department_id VARCHAR)

SELECT T1.first_name, T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id


Question: List the full name (first and last name), and salary for those employees who earn below 6000.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, salary INTEGER)

SELECT first_name, last_name, salary FROM employees WHERE salary < 6000


Question: Display the first name, and department number for all employees whose last name is "McEwen".

Context: CREATE TABLE employees (first_name VARCHAR, department_id VARCHAR, last_name VARCHAR)

SELECT first_name, department_id FROM employees WHERE last_name = 'McEwen'


Question: Return all the information for all employees without any department number.

Context: CREATE TABLE employees (department_id VARCHAR)

SELECT * FROM employees WHERE department_id = "null"


Question: Display all the information about the department Marketing.

Context: CREATE TABLE departments (department_name VARCHAR)

SELECT * FROM departments WHERE department_name = 'Marketing'


Question: when is the hire date for those employees whose first name does not containing the letter M?

Context: CREATE TABLE employees (hire_date VARCHAR, first_name VARCHAR)

SELECT hire_date FROM employees WHERE NOT first_name LIKE '%M%'


Question: display the full name (first and last), hire date, salary, and department number for those employees whose first name does not containing the letter M.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, hire_date VARCHAR, salary VARCHAR, department_id VARCHAR)

SELECT first_name, last_name, hire_date, salary, department_id FROM employees WHERE NOT first_name LIKE '%M%'


Question: display the full name (first and last), hire date, salary, and department number for those employees whose first name does not containing the letter M and make the result set in ascending order by department number.

SELECT first_name, last_name, hire_date, salary, department_id FROM employees WHERE NOT first_name LIKE '%M%' ORDER BY department_id


Question: what is the phone number of employees whose salary is in the range of 8000 and 12000?

Context: CREATE TABLE employees (phone_number VARCHAR, salary INTEGER)

SELECT phone_number FROM employees WHERE salary BETWEEN 8000 AND 12000


Question: display all the information of employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40.

Context: CREATE TABLE employees (department_id VARCHAR, salary VARCHAR, commission_pct VARCHAR)

SELECT * FROM employees WHERE salary BETWEEN 8000 AND 12000 AND commission_pct <> "null" OR department_id <> 40


Question: What are the full name (first and last name) and salary for all employees who does not have any value for commission?

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, salary VARCHAR, commission_pct VARCHAR)

SELECT first_name, last_name, salary FROM employees WHERE commission_pct = "null"


Question: Display the first and last name, and salary for those employees whose first name is ending with the letter m.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, salary VARCHAR)

SELECT first_name, last_name, salary FROM employees WHERE first_name LIKE '%m'


Question: Find job id and date of hire for those employees who was hired between November 5th, 2007 and July 5th, 2009.

Context: CREATE TABLE employees (job_id VARCHAR, hire_date INTEGER)

SELECT job_id, hire_date FROM employees WHERE hire_date BETWEEN '2007-11-05' AND '2009-07-05'


Question: What are the first and last name for those employees who works either in department 70 or 90?

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, department_id VARCHAR)

SELECT first_name, last_name FROM employees WHERE department_id = 70 OR department_id = 90


Question: Find the salary and manager number for those employees who is working under a manager.

Context: CREATE TABLE employees (salary VARCHAR, manager_id VARCHAR)

SELECT salary, manager_id FROM employees WHERE manager_id <> "null"


Question: display all the details from Employees table for those employees who was hired before 2002-06-21.

Context: CREATE TABLE employees (hire_date INTEGER)

SELECT * FROM employees WHERE hire_date < '2002-06-21'


Question: display all the information for all employees who have the letters D or S in their first name and also arrange the result in descending order by salary.

Context: CREATE TABLE employees (salary VARCHAR, first_name VARCHAR)

SELECT * FROM employees WHERE first_name LIKE '%D%' OR first_name LIKE '%S%' ORDER BY salary DESC


Question: display those employees who joined after 7th September, 1987.

SELECT * FROM employees WHERE hire_date > '1987-09-07'


Question: display the job title of jobs which minimum salary is greater than 9000.

Context: CREATE TABLE jobs (job_title VARCHAR, min_salary INTEGER)

SELECT job_title FROM jobs WHERE min_salary > 9000


Question: display job Title, the difference between minimum and maximum salaries for those jobs which max salary within the range 12000 to 18000.

Context: CREATE TABLE jobs (job_title VARCHAR, max_salary INTEGER, min_salary VARCHAR)

SELECT job_title, max_salary - min_salary FROM jobs WHERE max_salary BETWEEN 12000 AND 18000


Question: display the emails of the employees who have no commission percentage and salary within the range 7000 to 12000 and works in that department which number is 50.

Context: CREATE TABLE employees (email VARCHAR, department_id VARCHAR, commission_pct VARCHAR, salary VARCHAR)

SELECT email FROM employees WHERE commission_pct = "null" AND salary BETWEEN 7000 AND 12000 AND department_id = 50


Question: display the employee ID for each employee and the date on which he ended his previous job.

Context: CREATE TABLE job_history (employee_id VARCHAR, end_date INTEGER)

SELECT employee_id, MAX(end_date) FROM job_history GROUP BY employee_id


Question: display those departments where more than ten employees work who got a commission percentage.

Context: CREATE TABLE employees (department_id VARCHAR, commission_pct VARCHAR)

SELECT department_id FROM employees GROUP BY department_id HAVING COUNT(commission_pct) > 10


Question: Find the ids of the departments where any manager is managing 4 or more employees.

Context: CREATE TABLE employees (department_id VARCHAR, manager_id VARCHAR, employee_id VARCHAR)

SELECT DISTINCT department_id FROM employees GROUP BY department_id, manager_id HAVING COUNT(employee_id) >= 4


Question: display the average salary of employees for each department who gets a commission percentage.

Context: CREATE TABLE employees (department_id VARCHAR, salary INTEGER, commission_pct VARCHAR)

SELECT department_id, AVG(salary) FROM employees WHERE commission_pct <> "null" GROUP BY department_id


Question: display the country ID and number of cities for each country.

Context: CREATE TABLE locations (country_id VARCHAR)

SELECT country_id, COUNT(*) FROM locations GROUP BY country_id


Question: display job ID for those jobs that were done by two or more for more than 300 days.

Context: CREATE TABLE job_history (job_id VARCHAR, end_date VARCHAR, start_date VARCHAR)

SELECT job_id FROM job_history WHERE end_date - start_date > 300 GROUP BY job_id HAVING COUNT(*) >= 2


Question: display the ID for those employees who did two or more jobs in the past.

Context: CREATE TABLE job_history (employee_id VARCHAR)

SELECT employee_id FROM job_history GROUP BY employee_id HAVING COUNT(*) >= 2


Question: Find employee with ID and name of the country presently where (s)he is working.

Context: CREATE TABLE countries (country_name VARCHAR, country_id VARCHAR); CREATE TABLE departments (department_id VARCHAR, location_id VARCHAR); CREATE TABLE locations (location_id VARCHAR, country_id VARCHAR); CREATE TABLE employees (employee_id VARCHAR, department_id VARCHAR)

SELECT T1.employee_id, T4.country_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id JOIN countries AS T4 ON T3.country_id = T4.country_id


Question: display the department name and number of employees in each of the department.

Context: CREATE TABLE departments (department_name VARCHAR, department_id VARCHAR); CREATE TABLE employees (department_id VARCHAR)

SELECT T2.department_name, COUNT(*) FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id GROUP BY T2.department_name


Question: Can you return all detailed info of jobs which was done by any of the employees who is presently earning a salary on and above 12000?

Context: CREATE TABLE job_history (employee_id VARCHAR); CREATE TABLE employees (employee_id VARCHAR, salary VARCHAR)

SELECT * FROM job_history AS T1 JOIN employees AS T2 ON T1.employee_id = T2.employee_id WHERE T2.salary >= 12000


Question: display job title and average salary of employees.

Context: CREATE TABLE jobs (job_title VARCHAR, job_id VARCHAR); CREATE TABLE employees (job_id VARCHAR)

SELECT job_title, AVG(salary) FROM employees AS T1 JOIN jobs AS T2 ON T1.job_id = T2.job_id GROUP BY T2.job_title


Question: What is the full name ( first name and last name ) for those employees who gets more salary than the employee whose id is 163?

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, salary INTEGER, employee_id VARCHAR)

SELECT first_name, last_name FROM employees WHERE salary > (SELECT salary FROM employees WHERE employee_id = 163)


Question: return the smallest salary for every departments.

Context: CREATE TABLE employees (department_id VARCHAR, salary INTEGER)

SELECT MIN(salary), department_id FROM employees GROUP BY department_id


Question: Find the first name and last name and department id for those employees who earn such amount of salary which is the smallest salary of any of the departments.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, department_id VARCHAR, salary INTEGER)

SELECT first_name, last_name, department_id FROM employees WHERE salary IN (SELECT MIN(salary) FROM employees GROUP BY department_id)


Question: Find the employee id for all employees who earn more than the average salary.

Context: CREATE TABLE employees (employee_id VARCHAR, salary INTEGER)

SELECT employee_id FROM employees WHERE salary > (SELECT AVG(salary) FROM employees)


Question: display the employee id and salary of all employees who report to Payam (first name).

Context: CREATE TABLE employees (employee_id VARCHAR, salary VARCHAR, manager_id VARCHAR, first_name VARCHAR)

SELECT employee_id, salary FROM employees WHERE manager_id = (SELECT employee_id FROM employees WHERE first_name = 'Payam')


Question: find the name of all departments that do actually have one or more employees assigned to them.

SELECT DISTINCT T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id


Question: get the details of employees who manage a department.

Context: CREATE TABLE departments (department_id VARCHAR, manager_id VARCHAR); CREATE TABLE employees (department_id VARCHAR, employee_id VARCHAR)

SELECT DISTINCT * FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id WHERE T1.employee_id = T2.manager_id


Question: Find the job ID for those jobs which average salary is above 8000.

Context: CREATE TABLE employees (job_id VARCHAR, salary INTEGER)

SELECT job_id FROM employees GROUP BY job_id HAVING AVG(salary) > 8000


Question: display the employee ID and job name for all those jobs in department 80.

Context: CREATE TABLE jobs (job_title VARCHAR, job_id VARCHAR); CREATE TABLE employees (employee_id VARCHAR, job_id VARCHAR, department_id VARCHAR)

SELECT T1.employee_id, T2.job_title FROM employees AS T1 JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.department_id = 80


Question: What is the first name and job id for all employees in the Finance department?

Context: CREATE TABLE departments (department_id VARCHAR, department_name VARCHAR); CREATE TABLE employees (first_name VARCHAR, job_id VARCHAR, department_id VARCHAR)

SELECT T1.first_name, T1.job_id FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id WHERE T2.department_name = 'Finance'


Question: display all the information of the employees whose salary if within the range of smallest salary and 2500.

Context: CREATE TABLE employees (salary INTEGER)

SELECT * FROM employees WHERE salary BETWEEN (SELECT MIN(salary) FROM employees) AND 2500


Question: Find the ids of the employees who does not work in those departments where some employees works whose manager id within the range 100 and 200.

Context: CREATE TABLE departments (department_id VARCHAR, manager_id INTEGER); CREATE TABLE employees (department_id VARCHAR, manager_id INTEGER)

SELECT * FROM employees WHERE NOT department_id IN (SELECT department_id FROM departments WHERE manager_id BETWEEN 100 AND 200)


Question: display the employee name ( first name and last name ) and hire date for all employees in the same department as Clara.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, hire_date VARCHAR, department_id VARCHAR)

SELECT first_name, last_name, hire_date FROM employees WHERE department_id = (SELECT department_id FROM employees WHERE first_name = "Clara")


Question: display the employee name ( first name and last name ) and hire date for all employees in the same department as Clara excluding Clara.

SELECT first_name, last_name, hire_date FROM employees WHERE department_id = (SELECT department_id FROM employees WHERE first_name = "Clara") AND first_name <> "Clara"


Question: display the employee number and name( first name and last name ) for all employees who work in a department with any employee whose name contains a ’T’.

Context: CREATE TABLE employees (employee_id VARCHAR, first_name VARCHAR, last_name VARCHAR, department_id VARCHAR)

SELECT employee_id, first_name, last_name FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE first_name LIKE '%T%')


Question: display the employee number, name( first name and last name ), and salary for all employees who earn more than the average salary and who work in a department with any employee with a 'J' in their first name.

Context: CREATE TABLE employees (employee_id VARCHAR, first_name VARCHAR, last_name VARCHAR, salary INTEGER, department_id VARCHAR)

SELECT employee_id, first_name, last_name, salary FROM employees WHERE salary > (SELECT AVG(salary) FROM employees) AND department_id IN (SELECT department_id FROM employees WHERE first_name LIKE '%J%')


Question: display the employee number and job id for all employees whose salary is smaller than any salary of those employees whose job title is MK_MAN.

Context: CREATE TABLE employees (employee_id VARCHAR, job_id VARCHAR, salary INTEGER)

SELECT employee_id, job_id FROM employees WHERE salary < (SELECT MIN(salary) FROM employees WHERE job_id = 'MK_MAN')


Question: display the employee number, name( first name and last name ) and job title for all employees whose salary is more than any salary of those employees whose job title is PU_MAN.

Context: CREATE TABLE employees (employee_id VARCHAR, first_name VARCHAR, last_name VARCHAR, job_id VARCHAR, salary INTEGER)

SELECT employee_id, first_name, last_name, job_id FROM employees WHERE salary > (SELECT MAX(salary) FROM employees WHERE job_id = 'PU_MAN')


Question: display the department id and the total salary for those departments which contains at least two employees.

SELECT department_id, SUM(salary) FROM employees GROUP BY department_id HAVING COUNT(*) >= 2


Question: display all the information of those employees who did not have any job in the past.

Context: CREATE TABLE job_history (employee_id VARCHAR); CREATE TABLE employees (employee_id VARCHAR)

SELECT * FROM employees WHERE NOT employee_id IN (SELECT employee_id FROM job_history)


Question: display the department ID, full name (first and last name), salary for those employees who is highest salary in every department.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, salary INTEGER, department_id VARCHAR)

SELECT first_name, last_name, salary, department_id, MAX(salary) FROM employees GROUP BY department_id


Question: display the first and last name, department, city, and state province for each employee.

Context: CREATE TABLE departments (department_name VARCHAR, department_id VARCHAR, location_id VARCHAR); CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, department_id VARCHAR); CREATE TABLE locations (city VARCHAR, state_province VARCHAR, location_id VARCHAR)

SELECT T1.first_name, T1.last_name, T2.department_name, T3.city, T3.state_province FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id


Question: display those employees who contain a letter z to their first name and also display their last name, city.

Context: CREATE TABLE locations (city VARCHAR, location_id VARCHAR); CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, department_id VARCHAR); CREATE TABLE departments (department_id VARCHAR, location_id VARCHAR)

SELECT T1.first_name, T1.last_name, T3.city FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id WHERE T1.first_name LIKE '%z%'


Question: display the department name, city, and state province for each department.

Context: CREATE TABLE locations (city VARCHAR, state_province VARCHAR, location_id VARCHAR); CREATE TABLE departments (department_name VARCHAR, location_id VARCHAR)

SELECT T1.department_name, T2.city, T2.state_province FROM departments AS T1 JOIN locations AS T2 ON T2.location_id = T1.location_id


Question: display the full name (first and last name ) of employee with ID and name of the country presently where (s)he is working.

Context: CREATE TABLE countries (country_name VARCHAR, country_id VARCHAR); CREATE TABLE departments (department_id VARCHAR, location_id VARCHAR); CREATE TABLE locations (location_id VARCHAR, country_id VARCHAR); CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, employee_id VARCHAR, department_id VARCHAR)

SELECT T1.first_name, T1.last_name, T1.employee_id, T4.country_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id JOIN countries AS T4 ON T3.country_id = T4.country_id


Question: display the department name and number of employees in each of the department.

Context: CREATE TABLE employees (department_id VARCHAR); CREATE TABLE departments (department_id VARCHAR)

SELECT department_name, COUNT(*) FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id GROUP BY department_name


Question: display the full name (first and last name), and salary of those employees who working in any department located in London.

Context: CREATE TABLE locations (location_id VARCHAR, city VARCHAR); CREATE TABLE employees (department_id VARCHAR); CREATE TABLE departments (department_id VARCHAR, location_id VARCHAR)

SELECT first_name, last_name, salary FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id WHERE T3.city = 'London'


Question: What is the name of the song that was released in the most recent year?

Context: CREATE TABLE song (song_name VARCHAR, releasedate VARCHAR)

SELECT song_name, releasedate FROM song ORDER BY releasedate DESC LIMIT 1


Question: What is the id of the longest song?

Context: CREATE TABLE files (f_id VARCHAR, duration VARCHAR)

SELECT f_id FROM files ORDER BY duration DESC LIMIT 1


Question: Find the names of all English songs.

Context: CREATE TABLE song (song_name VARCHAR, languages VARCHAR)

SELECT song_name FROM song WHERE languages = "english"


Question: What are the id of songs whose format is mp3.

Context: CREATE TABLE files (f_id VARCHAR, formats VARCHAR)

SELECT f_id FROM files WHERE formats = "mp3"


Question: List the name and country of origin for all singers who have produced songs with rating above 9.

Context: CREATE TABLE song (artist_name VARCHAR, rating INTEGER); CREATE TABLE artist (artist_name VARCHAR, country VARCHAR)

SELECT DISTINCT T1.artist_name, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.rating > 9


Question: List the file size and format for all songs that have resolution lower than 800.

Context: CREATE TABLE song (f_id VARCHAR, resolution INTEGER); CREATE TABLE files (file_size VARCHAR, formats VARCHAR, f_id VARCHAR)

SELECT DISTINCT T1.file_size, T1.formats FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T2.resolution < 800


Question: What is the name of the artist who produced the shortest song?

Context: CREATE TABLE files (f_id VARCHAR, duration VARCHAR); CREATE TABLE song (artist_name VARCHAR, f_id VARCHAR)

SELECT T1.artist_name FROM song AS T1 JOIN files AS T2 ON T1.f_id = T2.f_id ORDER BY T2.duration LIMIT 1


Question: What are the names and countries of origin for the artists who produced the top three highly rated songs.

Context: CREATE TABLE song (artist_name VARCHAR, rating VARCHAR); CREATE TABLE artist (artist_name VARCHAR, country VARCHAR)

SELECT T1.artist_name, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name ORDER BY T2.rating DESC LIMIT 3


Question: How many songs have 4 minute duration?

Context: CREATE TABLE files (duration VARCHAR)

SELECT COUNT(*) FROM files WHERE duration LIKE "4:%"


Question: How many artists are from Bangladesh?

Context: CREATE TABLE artist (country VARCHAR)

SELECT COUNT(*) FROM artist WHERE country = "Bangladesh"


Question: What is the average rating of songs produced by female artists?

Context: CREATE TABLE song (rating INTEGER, artist_name VARCHAR); CREATE TABLE artist (artist_name VARCHAR, gender VARCHAR)

SELECT AVG(T2.rating) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T1.gender = "Female"


Question: What is the most popular file format?

Context: CREATE TABLE files (formats VARCHAR)

SELECT formats FROM files GROUP BY formats ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the names of the artists who are from UK and have produced English songs.

Context: CREATE TABLE artist (artist_name VARCHAR, country VARCHAR, languages VARCHAR); CREATE TABLE song (artist_name VARCHAR, country VARCHAR, languages VARCHAR)

SELECT artist_name FROM artist WHERE country = "UK" INTERSECT SELECT artist_name FROM song WHERE languages = "english"


Question: Find the id of songs that are available in mp4 format and have resolution lower than 1000.

Context: CREATE TABLE song (f_id VARCHAR, formats VARCHAR, resolution INTEGER); CREATE TABLE files (f_id VARCHAR, formats VARCHAR, resolution INTEGER)

SELECT f_id FROM files WHERE formats = "mp4" INTERSECT SELECT f_id FROM song WHERE resolution < 1000


Question: What is the country of origin of the artist who is female and produced a song in Bangla?

Context: CREATE TABLE artist (country VARCHAR, artist_name VARCHAR, gender VARCHAR); CREATE TABLE song (artist_name VARCHAR, languages VARCHAR)

SELECT T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T1.gender = "Female" AND T2.languages = "bangla"


Question: What is the average duration of songs that have mp3 format and resolution below 800?

Context: CREATE TABLE files (duration INTEGER, f_id VARCHAR, formats VARCHAR); CREATE TABLE song (f_id VARCHAR, resolution VARCHAR)

SELECT AVG(T1.duration) FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.formats = "mp3" AND T2.resolution < 800


Question: What is the number of artists for each gender?

Context: CREATE TABLE artist (gender VARCHAR)

SELECT COUNT(*), gender FROM artist GROUP BY gender


Question: What is the average rating of songs for each language?

Context: CREATE TABLE song (languages VARCHAR, rating INTEGER)

SELECT AVG(rating), languages FROM song GROUP BY languages


Question: Return the gender and name of artist who produced the song with the lowest resolution.

Context: CREATE TABLE artist (gender VARCHAR, artist_name VARCHAR); CREATE TABLE song (artist_name VARCHAR, resolution VARCHAR)

SELECT T1.gender, T1.artist_name FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name ORDER BY T2.resolution LIMIT 1


Question: For each file format, return the number of artists who released songs in that format.

Context: CREATE TABLE files (formats VARCHAR)

SELECT COUNT(*), formats FROM files GROUP BY formats


Question: Find the distinct names of all songs that have a higher resolution than some songs in English.

Context: CREATE TABLE song (song_name VARCHAR, resolution INTEGER, languages VARCHAR)

SELECT DISTINCT song_name FROM song WHERE resolution > (SELECT MIN(resolution) FROM song WHERE languages = "english")


Question: What are the names of all songs that have a lower rating than some song of blues genre?

Context: CREATE TABLE song (song_name VARCHAR, rating INTEGER, genre_is VARCHAR)

SELECT song_name FROM song WHERE rating < (SELECT MAX(rating) FROM song WHERE genre_is = "blues")


Question: What is the name and country of origin of the artist who released a song that has "love" in its title?

Context: CREATE TABLE song (artist_name VARCHAR, song_name VARCHAR); CREATE TABLE artist (artist_name VARCHAR, country VARCHAR)

SELECT T1.artist_name, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.song_name LIKE "%love%"


Question: List the name and gender for all artists who released songs in March.

Context: CREATE TABLE song (artist_name VARCHAR, releasedate VARCHAR); CREATE TABLE artist (artist_name VARCHAR, gender VARCHAR)

SELECT T1.artist_name, T1.gender FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.releasedate LIKE "%Mar%"


Question: List the names of all genres in alphabetical oder, together with its ratings.

Context: CREATE TABLE genre (g_name VARCHAR, rating VARCHAR)

SELECT g_name, rating FROM genre ORDER BY g_name


Question: Give me a list of the names of all songs ordered by their resolution.

Context: CREATE TABLE song (song_name VARCHAR, resolution VARCHAR)

SELECT song_name FROM song ORDER BY resolution


Question: What are the ids of songs that are available in either mp4 format or have resolution above 720?

SELECT f_id FROM files WHERE formats = "mp4" UNION SELECT f_id FROM song WHERE resolution > 720


Question: List the names of all songs that have 4 minute duration or are in English.

Context: CREATE TABLE files (f_id VARCHAR, duration VARCHAR); CREATE TABLE song (song_name VARCHAR, f_id VARCHAR); CREATE TABLE song (song_name VARCHAR, languages VARCHAR)

SELECT T2.song_name FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.duration LIKE "4:%" UNION SELECT song_name FROM song WHERE languages = "english"


Question: What is the language used most often in the songs?

Context: CREATE TABLE song (languages VARCHAR)

SELECT languages FROM song GROUP BY languages ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the language that was used most often in songs with resolution above 500?

Context: CREATE TABLE song (artist_name VARCHAR, languages VARCHAR, resolution INTEGER)

SELECT artist_name FROM song WHERE resolution > 500 GROUP BY languages ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the names of artists who are Male and are from UK?

Context: CREATE TABLE artist (artist_name VARCHAR, country VARCHAR, gender VARCHAR)

SELECT artist_name FROM artist WHERE country = "UK" AND gender = "Male"


Question: Find the names of songs whose genre is modern or language is English.

Context: CREATE TABLE song (song_name VARCHAR, genre_is VARCHAR, languages VARCHAR)

SELECT song_name FROM song WHERE genre_is = "modern" OR languages = "english"


Question: Return the names of songs for which format is mp3 and resolution is below 1000.

Context: CREATE TABLE song (song_name VARCHAR, resolution INTEGER); CREATE TABLE song (song_name VARCHAR, f_id VARCHAR); CREATE TABLE files (f_id VARCHAR, formats VARCHAR)

SELECT T2.song_name FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.formats = "mp3" INTERSECT SELECT song_name FROM song WHERE resolution < 1000


Question: Return the names of singers who are from UK and released an English song.

Context: CREATE TABLE song (artist_name VARCHAR, languages VARCHAR); CREATE TABLE artist (artist_name VARCHAR); CREATE TABLE artist (artist_name VARCHAR, country VARCHAR)

SELECT artist_name FROM artist WHERE country = "UK" INTERSECT SELECT T1.artist_name FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.languages = "english"


Question: What are the average rating and resolution of songs that are in Bangla?

Context: CREATE TABLE song (rating INTEGER, resolution INTEGER, languages VARCHAR)

SELECT AVG(rating), AVG(resolution) FROM song WHERE languages = "bangla"


Question: What are the maximum and minimum resolution of songs whose duration is 3 minutes?

Context: CREATE TABLE files (f_id VARCHAR, duration VARCHAR); CREATE TABLE song (resolution INTEGER, f_id VARCHAR)

SELECT MAX(T2.resolution), MIN(T2.resolution) FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.duration LIKE "3:%"


Question: What are the maximum duration and resolution of songs grouped and ordered by languages?

Context: CREATE TABLE song (languages VARCHAR, resolution INTEGER, f_id VARCHAR); CREATE TABLE files (duration INTEGER, f_id VARCHAR)

SELECT MAX(T1.duration), MAX(T2.resolution), T2.languages FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id GROUP BY T2.languages ORDER BY T2.languages


Question: What are the shortest duration and lowest rating of songs grouped by genre and ordered by genre?

Context: CREATE TABLE song (genre_is VARCHAR, rating INTEGER, f_id VARCHAR); CREATE TABLE files (duration INTEGER, f_id VARCHAR)

SELECT MIN(T1.duration), MIN(T2.rating), T2.genre_is FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id GROUP BY T2.genre_is ORDER BY T2.genre_is


Question: Find the names and number of works of all artists who have at least one English songs.

Context: CREATE TABLE song (artist_name VARCHAR, languages VARCHAR); CREATE TABLE artist (artist_name VARCHAR)

SELECT T1.artist_name, COUNT(*) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.languages = "english" GROUP BY T2.artist_name HAVING COUNT(*) >= 1


Question: Find the name and country of origin for all artists who have release at least one song of resolution above 900.

Context: CREATE TABLE song (artist_name VARCHAR, resolution INTEGER); CREATE TABLE artist (artist_name VARCHAR, country VARCHAR)

SELECT T1.artist_name, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.resolution > 900 GROUP BY T2.artist_name HAVING COUNT(*) >= 1


Question: Find the names and number of works of the three artists who have produced the most songs.

Context: CREATE TABLE song (artist_name VARCHAR); CREATE TABLE artist (artist_name VARCHAR)

SELECT T1.artist_name, COUNT(*) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name GROUP BY T2.artist_name ORDER BY COUNT(*) DESC LIMIT 3


Question: Find the country of origin for the artist who made the least number of songs?

Context: CREATE TABLE song (artist_name VARCHAR); CREATE TABLE artist (country VARCHAR, artist_name VARCHAR)

SELECT T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name GROUP BY T2.artist_name ORDER BY COUNT(*) LIMIT 1


Question: What are the names of the songs whose rating is below the rating of all songs in English?

Context: CREATE TABLE song (song_name VARCHAR, rating INTEGER, languages VARCHAR)

SELECT song_name FROM song WHERE rating < (SELECT MIN(rating) FROM song WHERE languages = 'english')


Question: What is ids of the songs whose resolution is higher than the resolution of any songs with rating lower than 8?

Context: CREATE TABLE song (f_id VARCHAR, resolution INTEGER, rating INTEGER)

SELECT f_id FROM song WHERE resolution > (SELECT MAX(resolution) FROM song WHERE rating < 8)


Question: What is ids of the songs whose resolution is higher than the average resolution of songs in modern genre?

Context: CREATE TABLE song (f_id VARCHAR, resolution INTEGER, genre_is VARCHAR)

SELECT f_id FROM song WHERE resolution > (SELECT AVG(resolution) FROM song WHERE genre_is = "modern")


Question: Find the top 3 artists who have the largest number of songs works whose language is Bangla.

SELECT T1.artist_name FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.languages = "bangla" GROUP BY T2.artist_name ORDER BY COUNT(*) DESC LIMIT 3


Question: List the id, genre and artist name of English songs ordered by rating.

Context: CREATE TABLE song (f_id VARCHAR, genre_is VARCHAR, artist_name VARCHAR, languages VARCHAR, rating VARCHAR)

SELECT f_id, genre_is, artist_name FROM song WHERE languages = "english" ORDER BY rating


Question: List the duration, file size and format of songs whose genre is pop, ordered by title?

Context: CREATE TABLE song (f_id VARCHAR, genre_is VARCHAR, song_name VARCHAR); CREATE TABLE files (duration VARCHAR, file_size VARCHAR, formats VARCHAR, f_id VARCHAR)

SELECT T1.duration, T1.file_size, T1.formats FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T2.genre_is = "pop" ORDER BY T2.song_name


Question: Find the names of the artists who have produced English songs but have never received rating higher than 8.

Context: CREATE TABLE song (artist_name VARCHAR, languages VARCHAR, rating INTEGER)

SELECT DISTINCT artist_name FROM song WHERE languages = "english" EXCEPT SELECT DISTINCT artist_name FROM song WHERE rating > 8


Question: Find the names of the artists who are from Bangladesh and have never received rating higher than 7.

Context: CREATE TABLE artist (artist_name VARCHAR, country VARCHAR, rating INTEGER); CREATE TABLE song (artist_name VARCHAR, country VARCHAR, rating INTEGER)

SELECT DISTINCT artist_name FROM artist WHERE country = "Bangladesh" EXCEPT SELECT DISTINCT artist_name FROM song WHERE rating > 7


Question: what is the full name and id of the college with the largest number of baseball players?

Context: CREATE TABLE player_college (college_id VARCHAR); CREATE TABLE college (name_full VARCHAR, college_id VARCHAR)

SELECT T1.name_full, T1.college_id FROM college AS T1 JOIN player_college AS T2 ON T1.college_id = T2.college_id GROUP BY T1.college_id ORDER BY COUNT(*) DESC LIMIT 1


Question: What is average salary of the players in the team named 'Boston Red Stockings' ?

Context: CREATE TABLE salary (salary INTEGER, team_id VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR)

SELECT AVG(T1.salary) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings'


Question: What are first and last names of players participating in all star game in 1998?

Context: CREATE TABLE all_star (player_id VARCHAR); CREATE TABLE player (player_id VARCHAR)

SELECT name_first, name_last FROM player AS T1 JOIN all_star AS T2 ON T1.player_id = T2.player_id WHERE YEAR = 1998


Question: What are the first name, last name and id of the player with the most all star game experiences? Also list the count.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, player_id VARCHAR); CREATE TABLE all_star (player_id VARCHAR)

SELECT T1.name_first, T1.name_last, T1.player_id, COUNT(*) FROM player AS T1 JOIN all_star AS T2 ON T1.player_id = T2.player_id GROUP BY T1.player_id ORDER BY COUNT(*) DESC LIMIT 1


Question: How many players enter hall of fame each year?

Context: CREATE TABLE hall_of_fame (yearid VARCHAR)

SELECT yearid, COUNT(*) FROM hall_of_fame GROUP BY yearid


Question: What is the average number of attendance at home games for each year?

Context: CREATE TABLE home_game (YEAR VARCHAR, attendance INTEGER)

SELECT YEAR, AVG(attendance) FROM home_game GROUP BY YEAR


Question: In 2014, what are the id and rank of the team that has the largest average number of attendance?

Context: CREATE TABLE team (team_id VARCHAR, rank VARCHAR); CREATE TABLE home_game (team_id VARCHAR, year VARCHAR, attendance INTEGER)

SELECT T2.team_id, T2.rank FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id WHERE T1.year = 2014 GROUP BY T1.team_id ORDER BY AVG(T1.attendance) DESC LIMIT 1