spider_version
int64
1
2
db_id
stringclasses
204 values
schema
stringclasses
187 values
question
stringlengths
3
328
query
stringlengths
20
3.81k
1
club_1
Count the total number of clubs.
SELECT count(*) FROM club
1
club_1
What are the names of all clubs?
SELECT clubname FROM club
1
club_1
Give me the name of each club.
SELECT clubname FROM club
1
club_1
How many students are there?
SELECT count(*) FROM student
1
club_1
Count the total number of students.
SELECT count(*) FROM student
1
club_1
What are the first names of all the students?
SELECT DISTINCT fname FROM student
1
club_1
Find each student's first name.
SELECT DISTINCT fname FROM student
1
club_1
Find the last names of the members of the club "Bootup Baltimore".
SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore"
1
club_1
Who are the members of the club named "Bootup Baltimore"? Give me their last names.
SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore"
1
club_1
Who are the members of the club named "Hopkins Student Enterprises"? Show the last name.
SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"
1
club_1
Return the last name for the members of the club named "Hopkins Student Enterprises".
SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"
1
club_1
How many members does the club "Tennis Club" has?
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Tennis Club"
1
club_1
Count the members of the club "Tennis Club".
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Tennis Club"
1
club_1
Find the number of members of club "Pen and Paper Gaming".
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Pen and Paper Gaming"
1
club_1
How many people have membership in the club "Pen and Paper Gaming"?
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Pen and Paper Gaming"
1
club_1
How many clubs does "Linda Smith" belong to?
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Linda" AND t3.lname = "Smith"
1
club_1
How many clubs does "Linda Smith" have membership for?
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Linda" AND t3.lname = "Smith"
1
club_1
Find the number of clubs where "Tracy Kim" is a member.
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Tracy" AND t3.lname = "Kim"
1
club_1
For how many clubs is "Tracy Kim" a member?
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Tracy" AND t3.lname = "Kim"
1
club_1
Find all the female members of club "Bootup Baltimore". Show the first name and last name.
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.sex = "F"
1
club_1
Give me the first name and last name for all the female members of the club "Bootup Baltimore".
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.sex = "F"
1
club_1
Find all the male members of club "Hopkins Student Enterprises". Show the first name and last name.
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t3.sex = "M"
1
club_1
What are the first name and last name of each male member in club "Hopkins Student Enterprises"?
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t3.sex = "M"
1
club_1
Find all members of "Bootup Baltimore" whose major is "600". Show the first name and last name.
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.major = "600"
1
club_1
Which members of "Bootup Baltimore" major in "600"? Give me their first names and last names.
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.major = "600"
1
club_1
Which club has the most members majoring in "600"?
SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.major = "600" GROUP BY t1.clubname ORDER BY count(*) DESC LIMIT 1
1
club_1
Find the club which has the largest number of members majoring in "600".
SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.major = "600" GROUP BY t1.clubname ORDER BY count(*) DESC LIMIT 1
1
club_1
Find the name of the club that has the most female students.
SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.sex = "F" GROUP BY t1.clubname ORDER BY count(*) DESC LIMIT 1
1
club_1
Which club has the most female students as their members? Give me the name of the club.
SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.sex = "F" GROUP BY t1.clubname ORDER BY count(*) DESC LIMIT 1
1
club_1
What is the description of the club named "Tennis Club"?
SELECT clubdesc FROM club WHERE clubname = "Tennis Club"
1
club_1
Find the description of the club called "Tennis Club".
SELECT clubdesc FROM club WHERE clubname = "Tennis Club"
1
club_1
Find the description of the club "Pen and Paper Gaming".
SELECT clubdesc FROM club WHERE clubname = "Pen and Paper Gaming"
1
club_1
What is the description of the club "Pen and Paper Gaming"?
SELECT clubdesc FROM club WHERE clubname = "Pen and Paper Gaming"
1
club_1
What is the location of the club named "Tennis Club"?
SELECT clublocation FROM club WHERE clubname = "Tennis Club"
1
club_1
Where us the club named "Tennis Club" located?
SELECT clublocation FROM club WHERE clubname = "Tennis Club"
1
club_1
Find the location of the club "Pen and Paper Gaming".
SELECT clublocation FROM club WHERE clubname = "Pen and Paper Gaming"
1
club_1
Where is the club "Pen and Paper Gaming" located?
SELECT clublocation FROM club WHERE clubname = "Pen and Paper Gaming"
1
club_1
Where is the club "Hopkins Student Enterprises" located?
SELECT clublocation FROM club WHERE clubname = "Hopkins Student Enterprises"
1
club_1
Tell me the location of the club "Hopkins Student Enterprises".
SELECT clublocation FROM club WHERE clubname = "Hopkins Student Enterprises"
1
club_1
Find the name of all the clubs at "AKW".
SELECT clubname FROM club WHERE clublocation = "AKW"
1
club_1
Which clubs are located at "AKW"? Return the club names.
SELECT clubname FROM club WHERE clublocation = "AKW"
1
club_1
How many clubs are located at "HHH"?
SELECT count(*) FROM club WHERE clublocation = "HHH"
1
club_1
Count the number of clubs located at "HHH".
SELECT count(*) FROM club WHERE clublocation = "HHH"
1
club_1
What are the first and last name of the president of the club "Bootup Baltimore"?
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t2.position = "President"
1
club_1
Who is the president of the club "Bootup Baltimore"? Give me the first and last name.
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t2.position = "President"
1
club_1
Who is the "CTO" of club "Hopkins Student Enterprises"? Show the first name and last name.
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t2.position = "CTO"
1
club_1
Find the first name and last name for the "CTO" of the club "Hopkins Student Enterprises"?
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t2.position = "CTO"
1
club_1
How many different roles are there in the club "Bootup Baltimore"?
SELECT count(DISTINCT t2.position) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid WHERE t1.clubname = "Bootup Baltimore"
1
club_1
Count the number of different positions in the club "Bootup Baltimore".
SELECT count(DISTINCT t2.position) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid WHERE t1.clubname = "Bootup Baltimore"
1
club_1
How many members of "Bootup Baltimore" are older than 18?
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age > 18
1
club_1
Count the number of members in club "Bootup Baltimore" whose age is above 18.
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age > 18
1
club_1
How many members of club "Bootup Baltimore" are younger than 18?
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age < 18
1
club_1
Count the number of members in club "Bootup Baltimore" whose age is below 18.
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age < 18
1
club_1
Find the names of all the clubs that have at least a member from the city with city code "BAL".
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "BAL"
1
club_1
Which clubs have one or more members from the city with code "BAL"? Give me the names of the clubs.
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "BAL"
1
club_1
Find the names of the clubs that have at least a member from the city with city code "HOU".
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "HOU"
1
club_1
Which clubs have one or more members from the city with code "HOU"? Give me the names of the clubs.
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "HOU"
1
club_1
How many clubs does the student named "Eric Tai" belong to?
SELECT count(DISTINCT t1.clubname) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Eric" AND t3.lname = "Tai"
1
club_1
Count the number of clubs for which the student named "Eric Tai" is a member.
SELECT count(DISTINCT t1.clubname) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Eric" AND t3.lname = "Tai"
1
club_1
List the clubs having "Davis Steven" as a member.
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Davis" AND t3.lname = "Steven"
1
club_1
What are the names of the clubs that have "Davis Steven" as a member?
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Davis" AND t3.lname = "Steven"
1
club_1
List the clubs that have at least a member with advisor "1121".
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.advisor = 1121
1
club_1
Which clubs have one or more members whose advisor is "1121"?
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.advisor = 1121
1
club_1
What is the average age of the members of the club "Bootup Baltimore"?
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore"
1
club_1
Find the average age of the members in the club "Bootup Baltimore".
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore"
1
club_1
Find the average age of members of the club "Hopkins Student Enterprises".
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"
1
club_1
On average, how old are the members in the club "Hopkins Student Enterprises"?
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"
1
club_1
Retrieve the average age of members of the club "Tennis Club".
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Tennis Club"
1
club_1
Compute the average age of the members in the club "Tennis Club".
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Tennis Club"
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the distinct grant amount for the grants where the documents were sent before '1986-08-26 20:49:27' and grant were ended after '1989-03-16 18:27:16'?
SELECT T1.grant_amount FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id = T2.grant_id WHERE T2.sent_date < '1986-08-26 20:49:27' INTERSECT SELECT grant_amount FROM grants WHERE grant_end_date > '1989-03-16 18:27:16'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the different grant amounts for documents sent before '1986-08-26 20:49:27' and after the grant ended on '1989-03-16 18:27:16'?
SELECT T1.grant_amount FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id = T2.grant_id WHERE T2.sent_date < '1986-08-26 20:49:27' INTERSECT SELECT grant_amount FROM grants WHERE grant_end_date > '1989-03-16 18:27:16'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
List the project details of the project both producing patent and paper as outcomes.
SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id WHERE T2.outcome_code = 'Paper' INTERSECT SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id WHERE T2.outcome_code = 'Patent'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the details of the project that is producing both patents and papers as outcomes?
SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id WHERE T2.outcome_code = 'Paper' INTERSECT SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id WHERE T2.outcome_code = 'Patent'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the total grant amount of the organisations described as research?
SELECT sum(grant_amount) FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id = T2.organisation_id JOIN organisation_Types AS T3 ON T2.organisation_type = T3.organisation_type WHERE T3.organisation_type_description = 'Research'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the total amount of grant money for research?
SELECT sum(grant_amount) FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id = T2.organisation_id JOIN organisation_Types AS T3 ON T2.organisation_type = T3.organisation_type WHERE T3.organisation_type_description = 'Research'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
List from which date and to which date these staff work: project staff of the project which hires the most staffs
SELECT date_from , date_to FROM Project_Staff WHERE project_id IN( SELECT project_id FROM Project_Staff GROUP BY project_id ORDER BY count(*) DESC LIMIT 1 ) UNION SELECT date_from , date_to FROM Project_Staff WHERE role_code = 'leader'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
From what date and to what date do the staff work on a project that has the most staff and has staff in a leader role?
SELECT date_from , date_to FROM Project_Staff WHERE project_id IN( SELECT project_id FROM Project_Staff GROUP BY project_id ORDER BY count(*) DESC LIMIT 1 ) UNION SELECT date_from , date_to FROM Project_Staff WHERE role_code = 'leader'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
Find the organisation ids and details of the organisations which are involved in
SELECT T2.organisation_id , T2.organisation_details FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id = T2.organisation_id GROUP BY T2.organisation_id HAVING sum(T1.grant_amount) > 6000
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the ids and details for all organizations that have grants of more than 6000 dollars?
SELECT T2.organisation_id , T2.organisation_details FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id = T2.organisation_id GROUP BY T2.organisation_id HAVING sum(T1.grant_amount) > 6000
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the organisation type and id of the organisation which has the most number of research staff?
SELECT T1.organisation_type , T1.organisation_id FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id = T2.employer_organisation_id GROUP BY T1.organisation_id ORDER BY count(*) DESC LIMIT 1
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the type and id of the organization that has the most research staff?
SELECT T1.organisation_type , T1.organisation_id FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id = T2.employer_organisation_id GROUP BY T1.organisation_id ORDER BY count(*) DESC LIMIT 1
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
Which organisation type hires most research staff?
SELECT T1.organisation_type FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id = T2.employer_organisation_id GROUP BY T1.organisation_type ORDER BY count(*) DESC LIMIT 1
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the type of the organization with the most research staff?
SELECT T1.organisation_type FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id = T2.employer_organisation_id GROUP BY T1.organisation_type ORDER BY count(*) DESC LIMIT 1
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
Find out the send dates of the documents with the grant amount of more than 5000 were granted by organisation type described
SELECT T1.sent_date FROM documents AS T1 JOIN Grants AS T2 ON T1.grant_id = T2.grant_id JOIN Organisations AS T3 ON T2.organisation_id = T3.organisation_id JOIN organisation_Types AS T4 ON T3.organisation_type = T4.organisation_type WHERE T2.grant_amount > 5000 AND T4.organisation_type_description = 'Research'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the send dates for all documents that have a grant amount of more than 5000 and are involved in research?
SELECT T1.sent_date FROM documents AS T1 JOIN Grants AS T2 ON T1.grant_id = T2.grant_id JOIN Organisations AS T3 ON T2.organisation_id = T3.organisation_id JOIN organisation_Types AS T4 ON T3.organisation_type = T4.organisation_type WHERE T2.grant_amount > 5000 AND T4.organisation_type_description = 'Research'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the response received dates for the documents described as 'Regular' or granted with more than 100?
SELECT T1.response_received_date FROM Documents AS T1 JOIN Document_Types AS T2 ON T1.document_type_code = T2.document_type_code JOIN Grants AS T3 ON T1.grant_id = T3.grant_id WHERE T2.document_description = 'Regular' OR T3.grant_amount > 100
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the response received date for the document described as Regular that was granted more than 100 dollars?
SELECT T1.response_received_date FROM Documents AS T1 JOIN Document_Types AS T2 ON T1.document_type_code = T2.document_type_code JOIN Grants AS T3 ON T1.grant_id = T3.grant_id WHERE T2.document_description = 'Regular' OR T3.grant_amount > 100
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
List the project details of the projects which did not hire any staff for a researcher role.
SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_Staff WHERE role_code = 'researcher' )
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the details for all projects that did not hire any staff in a research role?
SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_Staff WHERE role_code = 'researcher' )
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the task details, task id and project id for the projects which are detailed as 'omnis' or have more than 2 outcomes?
SELECT T1.task_details , T1.task_id , T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'omnis' UNION SELECT T1.task_details , T1.task_id , T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id JOIN Project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.project_id HAVING count(*) > 2
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the task details, task ids, and project ids for the progrects that are detailed as 'omnis' or have at least 3 outcomes?
SELECT T1.task_details , T1.task_id , T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'omnis' UNION SELECT T1.task_details , T1.task_id , T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id JOIN Project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.project_id HAVING count(*) > 2
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
When do all the researcher role staff start to work, and when do they stop working?
SELECT date_from , date_to FROM Project_Staff WHERE role_code = 'researcher'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
When did researchers start and stop working?
SELECT date_from , date_to FROM Project_Staff WHERE role_code = 'researcher'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
How many kinds of roles are there for the staff?
SELECT count(DISTINCT role_code) FROM Project_Staff
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
How many different roles are there on the project staff?
SELECT count(DISTINCT role_code) FROM Project_Staff
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the total amount of grants given by each organisations? Also list the organisation id.
SELECT sum(grant_amount) , organisation_id FROM Grants GROUP BY organisation_id
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What is the total amount of grant money given to each organization and what is its id?
SELECT sum(grant_amount) , organisation_id FROM Grants GROUP BY organisation_id
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
List the project details of the projects with the research outcome described with the substring 'Published'.
SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id JOIN Research_outcomes AS T3 ON T2.outcome_code = T3.outcome_code WHERE T3.outcome_description LIKE '%Published%'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
What are the details for the project whose research has been published?
SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id JOIN Research_outcomes AS T3 ON T2.outcome_code = T3.outcome_code WHERE T3.outcome_description LIKE '%Published%'
1
tracking_grants_for_research
CREATE TABLE `Document_Types` ( `document_type_code` VARCHAR(10) PRIMARY KEY, `document_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Documents` ( `document_id` INTEGER PRIMARY KEY, `document_type_code` VARCHAR(10), `grant_id` INTEGER NOT NULL, `sent_date` DATETIME NOT NULL, `response_received_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ), FOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` ) ); CREATE TABLE `Grants` ( `grant_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0, `grant_start_date` DATETIME NOT NULL, `grant_end_date` DATETIME NOT NULL, `other_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Organisation_Types` ( `organisation_type` VARCHAR(10) PRIMARY KEY, `organisation_type_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Organisations` ( `organisation_id` INTEGER PRIMARY KEY, `organisation_type` VARCHAR(10) NOT NULL, `organisation_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` ) ); CREATE TABLE `Project_Outcomes` ( `project_id` INTEGER NOT NULL, `outcome_code` VARCHAR(10) NOT NULL, `outcome_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` ) ); CREATE TABLE `Project_Staff` ( `staff_id` DOUBLE PRIMARY KEY, `project_id` INTEGER NOT NULL, `role_code` VARCHAR(10) NOT NULL, `date_from` DATETIME, `date_to` DATETIME, `other_details` VARCHAR(255), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` ) ); CREATE TABLE `Projects` ( `project_id` INTEGER PRIMARY KEY, `organisation_id` INTEGER NOT NULL, `project_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Research_Outcomes` ( `outcome_code` VARCHAR(10) PRIMARY KEY, `outcome_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Research_Staff` ( `staff_id` INTEGER PRIMARY KEY, `employer_organisation_id` INTEGER NOT NULL, `staff_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` ) ); CREATE TABLE `Staff_Roles` ( `role_code` VARCHAR(10) PRIMARY KEY, `role_description` VARCHAR(255) NOT NULL ); CREATE TABLE `Tasks` ( `task_id` INTEGER PRIMARY KEY, `project_id` INTEGER NOT NULL, `task_details` VARCHAR(255) NOT NULL, `eg Agree Objectives` VARCHAR(1), FOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ) )
How many staff does each project has? List the project id and the number in an ascending order.
SELECT T1.project_id , count(*) FROM Project_Staff AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id ORDER BY count(*) ASC