aherntech/sparc huggingface dataset:
Database: dorm_1
Question sequence:
find the number of students living in each city.
how many of them are male (with sex M)?
Include their average age as well.
SQL query sequence:
SELECT count(*), city_code FROM student GROUP BY city_code
SELECT count(*), city_code FROM student WHERE sex  =  'M' GROUP BY city_code
SELECT count(*) ,  avg(age) ,  city_code FROM student WHERE sex  =  'M' GROUP BY city_code
Final question: Find the average age and number of male students (with sex M) from each city.
Final SQL: SELECT count(*) ,  avg(age) ,  city_code FROM student WHERE sex  =  'M' GROUP BY city_code
Database: dorm_1
Question sequence:
Find the number of students living in each city.
just show the results of cities that have more than one student living in it.
SQL query sequence:
SELECT count(*),  city_code FROM student GROUP BY city_code
SELECT count(*) ,  city_code FROM student GROUP BY city_code HAVING count(*)  >  1
Final question: Find the number of students for the cities where have more than one student.
Final SQL: SELECT count(*) ,  city_code FROM student GROUP BY city_code HAVING count(*)  >  1
Database: dorm_1
Question sequence:
list all of the different majors.
which major has the fewest students?
what is the most popular major?
how many students are not this major?
show their first and last names.
SQL query sequence:
SELECT distinct major FROM student
SELECT major FROM student GROUP BY major ORDER BY count(*) LIMIT 1
SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1
SELECT count(*) FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
SELECT fname ,  lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
Final question: Find the first and last name of students who are not in the largest major.
Final SQL: SELECT fname ,  lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
Database: dorm_1
Question sequence:
what is the average age for each gender?
find the number of students whose age is older than the average age of these two groups.
SQL query sequence:
SELECT avg(age) ,  sex FROM student GROUP BY sex
SELECT count(*) ,  sex FROM student WHERE age  >  (SELECT avg(age) FROM student) GROUP BY sex
Final question: Find the number of students whose age is older than the average age for each gender.
Final SQL: SELECT count(*) ,  sex FROM student WHERE age  >  (SELECT avg(age) FROM student) GROUP BY sex
Database: dorm_1
Question sequence:
what are the names of all of the dorms?
how many students are living in each dorm? Group by names of dorms.
find the average age of students living in each dorm.
SQL query sequence:
SELECT dorm_name FROM dorm
SELECT count(*),  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid GROUP BY T3.dorm_name
SELECT avg(T1.age) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid GROUP BY T3.dorm_name
Final question: Find the average age of students living in each dorm and the name of dorm.
Final SQL: SELECT avg(T1.age) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid GROUP BY T3.dorm_name
Database: dorm_1
Question sequence:
find the names of dorms that can accommodate more than 100 students.
what is the average capacity of these dorms?
Find the number of amenities for each of these dorms.
SQL query sequence:
SELECT dorm_name FROM dorm WHERE student_capacity  >  100
SELECT avg(student_capacity) FROM dorm WHERE student_capacity  >  100
SELECT count(*) ,  T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid WHERE T1.student_capacity  >  100 GROUP BY T1.dormid
Final question: Find the number of amenities for each of the dorms that can accommodate more than 100 students.
Final SQL: SELECT count(*) ,  T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid WHERE T1.student_capacity  >  100 GROUP BY T1.dormid
Database: dorm_1
Question sequence:
what are the names of all dorms?
how many students are living in each dorm? Group by names of dorms.
how many students are older than 20 years old in each dorm?
SQL query sequence:
SELECT dorm_name FROM dorm
SELECT count(*),  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid GROUP BY T3.dorm_name
SELECT count(*) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T1.age  >  20 GROUP BY T3.dorm_name
Final question: Find the number of students who is older than 20 in each dorm.
Final SQL: SELECT count(*) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T1.age  >  20 GROUP BY T3.dorm_name
Database: dorm_1
Question sequence:
how many students are living in Smith Hall?
show their last names and room numbers.
what are their first names?
SQL query sequence:
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall'
SELECT T1.lname, T2.room_number FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall'
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall'
Final question: Find the first name of students who are living in the Smith Hall.
Final SQL: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall'
Database: dorm_1
Question sequence:
show the name and capacity of all dorms.
find the name of the dorm with the largest capacity.
how many students are living in there?
what is the average age of these students?
SQL query sequence:
SELECT dorm_name, student_capacity FROM dorm
SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.student_capacity  =  (SELECT max(student_capacity) FROM dorm)
SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.student_capacity  =  (SELECT max(student_capacity) FROM dorm)
Final question: Find the average age of students who are living in the dorm with the largest capacity.
Final SQL: SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.student_capacity  =  (SELECT max(student_capacity) FROM dorm)
Database: dorm_1
Question sequence:
list the names of all male dorms (with gender M).
how many are there?
Find the total number of students living in these dorms.
SQL query sequence:
SELECT dorm_name FROM dorm WHERE gender  =  'M'
SELECT count(*) FROM dorm WHERE gender  =  'M'
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.gender  =  'M'
Final question: Find the total number of students living in the male dorm (with gender M).
Final SQL: SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.gender  =  'M'
Database: dorm_1
Question sequence:
what is the capacity of Smith Hall dorm?
how many students are living in there?
how many of them are female?
SQL query sequence:
SELECT student_capacity FROM dorm WHERE dorm_name  =  'Smith Hall'
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall'
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall' AND T1.sex  =  'F'
Final question: Find the number of female students (with F sex) living in Smith Hall
Final SQL: SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall' AND T1.sex  =  'F'
Database: dorm_1
Question sequence:
how many students are living in Smith Hall dorm?
Find the number of amenities it has.
what are these amenities?
SQL query sequence:
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall'
SELECT count(*) FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall'
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall'
Final question: Find the name of amenities Smith Hall dorm have.
Final SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall'
Database: dorm_1
Question sequence:
What are the amenities in Smith Hall?
order the results by amenity names.
SQL query sequence:
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall'
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall' ORDER BY T3.amenity_name
Final question: Find the name of amenities Smith Hall dorm have. ordered the results by amenity names.
Final SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall' ORDER BY T3.amenity_name
Database: dorm_1
Question sequence:
show the names of all different amenities.
find the total number of each amenity in all of the dorms.
which one is the most common amenity used in all dorms? List its name.
SQL query sequence:
SELECT amenity_name FROM dorm_amenity
SELECT count(*), T2.amenid FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid  =  T2.amenid GROUP BY T2.amenid
SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid  =  T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1
Final question: Find the name of amenity that is the most common in all dorms.
Final SQL: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid  =  T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1
Database: dorm_1
Question sequence:
what is the id of the dorm that has the most amenities?
what is its name?
how many students are living in that dorm?
find their first names.
SQL query sequence:
SELECT T3.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid  =  T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid  =  T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1
SELECT T3.dorm_name FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid  =  T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid  =  T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid  =  T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid  =  T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1)
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid  =  T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid  =  T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1)
Final question: Find the first name of students who are living in the dorm that has most number of amenities.
Final SQL: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid  =  T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid  =  T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1)
Database: dorm_1
Question sequence:
find the number of amenities in each dorm.
which dorm has the fewest amenities? List its name.
what is its capacity?
SQL query sequence:
SELECT T1.dormid , count(*) FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid GROUP BY T2.dormid
SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1
SELECT T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1
Final question: Find the name and capacity of the dorm with least number of amenities.
Final SQL: SELECT T1.dorm_name ,  T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1
Database: dorm_1
Question sequence:
how many dorms have a TV Lounge?
what are their names?
what are the names of dorms that do not have it?
SQL query sequence:
SELECT count(*) FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge'
SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge'
SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge'
Final question: Find the name of dorms that do not have amenity TV Lounge.
Final SQL: SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge'
Database: dorm_1
Question sequence:
how many dorms have a TV Lounge?
what is the total capacity of these dorms?
how many students are living in these dorms?
list their first and last names.
SQL query sequence:
SELECT COUNT(*) FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge'
SELECT sum(T1.student_capacity) FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge'
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge')
SELECT T1.fname ,  T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge')
Final question: Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
Final SQL: SELECT T1.fname ,  T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge')
Database: dorm_1
Question sequence:
Find the names of dorms that do not have a TV Lounge.
Find the first name and age of students living in these dorms.
SQL query sequence:
SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge'
SELECT T1.fname ,  T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge')
Final question: Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.
Final SQL: SELECT T1.fname ,  T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge')
Database: cre_Doc_Control_Systems
Question sequence:
Show me all about documents.
What document types are there?
How about document status codes?
SQL query sequence:
SELECT * FROM documents
SELECT document_type_code FROM Ref_Document_Types;
SELECT document_status_code FROM Ref_Document_Status;
Final question: What document status codes do we have?
Final SQL: SELECT document_status_code FROM Ref_Document_Status;
Database: cre_Doc_Control_Systems
Question sequence:
How many document status codes there?
What are they?
What is the description of document status code 'working'?
SQL query sequence:
SELECT count(document_status_code) FROM Ref_Document_Status;
SELECT document_status_code FROM Ref_Document_Status;
SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working";
Final question: What is the description of document status code 'working'?
Final SQL: SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working";
Database: cre_Doc_Control_Systems
Question sequence:
Show me all about document types.
Show me the descriptions of document types.
Now, show the document type codes.
SQL query sequence:
SELECT * FROM Ref_Document_Types;
SELECT document_type_description FROM Ref_Document_Types;
SELECT document_type_code FROM Ref_Document_Types;
Final question: What document type codes do we have?
Final SQL: SELECT document_type_code FROM Ref_Document_Types;
Database: cre_Doc_Control_Systems
Question sequence:
Show me the shipping agent code of documents?
How about the document type code?
Among those, what is the description of document type 'Paper'?
SQL query sequence:
SELECT shipping_agent_code FROM Ref_Shipping_Agents;
SELECT document_type_code FROM Ref_Document_Types;
SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper";
Final question: What is the description of document type 'Paper'?
Final SQL: SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper";
Database: cre_Doc_Control_Systems
Question sequence:
What are the shipping agents' codes?
How about their descriptions?
Show me their names instead.
SQL query sequence:
SELECT shipping_agent_code FROM Ref_Shipping_Agents;
SELECT shipping_agent_description FROM Ref_Shipping_Agents;
SELECT shipping_agent_name FROM Ref_Shipping_Agents;
Final question: What are the shipping agent names?
Final SQL: SELECT shipping_agent_name FROM Ref_Shipping_Agents;
Database: cre_Doc_Control_Systems
Question sequence:
Show me the the shipping agent code of shipping agent Fedex.
How about the shipping agent description of shipping agent UPS?
What is the shipping agent code of this shipping agent?
SQL query sequence:
SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "Fedex";
SELECT shipping_agent_description FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";
SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";
Final question: What is the shipping agent code of shipping agent UPS?
Final SQL: SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";
Database: cre_Doc_Control_Systems
Question sequence:
Show me all the descriptions for each role?
Now show all the role codes.
SQL query sequence:
SELECT role_description FROM ROLES;
SELECT role_code FROM ROLES;
Final question: What are all role codes?
Final SQL: SELECT role_code FROM ROLES;
Database: cre_Doc_Control_Systems
Question sequence:
How many employees have role code ED?
What is the description for this role code?
SQL query sequence:
SELECT count(*) FROM Employees WHERE role_code = "ED";
SELECT role_description FROM ROLES WHERE role_code = "ED";
Final question: What is the description of role code ED?
Final SQL: SELECT role_description FROM ROLES WHERE role_code = "ED";
Database: cre_Doc_Control_Systems
Question sequence:
What are the employees' names?
How many are there?
SQL query sequence:
SELECT employee_name FROM Employees;
SELECT count(*) FROM Employees;
Final question: How many employees do we have?
Final SQL: SELECT count(*) FROM Employees;
Database: cre_Doc_Control_Systems
Question sequence:
Show me the names of the employee.
What is the role code of the employee named Koby?
How about his role description?
SQL query sequence:
SELECT employee_name FROM Employees;
SELECT T1.role_code FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";
SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";
Final question: What is the role of the employee named Koby?
Final SQL: SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";
Database: cre_Doc_Control_Systems
Question sequence:
Show me all information about the documents.
List document ids and receipt dates of all documents
SQL query sequence:
SELECT * FROM Documents;
SELECT document_id ,  receipt_date FROM Documents;
Final question: List all document ids and receipt dates of documents.
Final SQL: SELECT document_id ,  receipt_date FROM Documents;
Database: cre_Doc_Control_Systems
Question sequence:
What are the role codes?
How about their corresponding role_description?
List role description, role code and number of employees of each role?
SQL query sequence:
SELECT role_code FROM ROLES;
SELECT role_code, role_description FROM ROLES;
SELECT T1.role_description ,  T2.role_code ,  count(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code;
Final question: How many employees does each role have? List role description, id and number of employees.
Final SQL: SELECT T1.role_description ,  T2.role_code ,  count(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code;
Database: cre_Doc_Control_Systems
Question sequence:
What are the employees' id?
Which of those ids correspond to roles with more than 2 employees? Show in conjunction to the ids.
How about more than 1 employee? Now only show the role description and number of employee ids.
SQL query sequence:
SELECT employee_id FROM Employees;
SELECT Roles.role_description, Employees.employee_id FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id)  >  2;
SELECT Roles.role_description , count(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id)  >  1;
Final question: List roles that have more than one employee. List the role description and number of employees.
Final SQL: SELECT Roles.role_description , count(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id)  >  1;