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

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

Answer: [SQL] SELECT name FROM club ORDER BY Start_year [/SQL]


Question: List all club names in descending alphabetical order.

Context: CREATE TABLE club (name VARCHAR)

Answer: [SQL] SELECT name FROM club ORDER BY name DESC [/SQL]


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)

Answer: [SQL] SELECT T1.name, T2.Player_id FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID [/SQL]


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)

Answer: [SQL] SELECT T1.name FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID WHERE T2.Position = "Right Wing" [/SQL]


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)

Answer: [SQL] SELECT AVG(T2.Points) FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID WHERE T1.name = "AIB" [/SQL]


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)

Answer: [SQL] SELECT POSITION, AVG(Points) FROM player GROUP BY POSITION [/SQL]


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)

Answer: [SQL] SELECT POSITION FROM player GROUP BY name HAVING AVG(Points) >= 20 [/SQL]


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

Context: CREATE TABLE competition (Competition_type VARCHAR)

Answer: [SQL] SELECT Competition_type, COUNT(*) FROM competition GROUP BY Competition_type [/SQL]


Question: List the most common type of competition.

Answer: [SQL] SELECT Competition_type FROM competition GROUP BY Competition_type ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


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

Answer: [SQL] SELECT Competition_type FROM competition GROUP BY Competition_type HAVING COUNT(*) <= 5 [/SQL]


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)

Answer: [SQL] SELECT name FROM CLub WHERE NOT Club_ID IN (SELECT Club_ID FROM player) [/SQL]


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

Answer: [SQL] SELECT POSITION FROM player WHERE Points > 20 INTERSECT SELECT POSITION FROM player WHERE Points < 10 [/SQL]


Question: Show total points of all players.

Context: CREATE TABLE player (Points INTEGER)

Answer: [SQL] SELECT SUM(Points) FROM player [/SQL]


Question: how many different positions are there?

Context: CREATE TABLE player (POSITION VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT POSITION) FROM player [/SQL]


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

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

Answer: [SQL] SELECT name FROM player WHERE points > (SELECT AVG(points) FROM player) [/SQL]


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

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

Answer: [SQL] SELECT COUNT(*), POSITION FROM player WHERE points < 30 GROUP BY POSITION [/SQL]


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

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

Answer: [SQL] SELECT country FROM competition WHERE competition_type = 'Tournament' GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


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

Answer: [SQL] SELECT country FROM competition WHERE competition_type = 'Friendly' INTERSECT SELECT country FROM competition WHERE competition_type = 'Tournament' [/SQL]


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

Answer: [SQL] SELECT country FROM competition EXCEPT SELECT country FROM competition WHERE competition_type = 'Friendly' [/SQL]


Question: How many furniture components are there in total?

Context: CREATE TABLE furniture (num_of_component INTEGER)

Answer: [SQL] SELECT SUM(num_of_component) FROM furniture [/SQL]


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)

Answer: [SQL] SELECT name, furniture_id FROM furniture ORDER BY market_rate DESC LIMIT 1 [/SQL]


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

Context: CREATE TABLE furniture (market_rate INTEGER)

Answer: [SQL] SELECT SUM(market_rate) FROM furniture ORDER BY market_rate DESC LIMIT 2 [/SQL]


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)

Answer: [SQL] SELECT Num_of_Component, name FROM furniture WHERE Num_of_Component > 10 [/SQL]


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)

Answer: [SQL] SELECT name, Num_of_Component FROM furniture ORDER BY market_rate LIMIT 1 [/SQL]


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)

Answer: [SQL] 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) [/SQL]


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)

Answer: [SQL] SELECT open_year, name FROM manufacturer ORDER BY num_of_shops DESC LIMIT 1 [/SQL]


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)

Answer: [SQL] SELECT AVG(Num_of_Factories) FROM manufacturer WHERE num_of_shops > 20 [/SQL]


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

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

Answer: [SQL] SELECT name, manufacturer_id FROM manufacturer ORDER BY open_year [/SQL]


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)

Answer: [SQL] SELECT name, open_year FROM manufacturer WHERE num_of_shops > 10 OR Num_of_Factories < 10 [/SQL]


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)

Answer: [SQL] SELECT MAX(num_of_shops), AVG(Num_of_Factories) FROM manufacturer WHERE open_year < 1990 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT t1.name, t2.price_in_dollar FROM furniture AS t1 JOIN furniture_manufacte AS t2 ON t1.Furniture_ID = t2.Furniture_ID [/SQL]


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)

Answer: [SQL] SELECT Market_Rate, name FROM furniture WHERE NOT Furniture_ID IN (SELECT Furniture_ID FROM furniture_manufacte) [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT T1.first_name, T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name, salary FROM employees WHERE salary < 6000 [/SQL]


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)

Answer: [SQL] SELECT first_name, department_id FROM employees WHERE last_name = 'McEwen' [/SQL]


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

Context: CREATE TABLE employees (department_id VARCHAR)

Answer: [SQL] SELECT * FROM employees WHERE department_id = "null" [/SQL]


Question: Display all the information about the department Marketing.

Context: CREATE TABLE departments (department_name VARCHAR)

Answer: [SQL] SELECT * FROM departments WHERE department_name = 'Marketing' [/SQL]


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)

Answer: [SQL] SELECT hire_date FROM employees WHERE NOT first_name LIKE '%M%' [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name, hire_date, salary, department_id FROM employees WHERE NOT first_name LIKE '%M%' [/SQL]


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.

Answer: [SQL] SELECT first_name, last_name, hire_date, salary, department_id FROM employees WHERE NOT first_name LIKE '%M%' ORDER BY department_id [/SQL]


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)

Answer: [SQL] SELECT phone_number FROM employees WHERE salary BETWEEN 8000 AND 12000 [/SQL]


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)

Answer: [SQL] SELECT * FROM employees WHERE salary BETWEEN 8000 AND 12000 AND commission_pct <> "null" OR department_id <> 40 [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name, salary FROM employees WHERE commission_pct = "null" [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name, salary FROM employees WHERE first_name LIKE '%m' [/SQL]


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)

Answer: [SQL] SELECT job_id, hire_date FROM employees WHERE hire_date BETWEEN '2007-11-05' AND '2009-07-05' [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name FROM employees WHERE department_id = 70 OR department_id = 90 [/SQL]


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)

Answer: [SQL] SELECT salary, manager_id FROM employees WHERE manager_id <> "null" [/SQL]


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)

Answer: [SQL] SELECT * FROM employees WHERE hire_date < '2002-06-21' [/SQL]


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)

Answer: [SQL] SELECT * FROM employees WHERE first_name LIKE '%D%' OR first_name LIKE '%S%' ORDER BY salary DESC [/SQL]


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

Answer: [SQL] SELECT * FROM employees WHERE hire_date > '1987-09-07' [/SQL]


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

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

Answer: [SQL] SELECT job_title FROM jobs WHERE min_salary > 9000 [/SQL]


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)

Answer: [SQL] SELECT job_title, max_salary - min_salary FROM jobs WHERE max_salary BETWEEN 12000 AND 18000 [/SQL]


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)

Answer: [SQL] SELECT email FROM employees WHERE commission_pct = "null" AND salary BETWEEN 7000 AND 12000 AND department_id = 50 [/SQL]


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)

Answer: [SQL] SELECT employee_id, MAX(end_date) FROM job_history GROUP BY employee_id [/SQL]


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)

Answer: [SQL] SELECT department_id FROM employees GROUP BY department_id HAVING COUNT(commission_pct) > 10 [/SQL]


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)

Answer: [SQL] SELECT DISTINCT department_id FROM employees GROUP BY department_id, manager_id HAVING COUNT(employee_id) >= 4 [/SQL]


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)

Answer: [SQL] SELECT department_id, AVG(salary) FROM employees WHERE commission_pct <> "null" GROUP BY department_id [/SQL]


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

Context: CREATE TABLE locations (country_id VARCHAR)

Answer: [SQL] SELECT country_id, COUNT(*) FROM locations GROUP BY country_id [/SQL]


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)

Answer: [SQL] SELECT job_id FROM job_history WHERE end_date - start_date > 300 GROUP BY job_id HAVING COUNT(*) >= 2 [/SQL]


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

Context: CREATE TABLE job_history (employee_id VARCHAR)

Answer: [SQL] SELECT employee_id FROM job_history GROUP BY employee_id HAVING COUNT(*) >= 2 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT * FROM job_history AS T1 JOIN employees AS T2 ON T1.employee_id = T2.employee_id WHERE T2.salary >= 12000 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name FROM employees WHERE salary > (SELECT salary FROM employees WHERE employee_id = 163) [/SQL]


Question: return the smallest salary for every departments.

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

Answer: [SQL] SELECT MIN(salary), department_id FROM employees GROUP BY department_id [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name, department_id FROM employees WHERE salary IN (SELECT MIN(salary) FROM employees GROUP BY department_id) [/SQL]


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

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

Answer: [SQL] SELECT employee_id FROM employees WHERE salary > (SELECT AVG(salary) FROM employees) [/SQL]


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)

Answer: [SQL] SELECT employee_id, salary FROM employees WHERE manager_id = (SELECT employee_id FROM employees WHERE first_name = 'Payam') [/SQL]


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

Answer: [SQL] SELECT DISTINCT T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id [/SQL]


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)

Answer: [SQL] SELECT DISTINCT * FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id WHERE T1.employee_id = T2.manager_id [/SQL]


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

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

Answer: [SQL] SELECT job_id FROM employees GROUP BY job_id HAVING AVG(salary) > 8000 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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' [/SQL]


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)

Answer: [SQL] SELECT * FROM employees WHERE salary BETWEEN (SELECT MIN(salary) FROM employees) AND 2500 [/SQL]


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)

Answer: [SQL] SELECT * FROM employees WHERE NOT department_id IN (SELECT department_id FROM departments WHERE manager_id BETWEEN 100 AND 200) [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name, hire_date FROM employees WHERE department_id = (SELECT department_id FROM employees WHERE first_name = "Clara") [/SQL]


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

Answer: [SQL] 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" [/SQL]


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)

Answer: [SQL] SELECT employee_id, first_name, last_name FROM employees WHERE department_id IN (SELECT department_id FROM employees WHERE first_name LIKE '%T%') [/SQL]


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)

Answer: [SQL] 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%') [/SQL]


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)

Answer: [SQL] SELECT employee_id, job_id FROM employees WHERE salary < (SELECT MIN(salary) FROM employees WHERE job_id = 'MK_MAN') [/SQL]


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)

Answer: [SQL] SELECT employee_id, first_name, last_name, job_id FROM employees WHERE salary > (SELECT MAX(salary) FROM employees WHERE job_id = 'PU_MAN') [/SQL]


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

Answer: [SQL] SELECT department_id, SUM(salary) FROM employees GROUP BY department_id HAVING COUNT(*) >= 2 [/SQL]


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)

Answer: [SQL] SELECT * FROM employees WHERE NOT employee_id IN (SELECT employee_id FROM job_history) [/SQL]


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)

Answer: [SQL] SELECT first_name, last_name, salary, department_id, MAX(salary) FROM employees GROUP BY department_id [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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%' [/SQL]


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)

Answer: [SQL] SELECT T1.department_name, T2.city, T2.state_province FROM departments AS T1 JOIN locations AS T2 ON T2.location_id = T1.location_id [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT department_name, COUNT(*) FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id GROUP BY department_name [/SQL]


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)

Answer: [SQL] 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' [/SQL]


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)

Answer: [SQL] SELECT song_name, releasedate FROM song ORDER BY releasedate DESC LIMIT 1 [/SQL]


Question: What is the id of the longest song?

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

Answer: [SQL] SELECT f_id FROM files ORDER BY duration DESC LIMIT 1 [/SQL]


Question: Find the names of all English songs.

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

Answer: [SQL] SELECT song_name FROM song WHERE languages = "english" [/SQL]


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

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

Answer: [SQL] SELECT f_id FROM files WHERE formats = "mp3" [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


Question: How many songs have 4 minute duration?

Context: CREATE TABLE files (duration VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM files WHERE duration LIKE "4:%" [/SQL]


Question: How many artists are from Bangladesh?

Context: CREATE TABLE artist (country VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM artist WHERE country = "Bangladesh" [/SQL]


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)

Answer: [SQL] SELECT AVG(T2.rating) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T1.gender = "Female" [/SQL]


Question: What is the most popular file format?

Context: CREATE TABLE files (formats VARCHAR)

Answer: [SQL] SELECT formats FROM files GROUP BY formats ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


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)

Answer: [SQL] SELECT artist_name FROM artist WHERE country = "UK" INTERSECT SELECT artist_name FROM song WHERE languages = "english" [/SQL]


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)

Answer: [SQL] SELECT f_id FROM files WHERE formats = "mp4" INTERSECT SELECT f_id FROM song WHERE resolution < 1000 [/SQL]


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)

Answer: [SQL] 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" [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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

Context: CREATE TABLE artist (gender VARCHAR)

Answer: [SQL] SELECT COUNT(*), gender FROM artist GROUP BY gender [/SQL]


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

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

Answer: [SQL] SELECT AVG(rating), languages FROM song GROUP BY languages [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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

Context: CREATE TABLE files (formats VARCHAR)

Answer: [SQL] SELECT COUNT(*), formats FROM files GROUP BY formats [/SQL]


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)

Answer: [SQL] SELECT DISTINCT song_name FROM song WHERE resolution > (SELECT MIN(resolution) FROM song WHERE languages = "english") [/SQL]


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)

Answer: [SQL] SELECT song_name FROM song WHERE rating < (SELECT MAX(rating) FROM song WHERE genre_is = "blues") [/SQL]


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)

Answer: [SQL] 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%" [/SQL]


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)

Answer: [SQL] 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%" [/SQL]


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

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

Answer: [SQL] SELECT g_name, rating FROM genre ORDER BY g_name [/SQL]


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

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

Answer: [SQL] SELECT song_name FROM song ORDER BY resolution [/SQL]


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

Answer: [SQL] SELECT f_id FROM files WHERE formats = "mp4" UNION SELECT f_id FROM song WHERE resolution > 720 [/SQL]


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)

Answer: [SQL] 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" [/SQL]


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

Context: CREATE TABLE song (languages VARCHAR)

Answer: [SQL] SELECT languages FROM song GROUP BY languages ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


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)

Answer: [SQL] SELECT artist_name FROM song WHERE resolution > 500 GROUP BY languages ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


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)

Answer: [SQL] SELECT artist_name FROM artist WHERE country = "UK" AND gender = "Male" [/SQL]


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)

Answer: [SQL] SELECT song_name FROM song WHERE genre_is = "modern" OR languages = "english" [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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" [/SQL]


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

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

Answer: [SQL] SELECT AVG(rating), AVG(resolution) FROM song WHERE languages = "bangla" [/SQL]


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)

Answer: [SQL] 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:%" [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT song_name FROM song WHERE rating < (SELECT MIN(rating) FROM song WHERE languages = 'english') [/SQL]


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)

Answer: [SQL] SELECT f_id FROM song WHERE resolution > (SELECT MAX(resolution) FROM song WHERE rating < 8) [/SQL]


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)

Answer: [SQL] SELECT f_id FROM song WHERE resolution > (SELECT AVG(resolution) FROM song WHERE genre_is = "modern") [/SQL]


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

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT f_id, genre_is, artist_name FROM song WHERE languages = "english" ORDER BY rating [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] SELECT DISTINCT artist_name FROM song WHERE languages = "english" EXCEPT SELECT DISTINCT artist_name FROM song WHERE rating > 8 [/SQL]


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)

Answer: [SQL] SELECT DISTINCT artist_name FROM artist WHERE country = "Bangladesh" EXCEPT SELECT DISTINCT artist_name FROM song WHERE rating > 7 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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)

Answer: [SQL] 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' [/SQL]


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)

Answer: [SQL] SELECT name_first, name_last FROM player AS T1 JOIN all_star AS T2 ON T1.player_id = T2.player_id WHERE YEAR = 1998 [/SQL]


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)

Answer: [SQL] 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 [/SQL]


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

Context: CREATE TABLE hall_of_fame (yearid VARCHAR)

Answer: [SQL] SELECT yearid, COUNT(*) FROM hall_of_fame GROUP BY yearid [/SQL]


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

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

Answer: [SQL] SELECT YEAR, AVG(attendance) FROM home_game GROUP BY YEAR [/SQL]


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)

Answer: [SQL] 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 [/SQL]


Question: What are the manager's first name, last name and id who won the most manager award?

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

Answer: [SQL] SELECT T1.name_first, T1.name_last, T2.player_id FROM player AS T1 JOIN manager_award AS T2 ON T1.player_id = T2.player_id GROUP BY T2.player_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many parks are there in the state of NY?

Context: CREATE TABLE park (state VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM park WHERE state = 'NY' [/SQL]


Question: Which 3 players won the most player awards? List their full name and id.

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

Answer: [SQL] SELECT T1.name_first, T1.name_last, T1.player_id FROM player AS T1 JOIN player_award AS T2 ON T1.player_id = T2.player_id GROUP BY T1.player_id ORDER BY COUNT(*) DESC LIMIT 3 [/SQL]


Question: List three countries which are the origins of the least players.

Context: CREATE TABLE player (birth_country VARCHAR)

Answer: [SQL] SELECT birth_country FROM player GROUP BY birth_country ORDER BY COUNT(*) LIMIT 3 [/SQL]


Question: Find all the players' first name and last name who have empty death record.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, death_year VARCHAR)

Answer: [SQL] SELECT name_first, name_last FROM player WHERE death_year = '' [/SQL]


Question: How many players born in USA are right-handed batters? That is, have the batter value 'R'.

Context: CREATE TABLE player (birth_country VARCHAR, bats VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM player WHERE birth_country = 'USA' AND bats = 'R' [/SQL]


Question: What is the average height of the players from the college named 'Yale University'?

Context: CREATE TABLE player_college (player_id VARCHAR, college_id VARCHAR); CREATE TABLE player (height INTEGER, player_id VARCHAR); CREATE TABLE college (college_id VARCHAR, name_full VARCHAR)

Answer: [SQL] SELECT AVG(T1.height) FROM player AS T1 JOIN player_college AS T2 ON T1.player_id = T2.player_id JOIN college AS T3 ON T3.college_id = T2.college_id WHERE T3.name_full = 'Yale University' [/SQL]


Question: What is the highest salary among each team? List the team name, id and maximum salary.

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

Answer: [SQL] SELECT T1.name, T1.team_id, MAX(T2.salary) FROM team AS T1 JOIN salary AS T2 ON T1.team_id = T2.team_id GROUP BY T1.team_id [/SQL]


Question: What are the name and id of the team offering the lowest average salary?

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

Answer: [SQL] SELECT T1.name, T1.team_id FROM team AS T1 JOIN salary AS T2 ON T1.team_id = T2.team_id GROUP BY T1.team_id ORDER BY AVG(T2.salary) LIMIT 1 [/SQL]


Question: Find the players' first name and last name who won award both in 1960 and in 1961.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR); CREATE TABLE player_award (year VARCHAR)

Answer: [SQL] SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1960 INTERSECT SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1961 [/SQL]


Question: List players' first name and last name who have weight greater than 220 or height shorter than 75.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, weight VARCHAR, height VARCHAR)

Answer: [SQL] SELECT name_first, name_last FROM player WHERE weight > 220 OR height < 75 [/SQL]


Question: List the maximum scores of the team Boston Red Stockings when the team won in postseason?

Context: CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE postseason (wins INTEGER, team_id_winner VARCHAR)

Answer: [SQL] SELECT MAX(T1.wins) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' [/SQL]


Question: How many times did Boston Red Stockings lose in 2009 postseason?

Context: CREATE TABLE postseason (team_id_loser VARCHAR, year VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_loser = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 2009 [/SQL]


Question: What are the name and id of the team with the most victories in 2008 postseason?

Context: CREATE TABLE postseason (team_id_winner VARCHAR, year VARCHAR); CREATE TABLE team (name VARCHAR, team_id_br VARCHAR)

Answer: [SQL] SELECT T2.name, T1.team_id_winner FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T1.year = 2008 GROUP BY T1.team_id_winner ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What is the number of wins the team Boston Red Stockings got in the postseasons each year in history?

Context: CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE postseason (year VARCHAR, team_id_winner VARCHAR)

Answer: [SQL] SELECT COUNT(*), T1.year FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' GROUP BY T1.year [/SQL]


Question: What is the total number of postseason games that team Boston Red Stockings participated in?

Context: CREATE TABLE postseason (team_id_winner VARCHAR, team_id_loser VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM (SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' UNION SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_loser = T2.team_id_br WHERE T2.name = 'Boston Red Stockings') [/SQL]


Question: How many games in 1885 postseason resulted in ties (that is, the value of "ties" is '1')?

Context: CREATE TABLE postseason (YEAR VARCHAR, ties VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM postseason WHERE YEAR = 1885 AND ties = 1 [/SQL]


Question: What is the total salary paid by team Boston Red Stockings in 2010?

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

Answer: [SQL] SELECT SUM(T1.salary) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 2010 [/SQL]


Question: How many players were in the team Boston Red Stockings in 2000?

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

Answer: [SQL] SELECT COUNT(*) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 2000 [/SQL]


Question: List the 3 highest salaries of the players in 2001?

Context: CREATE TABLE salary (salary VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT salary FROM salary WHERE YEAR = 2001 ORDER BY salary DESC LIMIT 3 [/SQL]


Question: What were all the salary values of players in 2010 and 2001?

Answer: [SQL] SELECT salary FROM salary WHERE YEAR = 2010 UNION SELECT salary FROM salary WHERE YEAR = 2001 [/SQL]


Question: In which year did the least people enter hall of fame?

Context: CREATE TABLE hall_of_fame (yearid VARCHAR)

Answer: [SQL] SELECT yearid FROM hall_of_fame GROUP BY yearid ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: How many parks are there in Atlanta city?

Context: CREATE TABLE park (city VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM park WHERE city = 'Atlanta' [/SQL]


Question: How many games were played in park "Columbia Park" in 1907?

Context: CREATE TABLE park (park_id VARCHAR, park_name VARCHAR); CREATE TABLE home_game (park_id VARCHAR, year VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM home_game AS T1 JOIN park AS T2 ON T1.park_id = T2.park_id WHERE T1.year = 1907 AND T2.park_name = 'Columbia Park' [/SQL]


Question: How many games were played in city Atlanta in 2000?

Context: CREATE TABLE park (park_id VARCHAR, city VARCHAR); CREATE TABLE home_game (park_id VARCHAR, year VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM home_game AS T1 JOIN park AS T2 ON T1.park_id = T2.park_id WHERE T1.year = 2000 AND T2.city = 'Atlanta' [/SQL]


Question: What is the total home game attendance of team Boston Red Stockings from 2000 to 2010?

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

Answer: [SQL] SELECT SUM(T1.attendance) FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year BETWEEN 2000 AND 2010 [/SQL]


Question: How much did the the player with first name Len and last name Barker earn between 1985 to 1990 in total?

Context: CREATE TABLE salary (salary INTEGER, player_id VARCHAR, year VARCHAR); CREATE TABLE player (player_id VARCHAR, name_first VARCHAR, name_last VARCHAR)

Answer: [SQL] SELECT SUM(T1.salary) FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id WHERE T2.name_first = 'Len' AND T2.name_last = 'Barker' AND T1.year BETWEEN 1985 AND 1990 [/SQL]


Question: List players' first name and last name who received salary from team Washington Nationals in both 2005 and 2007.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, player_id VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE salary (player_id VARCHAR, team_id VARCHAR, year VARCHAR)

Answer: [SQL] SELECT T2.name_first, T2.name_last FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id JOIN team AS T3 ON T3.team_id_br = T1.team_id WHERE T1.year = 2005 AND T3.name = 'Washington Nationals' INTERSECT SELECT T2.name_first, T2.name_last FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id JOIN team AS T3 ON T3.team_id_br = T1.team_id WHERE T1.year = 2007 AND T3.name = 'Washington Nationals' [/SQL]


Question: How many home games did the team Boston Red Stockings play from 1990 to 2000 in total?

Context: CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE home_game (games INTEGER, team_id VARCHAR, year VARCHAR)

Answer: [SQL] SELECT SUM(T1.games) FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year BETWEEN 1990 AND 2000 [/SQL]


Question: Which team had the least number of attendances in home games in 1980?

Context: CREATE TABLE home_game (team_id VARCHAR, year VARCHAR, attendance VARCHAR); CREATE TABLE team (name VARCHAR, team_id_br VARCHAR)

Answer: [SQL] SELECT T2.name FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T1.year = 1980 ORDER BY T1.attendance LIMIT 1 [/SQL]


Question: List the names of states that have more than 2 parks.

Context: CREATE TABLE park (state VARCHAR)

Answer: [SQL] SELECT state FROM park GROUP BY state HAVING COUNT(*) > 2 [/SQL]


Question: How many team franchises are active, with active value 'Y'?

Context: CREATE TABLE team_franchise (active VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM team_franchise WHERE active = 'Y' [/SQL]


Question: Which cities have 2 to 4 parks?

Context: CREATE TABLE park (city VARCHAR)

Answer: [SQL] SELECT city FROM park GROUP BY city HAVING COUNT(*) BETWEEN 2 AND 4 [/SQL]


Question: Which park had most attendances in 2008?

Context: CREATE TABLE park (park_name VARCHAR, park_id VARCHAR); CREATE TABLE home_game (park_id VARCHAR, year VARCHAR, attendance VARCHAR)

Answer: [SQL] SELECT T2.park_name FROM home_game AS T1 JOIN park AS T2 ON T1.park_id = T2.park_id WHERE T1.year = 2008 ORDER BY T1.attendance DESC LIMIT 1 [/SQL]


Question: How many camera lenses have a focal length longer than 15 mm?

Context: CREATE TABLE camera_lens (focal_length_mm INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM camera_lens WHERE focal_length_mm > 15 [/SQL]


Question: Find the brand and name for each camera lens, and sort in descending order of maximum aperture.

Context: CREATE TABLE camera_lens (brand VARCHAR, name VARCHAR, max_aperture VARCHAR)

Answer: [SQL] SELECT brand, name FROM camera_lens ORDER BY max_aperture DESC [/SQL]


Question: List the id, color scheme, and name for all the photos.

Context: CREATE TABLE photos (id VARCHAR, color VARCHAR, name VARCHAR)

Answer: [SQL] SELECT id, color, name FROM photos [/SQL]


Question: What are the maximum and average height of the mountains?

Context: CREATE TABLE mountain (height INTEGER)

Answer: [SQL] SELECT MAX(height), AVG(height) FROM mountain [/SQL]


Question: What are the average prominence of the mountains in country 'Morocco'?

Context: CREATE TABLE mountain (prominence INTEGER, country VARCHAR)

Answer: [SQL] SELECT AVG(prominence) FROM mountain WHERE country = 'Morocco' [/SQL]


Question: What are the name, height and prominence of mountains which do not belong to the range 'Aberdare Range'?

Context: CREATE TABLE mountain (name VARCHAR, height VARCHAR, prominence VARCHAR, range VARCHAR)

Answer: [SQL] SELECT name, height, prominence FROM mountain WHERE range <> 'Aberdare Range' [/SQL]


Question: What are the id and name of the photos for mountains?

Context: CREATE TABLE photos (mountain_id VARCHAR); CREATE TABLE mountain (id VARCHAR, name VARCHAR, height INTEGER)

Answer: [SQL] SELECT T1.id, T1.name FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id WHERE T1.height > 4000 [/SQL]


Question: What are the id and name of the mountains that have at least 2 photos?

Context: CREATE TABLE mountain (id VARCHAR, name VARCHAR); CREATE TABLE photos (mountain_id VARCHAR)

Answer: [SQL] SELECT T1.id, T1.name FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id GROUP BY T1.id HAVING COUNT(*) >= 2 [/SQL]


Question: What are the names of the cameras that have taken picture of the most mountains?

Context: CREATE TABLE camera_lens (name VARCHAR, id VARCHAR); CREATE TABLE photos (camera_lens_id VARCHAR)

Answer: [SQL] SELECT T2.name FROM photos AS T1 JOIN camera_lens AS T2 ON T1.camera_lens_id = T2.id GROUP BY T2.id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the names of photos taken with the lens brand 'Sigma' or 'Olympus'?

Context: CREATE TABLE photos (camera_lens_id VARCHAR); CREATE TABLE camera_lens (name VARCHAR, id VARCHAR, brand VARCHAR)

Answer: [SQL] SELECT T1.name FROM camera_lens AS T1 JOIN photos AS T2 ON T2.camera_lens_id = T1.id WHERE T1.brand = 'Sigma' OR T1.brand = 'Olympus' [/SQL]


Question: How many different kinds of lens brands are there?

Context: CREATE TABLE camera_lens (brand VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT brand) FROM camera_lens [/SQL]


Question: How many camera lenses are not used in taking any photos?

Context: CREATE TABLE photos (id VARCHAR, camera_lens_id VARCHAR); CREATE TABLE camera_lens (id VARCHAR, camera_lens_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM camera_lens WHERE NOT id IN (SELECT camera_lens_id FROM photos) [/SQL]


Question: How many distinct kinds of camera lenses are used to take photos of mountains in the country 'Ethiopia'?

Context: CREATE TABLE mountain (id VARCHAR, country VARCHAR); CREATE TABLE photos (camera_lens_id VARCHAR, mountain_id VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT T2.camera_lens_id) FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id WHERE T1.country = 'Ethiopia' [/SQL]


Question: List the brands of lenses that took both a picture of mountains with range 'Toubkal Atlas' and a picture of mountains with range 'Lasta Massif'

Context: CREATE TABLE mountain (id VARCHAR, range VARCHAR); CREATE TABLE photos (mountain_id VARCHAR, camera_lens_id VARCHAR); CREATE TABLE camera_lens (brand VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T1.range = 'Toubkal Atlas' INTERSECT SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T1.range = 'Lasta Massif' [/SQL]


Question: Show the name and prominence of the mountains whose picture is not taken by a lens of brand 'Sigma'.

Context: CREATE TABLE camera_lens (id VARCHAR, brand VARCHAR); CREATE TABLE mountain (name VARCHAR, prominence VARCHAR, id VARCHAR); CREATE TABLE photos (mountain_id VARCHAR, camera_lens_id VARCHAR); CREATE TABLE mountain (name VARCHAR, prominence VARCHAR)

Answer: [SQL] SELECT name, prominence FROM mountain EXCEPT SELECT T1.name, T1.prominence FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T3.brand = 'Sigma' [/SQL]


Question: List the camera lens names containing substring "Digital".

Context: CREATE TABLE camera_lens (name VARCHAR)

Answer: [SQL] SELECT name FROM camera_lens WHERE name LIKE "%Digital%" [/SQL]


Question: What is the name of each camera lens and the number of photos taken by it? Order the result by the count of photos.

Context: CREATE TABLE photos (camera_lens_id VARCHAR); CREATE TABLE camera_lens (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.name, COUNT(*) FROM camera_lens AS T1 JOIN photos AS T2 ON T1.id = T2.camera_lens_id GROUP BY T1.id ORDER BY COUNT(*) [/SQL]


Question: Find the names of channels that are not owned by CCTV.

Context: CREATE TABLE channel (name VARCHAR, OWNER VARCHAR)

Answer: [SQL] SELECT name FROM channel WHERE OWNER <> 'CCTV' [/SQL]


Question: List all channel names ordered by their rating in percent from big to small.

Context: CREATE TABLE channel (name VARCHAR, rating_in_percent VARCHAR)

Answer: [SQL] SELECT name FROM channel ORDER BY rating_in_percent DESC [/SQL]


Question: What is the owner of the channel that has the highest rating ratio?

Context: CREATE TABLE channel (OWNER VARCHAR, rating_in_percent VARCHAR)

Answer: [SQL] SELECT OWNER FROM channel ORDER BY rating_in_percent DESC LIMIT 1 [/SQL]


Question: how many programs are there?

Context: CREATE TABLE program (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM program [/SQL]


Question: list all the names of programs, ordering by launch time.

Context: CREATE TABLE program (name VARCHAR, launch VARCHAR)

Answer: [SQL] SELECT name FROM program ORDER BY launch [/SQL]


Question: List the name, origin and owner of each program.

Context: CREATE TABLE program (name VARCHAR, origin VARCHAR, OWNER VARCHAR)

Answer: [SQL] SELECT name, origin, OWNER FROM program [/SQL]


Question: find the name of the program that was launched most recently.

Answer: [SQL] SELECT name FROM program ORDER BY launch DESC LIMIT 1 [/SQL]


Question: find the total percentage share of all channels owned by CCTV.

Context: CREATE TABLE channel (Share_in_percent INTEGER, OWNER VARCHAR)

Answer: [SQL] SELECT SUM(Share_in_percent) FROM channel WHERE OWNER = 'CCTV' [/SQL]


Question: Find the names of the channels that are broadcast in the morning.

Context: CREATE TABLE channel (name VARCHAR, channel_id VARCHAR); CREATE TABLE broadcast (channel_id VARCHAR, time_of_day VARCHAR)

Answer: [SQL] SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Morning' [/SQL]


Question: what are the names of the channels that broadcast in both morning and night?

Answer: [SQL] SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Morning' INTERSECT SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Night' [/SQL]


Question: how many programs are broadcast in each time section of the day?

Context: CREATE TABLE broadcast (time_of_day VARCHAR)

Answer: [SQL] SELECT COUNT(*), time_of_day FROM broadcast GROUP BY time_of_day [/SQL]


Question: find the number of different programs that are broadcast during night time.

Context: CREATE TABLE broadcast (program_id VARCHAR, time_of_day VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT program_id) FROM broadcast WHERE time_of_day = 'Night' [/SQL]


Question: Find the names of programs that are never broadcasted in the morning.

Context: CREATE TABLE broadcast (program_id VARCHAR, Time_of_day VARCHAR); CREATE TABLE program (name VARCHAR, program_id VARCHAR); CREATE TABLE program (name VARCHAR)

Answer: [SQL] SELECT name FROM program EXCEPT SELECT t1.name FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Morning" [/SQL]


Question: find the program owners that have some programs in both morning and night time.

Context: CREATE TABLE broadcast (program_id VARCHAR, Time_of_day VARCHAR); CREATE TABLE program (owner VARCHAR, program_id VARCHAR)

Answer: [SQL] SELECT t1.owner FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Morning" INTERSECT SELECT t1.owner FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Night" [/SQL]


Question: List all program origins in the alphabetical order.

Context: CREATE TABLE program (origin VARCHAR)

Answer: [SQL] SELECT origin FROM program ORDER BY origin [/SQL]


Question: what is the number of different channel owners?

Context: CREATE TABLE channel (OWNER VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT OWNER) FROM channel [/SQL]


Question: find the names of programs whose origin is not in Beijing.

Context: CREATE TABLE program (name VARCHAR, origin VARCHAR)

Answer: [SQL] SELECT name FROM program WHERE origin <> 'Beijing' [/SQL]


Question: What are the names of the channels owned by CCTV or HBS?

Answer: [SQL] SELECT name FROM channel WHERE OWNER = 'CCTV' OR OWNER = 'HBS' [/SQL]


Question: Find the total rating ratio for each channel owner.

Context: CREATE TABLE channel (OWNER VARCHAR, Rating_in_percent INTEGER)

Answer: [SQL] SELECT SUM(Rating_in_percent), OWNER FROM channel GROUP BY OWNER [/SQL]


Question: Find the name of the program that is broadcast most frequently.

Context: CREATE TABLE program (name VARCHAR, program_id VARCHAR); CREATE TABLE broadcast (program_id VARCHAR)

Answer: [SQL] SELECT t1.name FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id GROUP BY t2.program_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many courses are there in total?

Context: CREATE TABLE COURSES (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM COURSES [/SQL]


Question: What are the descriptions of the courses with name "database"?

Context: CREATE TABLE COURSES (course_description VARCHAR, course_name VARCHAR)

Answer: [SQL] SELECT course_description FROM COURSES WHERE course_name = "database" [/SQL]


Question: What are the addresses of the course authors or tutors with personal name "Cathrine"

Context: CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR, personal_name VARCHAR)

Answer: [SQL] SELECT address_line_1 FROM Course_Authors_and_Tutors WHERE personal_name = "Cathrine" [/SQL]


Question: List the addresses of all the course authors or tutors.

Context: CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR)

Answer: [SQL] SELECT address_line_1 FROM Course_Authors_and_Tutors [/SQL]


Question: List all the login names and family names of course author and tutors.

Context: CREATE TABLE Course_Authors_and_Tutors (login_name VARCHAR, family_name VARCHAR)

Answer: [SQL] SELECT login_name, family_name FROM Course_Authors_and_Tutors [/SQL]


Question: List all the dates of enrollment and completion of students.

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, date_of_completion VARCHAR)

Answer: [SQL] SELECT date_of_enrolment, date_of_completion FROM Student_Course_Enrolment [/SQL]


Question: How many distinct students are enrolled in courses?

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT student_id) FROM Student_Course_Enrolment [/SQL]


Question: How many distinct courses are enrolled in by students?

Context: CREATE TABLE Student_Course_Enrolment (course_id VARCHAR)

Answer: [SQL] SELECT COUNT(course_id) FROM Student_Course_Enrolment [/SQL]


Question: Find the dates of the tests taken with result "Pass".

Context: CREATE TABLE Student_Tests_Taken (date_test_taken VARCHAR, test_result VARCHAR)

Answer: [SQL] SELECT date_test_taken FROM Student_Tests_Taken WHERE test_result = "Pass" [/SQL]


Question: How many tests have result "Fail"?

Context: CREATE TABLE Student_Tests_Taken (test_result VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Student_Tests_Taken WHERE test_result = "Fail" [/SQL]


Question: What are the login names of the students with family name "Ward"?

Context: CREATE TABLE Students (login_name VARCHAR, family_name VARCHAR)

Answer: [SQL] SELECT login_name FROM Students WHERE family_name = "Ward" [/SQL]


Question: What are the dates of the latest logon of the students with family name "Jaskolski" or "Langosh"?

Context: CREATE TABLE Students (date_of_latest_logon VARCHAR, family_name VARCHAR)

Answer: [SQL] SELECT date_of_latest_logon FROM Students WHERE family_name = "Jaskolski" OR family_name = "Langosh" [/SQL]


Question: How many students have personal names that contain the word "son"?

Context: CREATE TABLE Students (personal_name VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Students WHERE personal_name LIKE "%son%" [/SQL]


Question: List all the subject names.

Context: CREATE TABLE SUBJECTS (subject_name VARCHAR)

Answer: [SQL] SELECT subject_name FROM SUBJECTS [/SQL]


Question: List all the information about course authors and tutors in alphabetical order of the personal name.

Context: CREATE TABLE Course_Authors_and_Tutors (personal_name VARCHAR)

Answer: [SQL] SELECT * FROM Course_Authors_and_Tutors ORDER BY personal_name [/SQL]


Question: List the personal names and family names of all the students in alphabetical order of family name.

Context: CREATE TABLE Students (personal_name VARCHAR, family_name VARCHAR)

Answer: [SQL] SELECT personal_name, family_name FROM Students ORDER BY family_name [/SQL]


Question: List each test result and its count in descending order of count.

Answer: [SQL] SELECT test_result, COUNT(*) FROM Student_Tests_Taken GROUP BY test_result ORDER BY COUNT(*) DESC [/SQL]


Question: Find the login name of the course author that teaches the course with name "advanced database".

Context: CREATE TABLE Courses (author_id VARCHAR, course_name VARCHAR); CREATE TABLE Course_Authors_and_Tutors (login_name VARCHAR, author_id VARCHAR)

Answer: [SQL] SELECT T1.login_name FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id WHERE T2.course_name = "advanced database" [/SQL]


Question: Find the addresses of the course authors who teach the course with name "operating system" or "data structure".

Context: CREATE TABLE Courses (author_id VARCHAR, course_name VARCHAR); CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR, author_id VARCHAR)

Answer: [SQL] SELECT T1.address_line_1 FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id WHERE T2.course_name = "operating system" OR T2.course_name = "data structure" [/SQL]


Question: Find the personal name, family name, and author ID of the course author that teaches the most courses.

Context: CREATE TABLE Courses (author_id VARCHAR); CREATE TABLE Course_Authors_and_Tutors (personal_name VARCHAR, family_name VARCHAR, author_id VARCHAR)

Answer: [SQL] SELECT T1.personal_name, T1.family_name, T2.author_id FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id GROUP BY T2.author_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the addresses and author IDs of the course authors that teach at least two courses.

Context: CREATE TABLE Courses (author_id VARCHAR); CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR, author_id VARCHAR)

Answer: [SQL] SELECT T1.address_line_1, T2.author_id FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id GROUP BY T2.author_id HAVING COUNT(*) >= 2 [/SQL]


Question: Find the names of courses taught by the tutor who has personal name "Julio".

Context: CREATE TABLE Course_Authors_and_Tutors (author_id VARCHAR, personal_name VARCHAR); CREATE TABLE Courses (course_name VARCHAR, author_id VARCHAR)

Answer: [SQL] SELECT T2.course_name FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id WHERE T1.personal_name = "Julio" [/SQL]


Question: Find the names and descriptions of courses that belong to the subject named "Computer Science".

Context: CREATE TABLE Courses (course_name VARCHAR, course_description VARCHAR, subject_id VARCHAR); CREATE TABLE Subjects (subject_id VARCHAR, subject_name VARCHAR)

Answer: [SQL] SELECT T1.course_name, T1.course_description FROM Courses AS T1 JOIN Subjects AS T2 ON T1.subject_id = T2.subject_id WHERE T2.subject_name = "Computer Science" [/SQL]


Question: Find the subject ID, subject name, and the corresponding number of available courses for each subject.

Context: CREATE TABLE Courses (subject_id VARCHAR); CREATE TABLE Subjects (subject_name VARCHAR, subject_id VARCHAR)

Answer: [SQL] SELECT T1.subject_id, T2.subject_name, COUNT(*) FROM Courses AS T1 JOIN Subjects AS T2 ON T1.subject_id = T2.subject_id GROUP BY T1.subject_id [/SQL]


Question: Find the subject ID, name of subject and the corresponding number of courses for each subject, and sort by the course count in ascending order.

Answer: [SQL] SELECT T1.subject_id, T2.subject_name, COUNT(*) FROM Courses AS T1 JOIN Subjects AS T2 ON T1.subject_id = T2.subject_id GROUP BY T1.subject_id ORDER BY COUNT(*) [/SQL]


Question: What is the date of enrollment of the course named "Spanish"?

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, course_id VARCHAR); CREATE TABLE Courses (course_id VARCHAR, course_name VARCHAR)

Answer: [SQL] SELECT T2.date_of_enrolment FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "Spanish" [/SQL]


Question: What is the name of the course that has the most student enrollment?

Context: CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Student_Course_Enrolment (course_id VARCHAR)

Answer: [SQL] SELECT T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the names of the courses that have exactly 1 student enrollment?

Answer: [SQL] SELECT T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name HAVING COUNT(*) = 1 [/SQL]


Question: What are the descriptions and names of the courses that have student enrollment bigger than 2?

Context: CREATE TABLE Student_Course_Enrolment (course_id VARCHAR); CREATE TABLE Courses (course_description VARCHAR, course_name VARCHAR, course_id VARCHAR)

Answer: [SQL] SELECT T1.course_description, T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name HAVING COUNT(*) > 2 [/SQL]


Question: What is the name of each course and the corresponding number of student enrollment?

Answer: [SQL] SELECT T1.course_name, COUNT(*) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name [/SQL]


Question: What are the enrollment dates of all the tests that have result "Pass"?

Context: CREATE TABLE Student_Tests_Taken (registration_id VARCHAR, test_result VARCHAR); CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, registration_id VARCHAR)

Answer: [SQL] SELECT T1.date_of_enrolment FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Pass" [/SQL]


Question: What are the completion dates of all the tests that have result "Fail"?

Context: CREATE TABLE Student_Tests_Taken (registration_id VARCHAR, test_result VARCHAR); CREATE TABLE Student_Course_Enrolment (date_of_completion VARCHAR, registration_id VARCHAR)

Answer: [SQL] SELECT T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Fail" [/SQL]


Question: List the dates of enrollment and completion of the student with personal name "Karson".

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, date_of_completion VARCHAR, student_id VARCHAR); CREATE TABLE Students (student_id VARCHAR, personal_name VARCHAR)

Answer: [SQL] SELECT T1.date_of_enrolment, T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.personal_name = "Karson" [/SQL]


Question: List the dates of enrollment and completion of the student with family name "Zieme" and personal name "Bernie".

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, date_of_completion VARCHAR, student_id VARCHAR); CREATE TABLE Students (student_id VARCHAR, family_name VARCHAR, personal_name VARCHAR)

Answer: [SQL] SELECT T1.date_of_enrolment, T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.family_name = "Zieme" AND T2.personal_name = "Bernie" [/SQL]


Question: Find the student ID and login name of the student with the most course enrollments

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (login_name VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT T1.student_id, T2.login_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the student ID and personal name of the student with at least two enrollments.

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (personal_name VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT T1.student_id, T2.personal_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) >= 2 [/SQL]


Question: Find the student ID and middle name for all the students with at most two enrollments.

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (middle_name VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT T1.student_id, T2.middle_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) <= 2 [/SQL]


Question: Find the personal names of students not enrolled in any course.

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (personal_name VARCHAR); CREATE TABLE Students (personal_name VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT personal_name FROM Students EXCEPT SELECT T1.personal_name FROM Students AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.student_id = T2.student_id [/SQL]


Question: How many students did not have any course enrollment?

Context: CREATE TABLE Students (student_id VARCHAR); CREATE TABLE Student_Course_Enrolment (student_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Students WHERE NOT student_id IN (SELECT student_id FROM Student_Course_Enrolment) [/SQL]


Question: Find the common login name of course authors and students.

Context: CREATE TABLE Course_Authors_and_Tutors (login_name VARCHAR); CREATE TABLE Students (login_name VARCHAR)

Answer: [SQL] SELECT login_name FROM Course_Authors_and_Tutors INTERSECT SELECT login_name FROM Students [/SQL]


Question: Find the common personal name of course authors and students.

Context: CREATE TABLE Course_Authors_and_Tutors (personal_name VARCHAR); CREATE TABLE Students (personal_name VARCHAR)

Answer: [SQL] SELECT personal_name FROM Course_Authors_and_Tutors INTERSECT SELECT personal_name FROM Students [/SQL]


Question: Which claims caused more than 2 settlements or have the maximum claim value? List the date the claim was made and the claim id.

Context: CREATE TABLE Settlements (Claim_id VARCHAR); CREATE TABLE Claims (Amount_Claimed INTEGER); CREATE TABLE Claims (Date_Claim_Made VARCHAR, Claim_id VARCHAR, Amount_Claimed INTEGER)

Answer: [SQL] SELECT T1.Date_Claim_Made, T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id GROUP BY T1.Claim_id HAVING COUNT(*) > 2 UNION SELECT T1.Date_Claim_Made, T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id WHERE T1.Amount_Claimed = (SELECT MAX(Amount_Claimed) FROM Claims) [/SQL]


Question: Which customer had at least 2 policies but did not file any claims? List the customer details and id.

Context: CREATE TABLE Customers (customer_details VARCHAR, customer_id VARCHAR, Customer_id VARCHAR); CREATE TABLE Customer_Policies (customer_id VARCHAR, policy_id VARCHAR); CREATE TABLE Claims (policy_id VARCHAR)

Answer: [SQL] SELECT T1.customer_details, T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 2 EXCEPT SELECT T1.customer_details, T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id = T2.customer_id JOIN Claims AS T3 ON T2.policy_id = T3.policy_id [/SQL]


Question: List the method, date and amount of all the payments, in ascending order of date.

Context: CREATE TABLE Payments (Payment_Method_Code VARCHAR, Date_Payment_Made VARCHAR, Amount_Payment VARCHAR)

Answer: [SQL] SELECT Payment_Method_Code, Date_Payment_Made, Amount_Payment FROM Payments ORDER BY Date_Payment_Made [/SQL]


Question: Among all the claims, what is the settlement amount of the claim with the largest claim amount? List both the settlement amount and claim amount.

Context: CREATE TABLE Claims (Amount_Settled VARCHAR, Amount_Claimed VARCHAR)

Answer: [SQL] SELECT Amount_Settled, Amount_Claimed FROM Claims ORDER BY Amount_Claimed DESC LIMIT 1 [/SQL]


Question: Among all the claims, what is the amount claimed in the claim with the least amount settled? List both the settlement amount and claim amount.

Answer: [SQL] SELECT Amount_Settled, Amount_Claimed FROM Claims ORDER BY Amount_Settled LIMIT 1 [/SQL]


Question: Among all the claims, which claims have a claimed amount larger than the average? List the date the claim was made and the date it was settled.

Context: CREATE TABLE Claims (Date_Claim_Made VARCHAR, Date_Claim_Settled VARCHAR, Amount_Claimed INTEGER)

Answer: [SQL] SELECT Date_Claim_Made, Date_Claim_Settled FROM Claims WHERE Amount_Claimed > (SELECT AVG(Amount_Claimed) FROM Claims) [/SQL]


Question: Among all the claims, which settlements have a claimed amount that is no more than the average? List the claim start date.

Context: CREATE TABLE Claims (Date_Claim_Made VARCHAR, Amount_Settled INTEGER)

Answer: [SQL] SELECT Date_Claim_Made FROM Claims WHERE Amount_Settled <= (SELECT AVG(Amount_Settled) FROM Claims) [/SQL]


Question: How many settlements does each claim correspond to? List the claim id and the number of settlements.

Context: CREATE TABLE Settlements (claim_id VARCHAR); CREATE TABLE Claims (Claim_id VARCHAR, claim_id VARCHAR)

Answer: [SQL] SELECT T1.Claim_id, COUNT(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id [/SQL]


Question: Which claim incurred the most number of settlements? List the claim id, the date the claim was made, and the number.

Context: CREATE TABLE Claims (claim_id VARCHAR, date_claim_made VARCHAR); CREATE TABLE Settlements (claim_id VARCHAR)

Answer: [SQL] SELECT T1.claim_id, T1.date_claim_made, COUNT(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many settlements were made on the claim with the most recent claim settlement date? List the number and the claim id.

Context: CREATE TABLE Settlements (claim_id VARCHAR); CREATE TABLE Claims (claim_id VARCHAR, Date_Claim_Settled VARCHAR)

Answer: [SQL] SELECT COUNT(*), T1.claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id ORDER BY T1.Date_Claim_Settled DESC LIMIT 1 [/SQL]


Question: Of all the claims, what was the earliest date when any claim was made?

Context: CREATE TABLE Claims (Date_Claim_Made VARCHAR)

Answer: [SQL] SELECT Date_Claim_Made FROM Claims ORDER BY Date_Claim_Made LIMIT 1 [/SQL]


Question: What is the total amount of settlement made for all the settlements?

Context: CREATE TABLE Settlements (Amount_Settled INTEGER)

Answer: [SQL] SELECT SUM(Amount_Settled) FROM Settlements [/SQL]


Question: Who are the customers that had more than 1 policy? List the customer details and id.

Context: CREATE TABLE Customers (customer_details VARCHAR, customer_id VARCHAR, Customer_id VARCHAR); CREATE TABLE Customer_Policies (Customer_id VARCHAR)

Answer: [SQL] SELECT T1.customer_details, T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id = T2.Customer_id GROUP BY T1.customer_id HAVING COUNT(*) > 1 [/SQL]


Question: What are the claim dates and settlement dates of all the settlements?

Context: CREATE TABLE Settlements (Date_Claim_Made VARCHAR, Date_Claim_Settled VARCHAR)

Answer: [SQL] SELECT Date_Claim_Made, Date_Claim_Settled FROM Settlements [/SQL]


Question: What is the most popular payment method?

Context: CREATE TABLE Payments (Payment_Method_Code VARCHAR)

Answer: [SQL] SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: With which kind of payment method were the least number of payments processed?

Answer: [SQL] SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: What is the total amount of payment?

Context: CREATE TABLE Payments (Amount_Payment INTEGER)

Answer: [SQL] SELECT SUM(Amount_Payment) FROM Payments [/SQL]


Question: What are all the distinct details of the customers?

Context: CREATE TABLE Customers (customer_details VARCHAR)

Answer: [SQL] SELECT DISTINCT customer_details FROM Customers [/SQL]


Question: Which kind of policy type was chosen by the most customers?

Context: CREATE TABLE Customer_Policies (Policy_Type_Code VARCHAR)

Answer: [SQL] SELECT Policy_Type_Code FROM Customer_Policies GROUP BY Policy_Type_Code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many settlements are there in total?

Context: CREATE TABLE Settlements (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Settlements [/SQL]


Question: Which Payments were processed with Visa? List the payment Id, the date and the amount.

Context: CREATE TABLE Payments (Payment_ID VARCHAR, Date_Payment_Made VARCHAR, Amount_Payment VARCHAR, Payment_Method_Code VARCHAR)

Answer: [SQL] SELECT Payment_ID, Date_Payment_Made, Amount_Payment FROM Payments WHERE Payment_Method_Code = 'Visa' [/SQL]


Question: List the details of the customers who do not have any policies.

Context: CREATE TABLE Customer_Policies (customer_id VARCHAR); CREATE TABLE Customers (customer_details VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_details VARCHAR)

Answer: [SQL] SELECT customer_details FROM Customers EXCEPT SELECT T1.customer_details FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.customer_id = T2.customer_id [/SQL]


Question: List the date the claim was made, the date it was settled and the amount settled for all the claims which had exactly one settlement.

Context: CREATE TABLE Claims (claim_id VARCHAR, date_claim_made VARCHAR, Date_Claim_Settled VARCHAR, Claim_id VARCHAR); CREATE TABLE Settlements (Claim_id VARCHAR)

Answer: [SQL] SELECT T1.claim_id, T1.date_claim_made, T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id GROUP BY T1.claim_id HAVING COUNT(*) = 1 [/SQL]


Question: Find the total claimed amount of all the claims.

Context: CREATE TABLE Claims (Amount_Claimed INTEGER)

Answer: [SQL] SELECT SUM(Amount_Claimed) FROM Claims [/SQL]


Question: Which department has the largest number of employees?

Context: CREATE TABLE department (name VARCHAR, departmentID VARCHAR)

Answer: [SQL] SELECT name FROM department GROUP BY departmentID ORDER BY COUNT(departmentID) DESC LIMIT 1 [/SQL]


Question: What is the employee id of the head whose department has the least number of employees?

Context: CREATE TABLE department (head VARCHAR, departmentID VARCHAR)

Answer: [SQL] SELECT head FROM department GROUP BY departmentID ORDER BY COUNT(departmentID) LIMIT 1 [/SQL]


Question: what is the name and position of the head whose department has least number of employees?

Context: CREATE TABLE department (head VARCHAR); CREATE TABLE physician (name VARCHAR, position VARCHAR, EmployeeID VARCHAR)

Answer: [SQL] SELECT T2.name, T2.position FROM department AS T1 JOIN physician AS T2 ON T1.head = T2.EmployeeID GROUP BY departmentID ORDER BY COUNT(departmentID) LIMIT 1 [/SQL]


Question: What are names of patients who made an appointment?

Context: CREATE TABLE appointment (patient VARCHAR); CREATE TABLE patient (ssn VARCHAR)

Answer: [SQL] SELECT name FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn [/SQL]


Question: what are name and phone number of patients who had more than one appointment?

Answer: [SQL] SELECT name, phone FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn GROUP BY T1.patient HAVING COUNT(*) > 1 [/SQL]


Question: Find the id of the appointment with the most recent start date?

Context: CREATE TABLE appointment (appointmentid VARCHAR, START VARCHAR)

Answer: [SQL] SELECT appointmentid FROM appointment ORDER BY START DESC LIMIT 1 [/SQL]


Question: List the name of physicians who took some appointment.

Context: CREATE TABLE appointment (Physician VARCHAR); CREATE TABLE physician (name VARCHAR, EmployeeID VARCHAR)

Answer: [SQL] SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID [/SQL]


Question: List the name of physicians who never took any appointment.

Context: CREATE TABLE physician (name VARCHAR); CREATE TABLE appointment (Physician VARCHAR); CREATE TABLE physician (name VARCHAR, EmployeeID VARCHAR)

Answer: [SQL] SELECT name FROM physician EXCEPT SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID [/SQL]


Question: Find the names of all physicians and their primary affiliated departments' names.

Context: CREATE TABLE department (name VARCHAR, DepartmentID VARCHAR); CREATE TABLE affiliated_with (physician VARCHAR, department VARCHAR, PrimaryAffiliation VARCHAR); CREATE TABLE physician (name VARCHAR, EmployeeID VARCHAR)

Answer: [SQL] SELECT T1.name, T3.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.department = T3.DepartmentID WHERE T2.PrimaryAffiliation = 1 [/SQL]


Question: What is the name of the patient who made the most recent appointment?

Context: CREATE TABLE patient (name VARCHAR, ssn VARCHAR); CREATE TABLE appointment (patient VARCHAR, start VARCHAR)

Answer: [SQL] SELECT T1.name FROM patient AS T1 JOIN appointment AS T2 ON T1.ssn = T2.patient ORDER BY T2.start DESC LIMIT 1 [/SQL]


Question: How many patients stay in room 112?

Context: CREATE TABLE stay (patient VARCHAR, room VARCHAR)

Answer: [SQL] SELECT COUNT(patient) FROM stay WHERE room = 112 [/SQL]


Question: How many patients' prescriptions are made by physician John Dorian?

Context: CREATE TABLE patient (SSN VARCHAR); CREATE TABLE prescribes (patient VARCHAR, physician VARCHAR); CREATE TABLE physician (employeeid VARCHAR, name VARCHAR)

Answer: [SQL] SELECT COUNT(T1.SSN) FROM patient AS T1 JOIN prescribes AS T2 ON T1.SSN = T2.patient JOIN physician AS T3 ON T2.physician = T3.employeeid WHERE T3.name = "John Dorian" [/SQL]


Question: Find the name of medication used on the patient who stays in room 111?

Context: CREATE TABLE Prescribes (Patient VARCHAR, Medication VARCHAR); CREATE TABLE Medication (name VARCHAR, Code VARCHAR); CREATE TABLE patient (SSN VARCHAR); CREATE TABLE stay (Patient VARCHAR)

Answer: [SQL] SELECT T4.name FROM stay AS T1 JOIN patient AS T2 ON T1.Patient = T2.SSN JOIN Prescribes AS T3 ON T3.Patient = T2.SSN JOIN Medication AS T4 ON T3.Medication = T4.Code WHERE room = 111 [/SQL]


Question: Find the patient who most recently stayed in room 111.

Context: CREATE TABLE stay (patient VARCHAR, room VARCHAR, staystart VARCHAR)

Answer: [SQL] SELECT patient FROM stay WHERE room = 111 ORDER BY staystart DESC LIMIT 1 [/SQL]


Question: What is the name of the nurse has the most appointments?

Context: CREATE TABLE nurse (name VARCHAR, employeeid VARCHAR); CREATE TABLE appointment (prepnurse VARCHAR)

Answer: [SQL] SELECT T1.name FROM nurse AS T1 JOIN appointment AS T2 ON T1.employeeid = T2.prepnurse GROUP BY T1.employeeid ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many patients do each physician take care of? List their names and number of patients they take care of.

Context: CREATE TABLE patient (PCP VARCHAR); CREATE TABLE physician (name VARCHAR, employeeid VARCHAR)

Answer: [SQL] SELECT T1.name, COUNT(*) FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid [/SQL]


Question: Find the name of physicians who are in charge of more than one patient.

Answer: [SQL] SELECT T1.name FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid HAVING COUNT(*) > 1 [/SQL]