spider_version
int64
1
2
db_id
stringclasses
204 values
schema
stringclasses
187 values
question
stringlengths
3
328
query
stringlengths
20
3.81k
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
List the campus that have between 600 and 1000 faculty lines in year 2004.
SELECT T1.campus FROM campuses AS t1 JOIN faculty AS t2 ON t1.id = t2.campus WHERE t2.faculty >= 600 AND t2.faculty <= 1000 AND T1.year = 2004
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
What are the campuses that had between 600 and 1000 faculty members in 2004?
SELECT T1.campus FROM campuses AS t1 JOIN faculty AS t2 ON t1.id = t2.campus WHERE t2.faculty >= 600 AND t2.faculty <= 1000 AND T1.year = 2004
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many faculty lines are there in the university that conferred the most number of degrees in year 2002?
SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2002 ORDER BY t3.degrees DESC LIMIT 1
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many faculty members did the university that conferred the most degrees in 2002 have?
SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2002 ORDER BY t3.degrees DESC LIMIT 1
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many faculty lines are there in the university that conferred the least number of degrees in year 2001?
SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2001 ORDER BY t3.degrees LIMIT 1
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many faculty members are at the university that gave the least number of degrees in 2001?
SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2001 ORDER BY t3.degrees LIMIT 1
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many undergraduates are there in "San Jose State University" in year 2004?
SELECT sum(t1.undergraduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Jose State University"
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many undergraduates are there at San Jose State
SELECT sum(t1.undergraduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Jose State University"
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
What is the number of graduates in "San Francisco State University" in year 2004?
SELECT sum(t1.graduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Francisco State University"
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many people graduated from San Francisco State University in 2004?
SELECT sum(t1.graduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Francisco State University"
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
What is the campus fee of "San Francisco State University" in year 2000?
SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Francisco State University" AND t1.year = 2000
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
In the year 2000, what is the campus fee for San Francisco State University?
SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Francisco State University" AND t1.year = 2000
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
Find the campus fee of "San Jose State University" in year 2000.
SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Jose State University" AND t1.year = 2000
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
What is the campus fee in the year 2000 for San Jose State University?
SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Jose State University" AND t1.year = 2000
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
How many CSU campuses are there?
SELECT count(*) FROM campuses
1
csu_1
CREATE TABLE "Campuses" ( "Id" INTEGER PRIMARY KEY, "Campus" TEXT, "Location" TEXT, "County" TEXT, "Year" INTEGER ); CREATE TABLE "csu_fees" ( "Campus" INTEGER PRIMARY KEY, "Year" INTEGER, "CampusFee" INTEGER, FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "degrees" ( "Year" INTEGER, "Campus" INTEGER, "Degrees" INTEGER, PRIMARY KEY (YEAR, Campus), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "discipline_enrollments" ( "Campus" INTEGER, "Discipline" INTEGER, "Year" INTEGER, "Undergraduate" INTEGER, "Graduate" INTEGER, PRIMARY KEY (Campus, Discipline), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "enrollments" ( "Campus" INTEGER, "Year" INTEGER, "TotalEnrollment_AY" INTEGER, "FTE_AY" INTEGER, PRIMARY KEY(Campus, YEAR), FOREIGN KEY (Campus) REFERENCES Campuses(Id) ); CREATE TABLE "faculty" ( "Campus" INTEGER, "Year" INTEGER, "Faculty" REAL, FOREIGN KEY (Campus) REFERENCES Campuses(Id) )
What is the total number of campuses?
SELECT count(*) FROM campuses
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
How many candidates are there?
SELECT count(*) FROM candidate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Count the number of candidates.
SELECT count(*) FROM candidate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Which poll resource provided the most number of candidate information?
SELECT poll_source FROM candidate GROUP BY poll_source ORDER BY count(*) DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Return the poll resource associated with the most candidates.
SELECT poll_source FROM candidate GROUP BY poll_source ORDER BY count(*) DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
what are the top 3 highest support rates?
SELECT support_rate FROM candidate ORDER BY support_rate DESC LIMIT 3
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Return the top 3 greatest support rates.
SELECT support_rate FROM candidate ORDER BY support_rate DESC LIMIT 3
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Find the id of the candidate who got the lowest oppose rate.
SELECT Candidate_ID FROM candidate ORDER BY oppose_rate LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What is the id of the candidate with the lowest oppose rate?
SELECT Candidate_ID FROM candidate ORDER BY oppose_rate LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Please list support, consider, and oppose rates for each candidate in ascending order by unsure rate.
SELECT Support_rate , Consider_rate , Oppose_rate FROM candidate ORDER BY unsure_rate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the support, consider, and oppose rates of each candidate, ordered ascending by their unsure rate?
SELECT Support_rate , Consider_rate , Oppose_rate FROM candidate ORDER BY unsure_rate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
which poll source does the highest oppose rate come from?
SELECT poll_source FROM candidate ORDER BY oppose_rate DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Return the poll source corresponding to the candidate who has the oppose rate.
SELECT poll_source FROM candidate ORDER BY oppose_rate DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
List all people names in the order of their date of birth from old to young.
SELECT name FROM people ORDER BY date_of_birth
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the names of all people, ordered by their date of birth?
SELECT name FROM people ORDER BY date_of_birth
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Find the average height and weight for all males (sex is M).
SELECT avg(height) , avg(weight) FROM people WHERE sex = 'M'
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the average height and weight across males (sex is M)?
SELECT avg(height) , avg(weight) FROM people WHERE sex = 'M'
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
find the names of people who are taller than 200 or lower than 190.
SELECT name FROM people WHERE height > 200 OR height < 190
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the names of people who have a height greater than 200 or less than 190?
SELECT name FROM people WHERE height > 200 OR height < 190
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Find the average and minimum weight for each gender.
SELECT avg(weight) , min(weight) , sex FROM people GROUP BY sex
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the average and minimum weights for people of each sex?
SELECT avg(weight) , min(weight) , sex FROM people GROUP BY sex
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Find the name and gender of the candidate who got the highest support rate.
SELECT t1.name , t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id ORDER BY t2.support_rate DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What is the name and sex of the candidate with the highest support rate?
SELECT t1.name , t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id ORDER BY t2.support_rate DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Find the name of the candidates whose oppose percentage is the lowest for each sex.
SELECT t1.name , t1.sex , min(oppose_rate) FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
For each sex, what is the name and sex of the candidate with the oppose rate for their sex?
SELECT t1.name , t1.sex , min(oppose_rate) FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
which gender got the highest average uncertain ratio.
SELECT t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex ORDER BY avg(t2.unsure_rate) DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What is the sex of the candidate who had the highest unsure rate?
SELECT t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex ORDER BY avg(t2.unsure_rate) DESC LIMIT 1
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
what are the names of people who did not participate in the candidate election.
SELECT name FROM people WHERE people_id NOT IN (SELECT people_id FROM candidate)
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Give the names of people who did not participate in the candidate election.
SELECT name FROM people WHERE people_id NOT IN (SELECT people_id FROM candidate)
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Find the names of the candidates whose support percentage is lower than their oppose rate.
SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t2.support_rate < t2.oppose_rate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the names of candidates who have a lower support rate than oppose rate?
SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t2.support_rate < t2.oppose_rate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
how many people are there whose weight is higher than 85 for each gender?
SELECT count(*) , sex FROM people WHERE weight > 85 GROUP BY sex
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Count the number of people of each sex who have a weight higher than 85.
SELECT count(*) , sex FROM people WHERE weight > 85 GROUP BY sex
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
find the highest support percentage, lowest consider rate and oppose rate of all candidates.
SELECT max(support_rate) , min(consider_rate) , min(oppose_rate) FROM candidate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
Return the maximum support rate, minimum consider rate, and minimum oppose rate across all candidates?
SELECT max(support_rate) , min(consider_rate) , min(oppose_rate) FROM candidate
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
list all female (sex is F) candidate names in the alphabetical order.
SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t1.sex = 'F' ORDER BY t1.name
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the names of all female candidates in alphabetical order (sex is F)?
SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t1.sex = 'F' ORDER BY t1.name
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
find the name of people whose height is lower than the average.
SELECT name FROM people WHERE height < (SELECT avg(height) FROM people)
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What are the names of people who are shorter than average?
SELECT name FROM people WHERE height < (SELECT avg(height) FROM people)
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
List all info about all people.
SELECT * FROM people
1
candidate_poll
CREATE TABLE "candidate" ( "Candidate_ID" int, "People_ID" int, "Poll_Source" text, "Date" text, "Support_rate" real, "Consider_rate" real, "Oppose_rate" real, "Unsure_rate" real, PRIMARY KEY ("Candidate_ID"), FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID") ); CREATE TABLE "people" ( "People_ID" int, "Sex" text, "Name" text, "Date_of_Birth" text, "Height" real, "Weight" real, PRIMARY KEY ("People_ID") )
What is all the information about all people?
SELECT * FROM people
1
movie_1
Find the titles of all movies directed by steven spielberg.
SELECT title FROM Movie WHERE director = 'Steven Spielberg'
1
movie_1
What are the names of all movies directed by Steven Spielberg?
SELECT title FROM Movie WHERE director = 'Steven Spielberg'
1
movie_1
What is the name of the movie produced after 2000 and directed by James Cameron?
SELECT title FROM Movie WHERE director = 'James Cameron' AND YEAR > 2000
1
movie_1
What are the titles of all movies that James Cameron directed after 2000?
SELECT title FROM Movie WHERE director = 'James Cameron' AND YEAR > 2000
1
movie_1
How many movies were made before 2000?
SELECT count(*) FROM Movie WHERE YEAR < 2000
1
movie_1
How many movies were made before 2000?
SELECT count(*) FROM Movie WHERE YEAR < 2000
1
movie_1
Who is the director of movie Avatar?
SELECT director FROM Movie WHERE title = 'Avatar'
1
movie_1
Who directed Avatar?
SELECT director FROM Movie WHERE title = 'Avatar'
1
movie_1
How many reviewers listed?
SELECT count(*) FROM Reviewer
1
movie_1
How many reviewers are there?
SELECT count(*) FROM Reviewer
1
movie_1
What is the id of the reviewer whose name has substring “Mike”?
SELECT rID FROM Reviewer WHERE name LIKE "%Mike%"
1
movie_1
What is the id of the reviewer whose name includes the word "Mike"?
SELECT rID FROM Reviewer WHERE name LIKE "%Mike%"
1
movie_1
What is the reviewer id of Daniel Lewis?
SELECT rID FROM Reviewer WHERE name = "Daniel Lewis"
1
movie_1
What is the id of the reviewer named Daniel Lewis?
SELECT rID FROM Reviewer WHERE name = "Daniel Lewis"
1
movie_1
What is the total number of ratings that has more than 3 stars?
SELECT count(*) FROM Rating WHERE stars > 3
1
movie_1
How many movie ratings have more than 3 stars?
SELECT count(*) FROM Rating WHERE stars > 3
1
movie_1
What is the lowest and highest rating star?
SELECT max(stars) , min(stars) FROM Rating
1
movie_1
What is the maximum and mininum number of stars a rating can receive?
SELECT max(stars) , min(stars) FROM Rating
1
movie_1
Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order of year.
SELECT DISTINCT YEAR FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars >= 4 ORDER BY T1.year
1
movie_1
In what years did a movie receive a 4 or 5 star rating, and list the years from oldest to most recently?
SELECT DISTINCT YEAR FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars >= 4 ORDER BY T1.year
1
movie_1
What are the names of directors who directed movies with 5 star rating? Also return the title of these movies.
SELECT T1.director , T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5
1
movie_1
What are the names of the directors who created a movie with a 5 star rating, and what was the name of those movies?
SELECT T1.director , T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5
1
movie_1
What is the average rating star for each reviewer?
SELECT T2.name , avg(T1.stars) FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T2.name
1
movie_1
What is the average number of stars that each reviewer awards for a movie?
SELECT T2.name , avg(T1.stars) FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T2.name
1
movie_1
Find the titles of all movies that have no ratings.
SELECT title FROM Movie WHERE mID NOT IN (SELECT mID FROM Rating)
1
movie_1
What are the titles of all movies that have not been rated?
SELECT title FROM Movie WHERE mID NOT IN (SELECT mID FROM Rating)
1
movie_1
Find the names of all reviewers who have ratings with a NULL value for the date.
SELECT DISTINCT name FROM Reviewer AS T1 JOIN Rating AS T2 ON T1.rID = T2.rID WHERE ratingDate = "null"
1
movie_1
What are the different names of all reviewers whose ratings do not have a date field?
SELECT DISTINCT name FROM Reviewer AS T1 JOIN Rating AS T2 ON T1.rID = T2.rID WHERE ratingDate = "null"
1
movie_1
What is the average rating stars and title for the oldest movie?
SELECT avg(T1.stars) , T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT min(YEAR) FROM Movie)
1
movie_1
For the oldest movie listed, what is its average rating and title?
SELECT avg(T1.stars) , T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT min(YEAR) FROM Movie)
1
movie_1
What is the name of the most recent movie?
SELECT title FROM Movie WHERE YEAR = (SELECT max(YEAR) FROM Movie)
1
movie_1
What is the title of the newest movie?
SELECT title FROM Movie WHERE YEAR = (SELECT max(YEAR) FROM Movie)
1
movie_1
What is the maximum stars and year for the most recent movie?
SELECT max(T1.stars) , T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT max(YEAR) FROM Movie)
1
movie_1
What is highest rating for the most recent movie and when was it released?
SELECT max(T1.stars) , T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT max(YEAR) FROM Movie)
1
movie_1
What is the names of movies whose created year is after all movies directed by Steven Spielberg?
SELECT title FROM Movie WHERE YEAR > (SELECT max(YEAR) FROM Movie WHERE director = "Steven Spielberg")
1
movie_1
What are the names of all movies that were created after the most recent Steven Spielberg film?
SELECT title FROM Movie WHERE YEAR > (SELECT max(YEAR) FROM Movie WHERE director = "Steven Spielberg")
1
movie_1
What are the titles and directors of the movies whose star is greater than the average stars of the movies directed by James Cameron?
SELECT T2.title , T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars > (SELECT avg(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.director = "James Cameron")
1
movie_1
What are the titles and directors of all movies that have a rating higher than the average James Cameron film rating?
SELECT T2.title , T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars > (SELECT avg(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.director = "James Cameron")
1
movie_1
Return reviewer name, movie title, stars, and ratingDate. And sort the data first by reviewer name, then by movie title, and lastly by number of stars.
SELECT T3.name , T2.title , T1.stars , T1.ratingDate FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID ORDER BY T3.name , T2.title , T1.stars
1
movie_1
What is the reviewer name, film title, movie rating, and rating date for every movie ordered by reviewer name, movie title, then finally rating?
SELECT T3.name , T2.title , T1.stars , T1.ratingDate FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID ORDER BY T3.name , T2.title , T1.stars
1
movie_1
Find the names of all reviewers who have contributed three or more ratings.
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T1.rID HAVING COUNT(*) >= 3
1
movie_1
What are the names of all reviewers that have rated 3 or more movies?
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T1.rID HAVING COUNT(*) >= 3
1
movie_1
Find the names of all reviewers who rated Gone with the Wind.
SELECT DISTINCT T3.name FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.title = 'Gone with the Wind'
1
movie_1
What are the names of all the different reviewers who rates Gone with the Wind?
SELECT DISTINCT T3.name FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.title = 'Gone with the Wind'