db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
schema
stringclasses
69 values
hockey
List down the first name of coaches who still coach after year 2000.
after year 2000 refers to year>2000;
SELECT DISTINCT T1.firstName FROM Master AS T1 INNER JOIN Coaches AS T2 ON T1.coachID = T2.coachID WHERE T2.year > 2000
CREATE TABLE AwardsMisc ( name TEXT not null primary key, ID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT ); CREATE TABLE HOF ( year INTEGER, hofID TEXT not null primary key, name TEXT, category TEXT ); CREATE TABLE Teams ( year ...
shipping
Who was the driver of truck no.3 on 2016/9/19? Tell the full name.
truck no. 3 refers to truck_id = 3; on 2016/9/19 refers to ship_date = '2016-09-19'; full name refers to first_name, last_name
SELECT T3.first_name, T3.last_name FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id INNER JOIN driver AS T3 ON T3.driver_id = T2.driver_id WHERE T1.truck_id = '3' AND T2.ship_date = '2016-09-19'
CREATE TABLE city ( city_id INTEGER primary key, city_name TEXT, state TEXT, population INTEGER, area REAL ); CREATE TABLE customer ( cust_id INTEGER primary key, cust_name TEXT, annual_revenue INTEGER, cust_type TEXT, addre...
cs_semester
Describe the names and credits of the least difficult courses.
diff refers to difficulty; the least difficult courses refer to MIN(diff);
SELECT name, credit FROM course WHERE diff = ( SELECT MIN(diff) FROM course )
CREATE TABLE IF NOT EXISTS "course" ( course_id INTEGER constraint course_pk primary key, name TEXT, credit INTEGER, diff INTEGER ); CREATE TABLE prof ( prof_id INTEGER constraint prof_pk primary key, gender TEXT, first_na...
soccer_2016
What are the names of players that have run scored less than 3?
scored less than 3 refers to Runs_Scored < 3; name of player refers to Player_name;
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Batsman_Scored AS T3 ON T2.Match_ID = T3.Match_ID WHERE T3.Runs_Scored < 3 GROUP BY T1.Player_Name
CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT ); CREATE TABLE Bowling_Style ( Bowling_Id INTEGER primary key, Bowling_skill TEXT ); CREATE TABLE City ( City_Id INTEGER primary key, City_Name TEXT, Country_id INTEGE...
movies_4
Accumulate the budget of the movie titles with the keyword of "video game".
keyword of "video game" refers to keyword_name = 'video game'
SELECT SUM(T1.budget) FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T3.keyword_name = 'video game'
CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, country_name TEXT default NULL ); CREATE TABLE department ( department_id INTEGER not null primary key, department_name TEXT default NULL ); CREATE TABLE gender ( ...
superstore
Which order of Logitech G600 MMO Gaming Mouse has the highest total cost?
Logitech G600 MMO Gaming Mouse refers to "Product Name"; highest total cost refers to MAX(SUTRACT(MULTIPLY(DIVIDE(Sales, SUTRACT(1, discount)), Quantity), Profit))
SELECT T1.`Order ID` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.`Product Name` = 'Logitech G600 MMO Gaming Mouse' GROUP BY T1.`Order ID` ORDER BY SUM((T1.Sales / (1 - T1.Discount)) * T1.Quantity - T1.Profit) DESC LIMIT 1
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TE...
olympics
Which sport did John Aalberg participate in?
sport refers to sport_name;
SELECT DISTINCT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id INNER JOIN competitor_event AS T3 ON T2.id = T3.event_id INNER JOIN games_competitor AS T4 ON T3.competitor_id = T4.id INNER JOIN person AS T5 ON T4.person_id = T5.id WHERE T5.full_name = 'John Aalberg'
CREATE TABLE city ( id INTEGER not null primary key, city_name TEXT default NULL ); CREATE TABLE games ( id INTEGER not null primary key, games_year INTEGER default NULL, games_name TEXT default NULL, season TEXT default NULL ); CREATE TABLE ga...
language_corpus
What are the occurance of word "del" in title "Any anomalístic"?
This is not
SELECT T2.occurrences FROM words AS T1 INNER JOIN pages_words AS T2 ON T1.wid = T2.wid INNER JOIN pages AS T3 ON T2.pid = T3.pid WHERE T1.word = 'del' AND T3.title = 'Any anomalístic'
CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT, lang TEXT UNIQUE, locale TEXT UNIQUE, pages INTEGER DEFAULT 0, -- total pages in this language words INTEGER DEFAULT 0); CREATE TABLE sqlite_s...
mondial_geo
How many lakes are there in the 4th most populous African country with a republican form of government?
SELECT COUNT(*) FROM geo_lake WHERE Country = ( SELECT T4.Code FROM ( SELECT T2.Code, T2.Population FROM encompasses AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code INNER JOIN politics AS T3 ON T1.Country = T3.Country WHERE T1.Continent = 'Africa' AND T1.Percentage = 100 AND T3.Government = 'republic' ORDER BY P...
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE I...
food_inspection
List the names and business certificates of the eateries which got inspection score under 50.
eateries which got inspection score under 50 refer to business_id where score < 50;
SELECT T2.name, T2.business_id FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score < 50
CREATE TABLE `businesses` ( `business_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `address` TEXT DEFAULT NULL, `city` TEXT DEFAULT NULL, `postal_code` TEXT DEFAULT NULL, `latitude` REAL DEFAULT NULL, `longitude` REAL DEFAULT NULL, `phone_number` INTEGER DEFAULT NULL, `tax_code` TEXT DEFAULT NULL, `b...
shooting
Who are the officers involved in cases that are voted as 'No Bill'. List their last name and gender.
voted as 'No Bill' refers to grand_jury_disposition = 'No Bill'
SELECT T2.last_name, T2.gender FROM incidents AS T1 INNER JOIN officers AS T2 ON T1.case_number = T2.case_number WHERE T1.grand_jury_disposition = 'No Bill'
CREATE TABLE incidents ( case_number TEXT not null primary key, date DATE not null, location TEXT not null, subject_statuses TEXT not null, subject_weapon TEXT not null, subjects T...
movie_3
In films with a rental rate of 2.99, how many of the films are starred by Nina Soto?
a rental rate of 2.99 refers to rental_rate = 2.99
SELECT COUNT(T1.film_id) FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id WHERE T3.rental_rate = 2.99 AND T2.first_name = 'Nina' AND T2.last_name = 'Soto'
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_nam...
works_cycles
Please list the email adresses of the reviewers who have given the lowest rating to the product HL Mountain Pedal.
lowest rating refers to Rating = 1
SELECT T1.EmailAddress FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'HL Mountain Pedal' ORDER BY T1.Rating LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ...
student_loan
How many students are enrolled in UCLA school?
enrolled in UCLA refers to school = 'ucla';
SELECT COUNT(name) FROM enrolled WHERE school = 'ucla'
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
food_inspection
Please list the names of all the restaurants that have met all requirements in one inspection.
met all requirements refers to inspections where score = 100;
SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100
CREATE TABLE `businesses` ( `business_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `address` TEXT DEFAULT NULL, `city` TEXT DEFAULT NULL, `postal_code` TEXT DEFAULT NULL, `latitude` REAL DEFAULT NULL, `longitude` REAL DEFAULT NULL, `phone_number` INTEGER DEFAULT NULL, `tax_code` TEXT DEFAULT NULL, `b...
language_corpus
How many appearances does the word ID No. 2823 have in the Wikipedia page "Astre"?
Astre refers to title = 'Astre'; word ID No. 2823 refers to wid = 2823; appearances refers to pages_words_sampling.occurrences
SELECT SUM(T2.occurrences) FROM pages AS T1 INNER JOIN pages_words AS T2 ON T1.pid = T2.pid WHERE T1.title = 'Astre' AND T2.wid = 2823
CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT, lang TEXT UNIQUE, locale TEXT UNIQUE, pages INTEGER DEFAULT 0, -- total pages in this language words INTEGER DEFAULT 0); CREATE TABLE sqlite_s...
regional_sales
How many sales teams are there in the Midwest?
"Midwest" is the Region
SELECT SUM(CASE WHEN Region = 'Midwest' THEN 1 ELSE 0 END) FROM `Sales Team`
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT ...
cs_semester
For the professor who is working with Harrietta Lydford, how is his popularity?
research assistant refers to the student who serves for research where the abbreviation is RA; higher popularity means more popular; prof_id refers to professor’s ID;
SELECT T1.popularity FROM prof AS T1 INNER JOIN RA AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T2.student_id = T3.student_id WHERE T3.f_name = 'Harrietta' AND T3.l_name = 'Lydford'
CREATE TABLE IF NOT EXISTS "course" ( course_id INTEGER constraint course_pk primary key, name TEXT, credit INTEGER, diff INTEGER ); CREATE TABLE prof ( prof_id INTEGER constraint prof_pk primary key, gender TEXT, first_na...
movie_3
Among the films with a rental duration of 7 days, how many are comedies?
rental duration of 7 refers to rental_duration = 7; comedies refers to name = 'Comedy'
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T1.rental_duration = 7 AND T3.name = 'Comedy'
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_nam...
retails
How many suppliers are from Japan?
suppliers refer to s_nationkey; Japan is the name of the nation which refers to n_name = 'JAPAN';
SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'JAPAN'
CREATE TABLE `customer` ( `c_custkey` INTEGER NOT NULL, `c_mktsegment` TEXT DEFAULT NULL, `c_nationkey` INTEGER DEFAULT NULL, `c_name` TEXT DEFAULT NULL, `c_address` TEXT DEFAULT NULL, `c_phone` TEXT DEFAULT NULL, `c_acctbal` REAL DEFAULT NULL, `c_comment` TEXT DEFAULT NULL, PRIMARY KEY (`c_custkey`),...
hockey
Among the coaches whose team has over 30 wins in a year, how many of them are born in the USA?
over 30 wins refers to w>30; born in the USA refers to birthCountry = 'USA'
SELECT COUNT(T2.coachID) FROM Master AS T1 INNER JOIN Coaches AS T2 ON T1.coachID = T2.coachID WHERE T2.W > 30 AND T1.birthCountry = 'USA'
CREATE TABLE AwardsMisc ( name TEXT not null primary key, ID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT ); CREATE TABLE HOF ( year INTEGER, hofID TEXT not null primary key, name TEXT, category TEXT ); CREATE TABLE Teams ( year ...
music_platform_2
What is the rating and category of the podcast entitled Sitcomadon?
entitled refers to title; 'Sitcomadon' is the title of podcast
SELECT DISTINCT T3.rating, T1.category FROM categories AS T1 INNER JOIN podcasts AS T2 ON T2.podcast_id = T1.podcast_id INNER JOIN reviews AS T3 ON T3.podcast_id = T2.podcast_id WHERE T2.title = 'Sitcomadon'
CREATE TABLE runs ( run_at text not null, max_rowid integer not null, reviews_added integer not null ); CREATE TABLE podcasts ( podcast_id text primary key, itunes_id integer not null, slug text not null, itunes_url text not null, title text not null ...
college_completion
What is the number of female graduates between 2011 to 2013 from the state where 'Gateway Community College' is located?
female refers to gender = 'F'; graduates refers to grad_cohort; between 2011 to 2013 refers to year BETWEEN 2011 AND 2013; Gateway Community College refers to chronname = 'Gateway Community College';
SELECT COUNT(T2.grad_cohort) FROM institution_details AS T1 INNER JOIN state_sector_grads AS T2 ON T1.state = T2.state WHERE T2.year BETWEEN 2011 AND 2013 AND T1.chronname = 'Gateway Community College' AND T2.gender = 'F'
CREATE TABLE institution_details ( unitid INTEGER constraint institution_details_pk primary key, chronname TEXT, city TEXT, state TEXT, level ...
software_company
What is the income of female customers ages from 30 to 55 years old and has an occupation of machine-op-inspct?
female customers ages from 30 to 55 years old refer to SEX = 'Female' where age BETWEEN 30 AND 55; income refers to INCOME_K;
SELECT T2.INCOME_K FROM Customers AS T1 INNER JOIN Demog AS T2 ON T1.GEOID = T2.GEOID WHERE T1.SEX = 'Female' AND T1.age >= 30 AND T1.age <= 55 AND T1.OCCUPATION = 'Machine-op-inspct'
CREATE TABLE Demog ( GEOID INTEGER constraint Demog_pk primary key, INHABITANTS_K REAL, INCOME_K REAL, A_VAR1 REAL, A_VAR2 REAL, A_VAR3 REAL, A_VAR4 REAL, A_VAR5 REAL, A_VAR6 REAL, A_VAR7 REAL, ...
student_loan
List at least 10 students who have no payment due and are enlisted in Fire Department organization.
no payment due refers to bool = 'neg'; organization refers to organ; organ = 'fire_department';
SELECT T1.name FROM no_payment_due AS T1 INNER JOIN enlist AS T2 ON T2.name = T1.name WHERE T1.bool = 'neg' AND T2.organ = 'fire_department' LIMIT 10
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
world_development_indicators
Which country had the highest value of indicator belongs to Private Sector & Trade: Exports topic? Please list the country name and indicator name.
country refers to CountryName;
SELECT T1.CountryName, T1.IndicatorName FROM Indicators AS T1 INNER JOIN Series AS T2 ON T1.IndicatorName = T2.IndicatorName WHERE T2.Topic = 'Private Sector & Trade: Exports' ORDER BY T1.Value DESC LIMIT 1
CREATE TABLE IF NOT EXISTS "Country" ( CountryCode TEXT not null primary key, ShortName TEXT, TableName TEXT, LongName TEXT, Alpha2Code ...
public_review_platform
State the number of actively running Yelp businesses in "Tolleson".
actively running refers to active = 'TRUE'; Tolleson refers to city = 'Tolleson';
SELECT COUNT(business_id) FROM Business WHERE city LIKE 'Tolleson' AND active LIKE 'TRUE'
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id ...
disney
Who is the villain in Little Mermaid?
Little Mermaid refers to movie_title = 'Little Mermaid';
SELECT villian FROM characters WHERE movie_title = 'Little Mermaid'
CREATE TABLE characters ( movie_title TEXT primary key, release_date TEXT, hero TEXT, villian TEXT, song TEXT, foreign key (hero) references "voice-actors"(character) ); CREATE TABLE director ( name TEXT primary key, director TEXT, fo...
menu
How many dishes are there in total in the menus with the name "Waldorf Astoria"?
FALSE;
SELECT SUM(CASE WHEN T3.name = 'Waldorf Astoria' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id
CREATE TABLE Dish ( id INTEGER primary key, name TEXT, description TEXT, menus_appeared INTEGER, times_appeared INTEGER, first_appeared INTEGER, last_appeared INTEGER, lowest_price REAL, highest_price REAL ); CREATE TABLE Menu ( id ...
ice_hockey_draft
How many players, who were drafted by Anaheim Ducks in 2008, have played for U.S. National U18 Team?
drafted by Anaheim Ducks refers to overallby = 'Anaheim Ducks'; in 2008 refers to draftyear = 2008; played for U.S. National U18 Team refers to TEAM = 'U.S. National U18 Team';
SELECT COUNT(DISTINCT T1.ELITEID) FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.overallby = 'Anaheim Ducks' AND T1.draftyear = 2008 AND T2.TEAM = 'U.S. National U18 Team'
CREATE TABLE height_info ( height_id INTEGER primary key, height_in_cm INTEGER, height_in_inch TEXT ); CREATE TABLE weight_info ( weight_id INTEGER primary key, weight_in_kg INTEGER, weight_in_lbs INTEGER ); CREATE TABLE PlayerInfo ( ELITEID INTE...
cookbook
How many ingredients are there in Apricot Yogurt Parfaits?
Apricot Yogurt Parfaits refers to title
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Apricot Yogurt Parfaits'
CREATE TABLE Ingredient ( ingredient_id INTEGER primary key, category TEXT, name TEXT, plural TEXT ); CREATE TABLE Recipe ( recipe_id INTEGER primary key, title TEXT, subtitle TEXT, servings INTEGER, yield_unit TEXT, prep_min...
cookbook
Which recipes contain almond extract?
almond extract is a name of an ingredient
SELECT T1.title FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.name = 'almond extract'
CREATE TABLE Ingredient ( ingredient_id INTEGER primary key, category TEXT, name TEXT, plural TEXT ); CREATE TABLE Recipe ( recipe_id INTEGER primary key, title TEXT, subtitle TEXT, servings INTEGER, yield_unit TEXT, prep_min...
college_completion
How many students for both genders graduated from a 2-year institute in Alabama in 2011?
2-year institute refers to cohort = '2y all'; Alabama refers to state = 'Alabama'; in 2011 refers to year = 2011; T2.gender = 'B' means both genders;
SELECT SUM(T2.grad_cohort) FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T2.unitid = T1.unitid WHERE T2.cohort = '2y all' AND T2.year = 2011 AND T1.state = 'Alabama'
CREATE TABLE institution_details ( unitid INTEGER constraint institution_details_pk primary key, chronname TEXT, city TEXT, state TEXT, level ...
mondial_geo
How many organizations are established after 1999/1/1 in a country whose GDP is under 500000?
SELECT T1.Country, COUNT(T1.Country) FROM economy AS T1 INNER JOIN organization AS T2 ON T1.Country = T2.Country WHERE T1.GDP < 500000 AND STRFTIME('%Y', T2.Established) < '1999' GROUP BY T1.Country
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE I...
european_football_1
Which country did Bradford Team belongs to?
Bradford team refers to HomeTeam = 'Bradford' or AwayTeam = 'Bradford';
SELECT DISTINCT T2.country FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.HomeTeam = 'Bradford' OR T1.AwayTeam = 'Bradford'
CREATE TABLE divisions ( division TEXT not null primary key, name TEXT, country TEXT ); CREATE TABLE matchs ( Div TEXT, Date DATE, HomeTeam TEXT, AwayTeam TEXT, FTHG INTEGER, FTAG INTEGER, FTR TEXT, season INTEGER, foreign key (Div) re...
movie
In romantic movies, how many of them starred by John Travolta?
romantic movies refers to Genre = 'Romance'; starred by John Travolta refers to Name = 'John Travolta'
SELECT COUNT(*) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Genre = 'Romance' AND T3.Name = 'John Travolta'
CREATE TABLE actor ( ActorID INTEGER constraint actor_pk primary key, Name TEXT, "Date of Birth" DATE, "Birth City" TEXT, "Birth Country" TEXT, "Height (Inches)" INTEGER, Biography TEXT, Gender TEXT, Ethnicity ...
works_cycles
Which product cost the least in 2013?
cost refers to StandardCost; cost the least refers to MIN(StandardCost);
SELECT ProductID FROM ProductCostHistory WHERE StartDate LIKE '2013%' ORDER BY StandardCost LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ...
talkingdata
How many active users are there in the event?
active refers to is_active = 1;
SELECT COUNT(app_id) FROM app_events WHERE is_active = 1
CREATE TABLE `app_all` ( `app_id` INTEGER NOT NULL, PRIMARY KEY (`app_id`) ); CREATE TABLE `app_events` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `eve...
movie_3
What is the description and film title of ID 996?
ID 996 refers to film_id = 996
SELECT description, title FROM film_text WHERE film_id = 996
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_nam...
works_cycles
Among the employees who are store contacts, how many of them have a title of "Mr."?
store contact refers to PersonType = 'SC';
SELECT COUNT(BusinessEntityID) FROM Person WHERE PersonType = 'SC' AND Title = 'Mr.'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ...
image_and_language
How many object samples are there in image no.1?
object samples refers to OBJ_SAMPLE_ID; image no.1 refers to IMG_ID = 1
SELECT COUNT(OBJ_SAMPLE_ID) FROM IMG_OBJ WHERE IMG_ID = 1
CREATE TABLE ATT_CLASSES ( ATT_CLASS_ID INTEGER default 0 not null primary key, ATT_CLASS TEXT not null ); CREATE TABLE OBJ_CLASSES ( OBJ_CLASS_ID INTEGER default 0 not null primary key, OBJ_CLASS TEXT not null ); CREATE TABLE IMG_OBJ ( IMG_ID INTEGER default 0...
works_cycles
Which product ID do not have any work order ID?
Do not have any work order ID means WorkOrderID is null
SELECT ProductID FROM Product WHERE ProductID NOT IN ( SELECT T1.ProductID FROM Product AS T1 INNER JOIN WorkOrder AS T2 ON T1.ProductID = T2.ProductID )
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ...
student_loan
Which organization has the highest number of male students? Calculate for the percentage of the male students in the said organization.
organization refers to organ; highest number of male students refers to MAX(COUNT(male.name)); percentage = DIVIDE(COUNT(male.name), COUNT(person.name)), 1.0;
SELECT T.organ, T.per FROM ( SELECT T1.organ, CAST(COUNT(T3.name) AS REAL) / COUNT(T2.name) AS per , COUNT(T3.name) AS num FROM enlist AS T1 INNER JOIN person AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T2.name = T3.name GROUP BY T1.organ ) T ORDER BY T.num DESC LIMIT 1
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
food_inspection_2
Which business had the highest number of inspections done? Calculate the percentage of passed and failed inspections of the said business.
business name refers to dba_name; the highest number of inspections done max(count(inspection_id)); percentage of passed inspections = divide(sum(inspection_id where results = 'Pass'), total(inspection_id)) * 100%; percentage of failed inspections = divide(sum(inspection_id where results = 'Fail'), total(inspection_id)...
SELECT T2.dba_name , CAST(SUM(CASE WHEN T1.results = 'Pass' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.inspection_id) AS percentagePassed , CAST(SUM(CASE WHEN T1.results = 'Fail' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.inspection_id) FROM inspection AS T1 INNER JOIN establishment AS T2 ON T1.license_no = T2.lice...
CREATE TABLE employee ( employee_id INTEGER primary key, first_name TEXT, last_name TEXT, address TEXT, city TEXT, state TEXT, zip INTEGER, phone TEXT, title TEXT, salary INTEGER, supervisor INTEGER, foreign key (s...
simpson_episodes
What is the average heights of crew members from Animation Department?
from Animation Department refers to category = 'Animation Department'; AVG(height_meters) where category = 'Animation Department'
SELECT AVG(T1.height_meters) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.category = 'Animation Department';
CREATE TABLE IF NOT EXISTS "Episode" ( episode_id TEXT constraint Episode_pk primary key, season INTEGER, episode INTEGER, number_in_series INTEGER, title TEXT, summary TEXT, air_date TEXT, episode_image TEXT, ...
works_cycles
What's Emma H Harris's Business Entity ID number?
SELECT BusinessEntityID FROM Person WHERE FirstName = 'Emma' AND LastName = 'Harris'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ...
shooting
Which are the cases where the subject are female. List the case number, subject status and weapon.
female refers to gender = 'F'; weapon refers to subject_weapon
SELECT T1.case_number, T1.subject_statuses, T1.subject_weapon FROM incidents AS T1 INNER JOIN subjects AS T2 ON T1.case_number = T2.case_number WHERE T2.gender = 'F'
CREATE TABLE incidents ( case_number TEXT not null primary key, date DATE not null, location TEXT not null, subject_statuses TEXT not null, subject_weapon TEXT not null, subjects T...
chicago_crime
List down the report number of crimes associated with the district commander named Jill M. Stevens.
report number refers report_no; 'Jill M. Stevens" is the commander
SELECT SUM(CASE WHEN T1.commander = 'Jill M. Stevens' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no
CREATE TABLE Community_Area ( community_area_no INTEGER primary key, community_area_name TEXT, side TEXT, population TEXT ); CREATE TABLE District ( district_no INTEGER primary key, district_name TEXT, address TEXT, zip_code ...
image_and_language
Calculate the percentage of "airplane" object class in the table.
DIVIDE(SUM(OBJ_SAMPLE_ID where OBJ_CLASS = 'airplane'), COUNT(OBJ_CLASS)) as percentage;
SELECT CAST(SUM(CASE WHEN T2.OBJ_CLASS = 'airplane' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.OBJ_CLASS) FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID
CREATE TABLE ATT_CLASSES ( ATT_CLASS_ID INTEGER default 0 not null primary key, ATT_CLASS TEXT not null ); CREATE TABLE OBJ_CLASSES ( OBJ_CLASS_ID INTEGER default 0 not null primary key, OBJ_CLASS TEXT not null ); CREATE TABLE IMG_OBJ ( IMG_ID INTEGER default 0...
mondial_geo
Average length of the rivers flowing into the Donau River.
SELECT * FROM river WHERE Name = 'Donau'
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE I...
menu
Give me the name and menu price of dishes that were free.
dishes that were free refers to lowest_price = 0;
SELECT T2.name, T1.price FROM MenuItem AS T1 INNER JOIN Dish AS T2 ON T2.id = T1.dish_id WHERE T2.lowest_price = 0
CREATE TABLE Dish ( id INTEGER primary key, name TEXT, description TEXT, menus_appeared INTEGER, times_appeared INTEGER, first_appeared INTEGER, last_appeared INTEGER, lowest_price REAL, highest_price REAL ); CREATE TABLE Menu ( id ...
movies_4
List the title of movies in Latin released between 1/01/1990 and 12/31/1995.
movies in Latin refers to language_name = 'Latin'; released between 1/01/1990 and 12/31/1995 refers to release_date BETWEEN '1990-01-01' AND '1995-12-31'
SELECT T1.title FROM movie AS T1 INNER JOIN movie_languages AS T2 ON T1.movie_id = T2.movie_id INNER JOIN language AS T3 ON T2.language_id = T3.language_id WHERE T3.language_name = 'Latin' AND T1.release_date BETWEEN '1990-01-01' AND '1995-12-31'
CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, country_name TEXT default NULL ); CREATE TABLE department ( department_id INTEGER not null primary key, department_name TEXT default NULL ); CREATE TABLE gender ( ...
video_games
What are the names of games that were released in 2007?
names of games refers to game_name; released in 2007 refers to release_year = 2007;
SELECT T3.game_name FROM game_platform AS T1 INNER JOIN game_publisher AS T2 ON T1.game_publisher_id = T2.id INNER JOIN game AS T3 ON T2.game_id = T3.id WHERE T1.release_year = 2007
CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE game ( id INTEGER not null primary key, genre_id INTEGER default NULL, game_name TEXT default NULL, foreign key (genre_id) references genre(id) ); C...
social_media
What is the gender of the user who has posted the tweet that is seen by the most number of unique users?
seen by the most number of unique users refers to Max(Reach)
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID ORDER BY T1.Reach DESC LIMIT 1
CREATE TABLE location ( LocationID INTEGER constraint location_pk primary key, Country TEXT, State TEXT, StateCode TEXT, City TEXT ); CREATE TABLE user ( UserID TEXT constraint user_pk primary key, Gender TEXT ); CREATE TABLE twitter ( ...
address
Count the number of postal points in the district represented by Kirkpatrick Ann.
postal points refer to zip_code;
SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.first_name = 'Kirkpatrick' AND T1.last_name = 'Ann'
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
bike_share_1
How many trips which start station and end station are the same?
start station refers to start_station_id; end station refers to end_station_id; start station and end station are the same refers to start_station_id = end_station_id;
SELECT SUM(IIF(start_station_id = end_station_id, 1, 0)) FROM trip
CREATE TABLE IF NOT EXISTS "station" ( id INTEGER not null primary key, name TEXT, lat REAL, long REAL, dock_count INTEGER, city TEXT, installation_date TEXT ); CREATE TABLE IF NOT EXISTS "status" ( statio...
software_company
What is the geographic identifier and income of the oldest customer?
the oldest customer refers to MAX(age); geographic identifier refers to GEOID; income refers to INCOME_K;
SELECT T1.GEOID, T2.INCOME_K FROM Customers AS T1 INNER JOIN Demog AS T2 ON T1.GEOID = T2.GEOID ORDER BY T1.age DESC LIMIT 1
CREATE TABLE Demog ( GEOID INTEGER constraint Demog_pk primary key, INHABITANTS_K REAL, INCOME_K REAL, A_VAR1 REAL, A_VAR2 REAL, A_VAR3 REAL, A_VAR4 REAL, A_VAR5 REAL, A_VAR6 REAL, A_VAR7 REAL, ...
mondial_geo
How many people reside in the nation's capital city, which is situated in the nation that attained independence on 8/15/1947?
SELECT T3.Population FROM politics AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code INNER JOIN city AS T3 ON T3.Name = T2.Capital WHERE T1.Independence = '1947-08-15'
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE I...
software_company
How many female customers have an education level of over 11?
education level of 11 refers to EDUCATIONNUM = 11; SEX = 'Female';
SELECT COUNT(ID) FROM Customers WHERE EDUCATIONNUM > 11 AND SEX = 'Female'
CREATE TABLE Demog ( GEOID INTEGER constraint Demog_pk primary key, INHABITANTS_K REAL, INCOME_K REAL, A_VAR1 REAL, A_VAR2 REAL, A_VAR3 REAL, A_VAR4 REAL, A_VAR5 REAL, A_VAR6 REAL, A_VAR7 REAL, ...
airline
What is the flight number of the flight operated by American Airlines Inc. that had the longest delay in departure?
flight numbers refers to OP_CARRIER_FL_NUM; American Airlines Inc. refers to Description = 'American Airlines Inc.: AA'; longest delay in departure refers to MAX(DEP_DELAY);
SELECT T1.OP_CARRIER_FL_NUM FROM Airlines AS T1 INNER JOIN Airports AS T2 ON T2.Code = T1.ORIGIN INNER JOIN `Air Carriers` AS T3 ON T1.OP_CARRIER_AIRLINE_ID = T3.Code WHERE T3.Description = 'American Airlines Inc.: AA' ORDER BY T1.DEP_TIME DESC LIMIT 1
CREATE TABLE IF NOT EXISTS "Air Carriers" ( Code INTEGER primary key, Description TEXT ); CREATE TABLE Airports ( Code TEXT primary key, Description TEXT ); CREATE TABLE Airlines ( FL_DATE TEXT, OP_CARRIER_AIRLINE_ID INTEGER, TAIL_NUM ...
language_corpus
What number of words are there on revision page 27457362?
This is not;
SELECT words FROM pages WHERE revision = 27457362
CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT, lang TEXT UNIQUE, locale TEXT UNIQUE, pages INTEGER DEFAULT 0, -- total pages in this language words INTEGER DEFAULT 0); CREATE TABLE sqlite_s...
mondial_geo
What is the proportion of English-speaking citizens in the countries that rely on the United States compared to the total number of citizens in those countries?
SELECT T2.Percentage * T1.Population FROM country AS T1 INNER JOIN language AS T2 ON T1.Code = T2.Country INNER JOIN politics AS T3 ON T3.Country = T2.Country WHERE T3.Dependent = 'USA' AND T2.Name = 'English'
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE I...
language_corpus
Among the wikipedia pages on Catalan with more than 300 different words, how many of them have a revision ID of over 28330000?
lid = 1 means it's Catalan language; more than 300 different words refers to words > 300; revision ID of over 28330000 refers to revision > 28330000
SELECT COUNT(lid) FROM pages WHERE lid = 1 AND words > 300 AND revision > 28330000
CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT, lang TEXT UNIQUE, locale TEXT UNIQUE, pages INTEGER DEFAULT 0, -- total pages in this language words INTEGER DEFAULT 0); CREATE TABLE sqlite_s...
social_media
From which country is the tweet with the most likes posted?
tweet with the most likes refers to Max(Likes)
SELECT T2.Country FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID ORDER BY T1.Likes DESC LIMIT 1
CREATE TABLE location ( LocationID INTEGER constraint location_pk primary key, Country TEXT, State TEXT, StateCode TEXT, City TEXT ); CREATE TABLE user ( UserID TEXT constraint user_pk primary key, Gender TEXT ); CREATE TABLE twitter ( ...
talkingdata
Calculate the percentage of the app user IDs under Industry tag category.
percentage = DIVIDE(MULTIPLY(CONCAT(COUNT(app_id WHERE category = 'Industry tag'), 100), COUNT(app_id)),'%');
SELECT SUM(IIF(T1.category = 'Industry tag', 1, 0)) * 100 / COUNT(T2.app_id) AS per FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id
CREATE TABLE `app_all` ( `app_id` INTEGER NOT NULL, PRIMARY KEY (`app_id`) ); CREATE TABLE `app_events` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `eve...
college_completion
Please list the names of the institutes in the state of Alabama whose all graduates in total exceeded 500 in 2011?
names of the institutes refers to chronname; graduates refers to grad_cohort; grad_cohort > 500; in 2011 refers to year = 2011; all students refer to race = 'X'.
SELECT DISTINCT T1.chronname FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T2.unitid = T1.unitid WHERE T1.state = 'Alabama' AND T2.year = 2011 AND T2.race = 'X' AND T2.grad_cohort > 500
CREATE TABLE institution_details ( unitid INTEGER constraint institution_details_pk primary key, chronname TEXT, city TEXT, state TEXT, level ...
student_loan
Among the students who filed for bankruptcy with an absence in school of no more than 6 months, how many students enlisted for the fire department?
absence of no more than 6 months refers to month < 6; department refers to organ; organ = 'fire_department';
SELECT COUNT(T1.name) FROM longest_absense_from_school AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name INNER JOIN enlist AS T3 ON T3.name = T2.name WHERE T3.organ = 'fire_department'
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
retails
What is the average price of the orders made by a customer in Germany?
DIVIDE(SUM(o_totalprice), COUNT(o_orderkey)) where n_name = 'GERMANY';
SELECT AVG(T3.o_totalprice) FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY'
CREATE TABLE `customer` ( `c_custkey` INTEGER NOT NULL, `c_mktsegment` TEXT DEFAULT NULL, `c_nationkey` INTEGER DEFAULT NULL, `c_name` TEXT DEFAULT NULL, `c_address` TEXT DEFAULT NULL, `c_phone` TEXT DEFAULT NULL, `c_acctbal` REAL DEFAULT NULL, `c_comment` TEXT DEFAULT NULL, PRIMARY KEY (`c_custkey`),...
works_cycles
How much is the amount to be paid by the company for the purchase order with the third highest freight amount?
amount to be paid refers to TotalDue;
SELECT TotalDue FROM PurchaseOrderHeader ORDER BY Freight DESC LIMIT 2, 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ...
legislator
What is the contact URL of Claire McCaskill?
contact URL refers to contact_form; Claire McCaskill is an official_full_name
SELECT T2.contact_form FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.official_full_name = 'Claire McCaskill' GROUP BY T2.contact_form
CREATE TABLE current ( ballotpedia_id TEXT, bioguide_id TEXT, birthday_bio DATE, cspan_id REAL, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_id ...
shakespeare
How many poems did Shakespeare write?
poems refers to GenreType = 'Poem'
SELECT COUNT(id) FROM works WHERE GenreType = 'Poem'
CREATE TABLE IF NOT EXISTS "chapters" ( id INTEGER primary key autoincrement, Act INTEGER not null, Scene INTEGER not null, Description TEXT not null, work_id INTEGER not null references works ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NO...
hockey
Please list the first 3 teams that got the most penalty minutes in 2006.
the first 3 teams that got the most penalty minutes refer to name where MAX(PIM) limit to 3; year = 2006;
SELECT name FROM Teams WHERE year = 2006 GROUP BY tmID, name ORDER BY SUM(PIM) DESC LIMIT 3
CREATE TABLE AwardsMisc ( name TEXT not null primary key, ID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT ); CREATE TABLE HOF ( year INTEGER, hofID TEXT not null primary key, name TEXT, category TEXT ); CREATE TABLE Teams ( year ...
authors
Identify by papers title those in which conferences have been published that do not have a website..
do not have a website refers to HomePage IS NULL OR HomePage = ''
SELECT T2.Title FROM Conference AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.ConferenceId WHERE T1.HomePage = '' AND T2.Title <> ''
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TE...
sales_in_weather
How many inches of total precipitation was recorded by the weather station of store no.2 on 2012/12/25?
store no.2 refers to store_nbr = 2; on 2012/12/25 refers to date = '2012-12-25'; total precipitation refers to preciptotal
SELECT T1.preciptotal FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2012-12-25' AND T2.store_nbr = 2
CREATE TABLE sales_in_weather ( date DATE, store_nbr INTEGER, item_nbr INTEGER, units INTEGER, primary key (store_nbr, date, item_nbr) ); CREATE TABLE weather ( station_nbr INTEGER, date DATE, tmax INTEGER, tmin INTEGER, tavg INTEGER, dep...
professional_basketball
How many players did not get more than 10 steals between the years 2000 and 2005?
did not get more than 10 steals refers to count(steals) < = 10; between the years 2000 and 2005 refers to season_id between 2000 and 2005
SELECT COUNT(DISTINCT playerID) FROM player_allstar WHERE season_id BETWEEN 2000 AND 2005 AND steals <= 10
CREATE TABLE awards_players ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT null, note TEXT null, pos TEXT null, primary key (playerID, year, award), foreign key (playerID) references players (playerID) on update ca...
shipping
Among all shipments delivered by Sue Newel, identify the percentage of shipments that were placed by Autoware Inc.
"Autoware Inc" is the cust_name; percentage = Divide (Count(ship_id where cust_name = 'Autoware Inc'), Count(ship_id)) * 100
SELECT CAST(SUM(CASE WHEN T3.cust_name = 'Autoware Inc' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) AS per FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id INNER JOIN customer AS T3 ON T3.cust_id = T1.cust_id WHERE T2.first_name = 'Sue' AND T2.last_name = 'Newell'
CREATE TABLE city ( city_id INTEGER primary key, city_name TEXT, state TEXT, population INTEGER, area REAL ); CREATE TABLE customer ( cust_id INTEGER primary key, cust_name TEXT, annual_revenue INTEGER, cust_type TEXT, addre...
synthea
Name the patients who had an allergy to soy.
allergy to soy refers to allergies where DESCRIPTION = 'Allergy to soya';
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to soya'
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT ...
books
How many orders were delivered in 2021?
delivered refers to status_value = 'Delivered'; in 2021 refers to status_date LIKE '2021%'
SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2021'
CREATE TABLE address_status ( status_id INTEGER primary key, address_status TEXT ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT ); CREATE TABLE book_language ( language_id INTEGER primary key, language_code TEXT, language...
mondial_geo
In which Country is the second highest volcanic mountain located in? Give the code of the country.
SELECT T3.Country FROM mountain AS T1 INNER JOIN geo_mountain AS T2 ON T1.Name = T2.Mountain INNER JOIN province AS T3 ON T3.Name = T2.Province ORDER BY T1.Height DESC LIMIT 1, 1
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE I...
professional_basketball
What is the number of NBA titles that Ray Allen has won throughout his NBA career?
NBA refers to lgID = 'NBA'
SELECT COUNT(T1.playerID) FROM player_allstar AS T1 INNER JOIN awards_players AS T2 ON T1.playerID = T2.playerID WHERE first_name = 'Ray' AND last_name = 'Allen'
CREATE TABLE awards_players ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT null, note TEXT null, pos TEXT null, primary key (playerID, year, award), foreign key (playerID) references players (playerID) on update ca...
music_tracker
What is the tag of the album with the highest amount of downloads?
album refers to releaseType; the highest amount of downloads refers to MAX(totalSnatched);
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.releaseType = 'album' ORDER BY T1.totalSnatched DESC LIMIT 1
CREATE TABLE IF NOT EXISTS "torrents" ( groupName TEXT, totalSnatched INTEGER, artist TEXT, groupYear INTEGER, releaseType TEXT, groupId INTEGER, id INTEGER constraint torrents_pk primary key ); CREATE TABLE IF NOT EXISTS "tags" ( "in...
computer_student
How many students are under advisor 415?
advisor 415 refers to p_id_dummy = 415
SELECT COUNT(*) FROM advisedBy WHERE p_id_dummy = 415
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT ); CREATE TABLE person ( p_id INTEGER constraint person_pk primary key, professor INTEGER, student INTEGER, hasPosition TEXT, inPhase ...
beer_factory
What is the average number of root beers of the brand A&W sold in a day in August, 2014?
average = DIVIDE(SUM(COUNT(RootBeerID WHERE BrandName = 'A&W' AND SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08')), 31); A&W refers to BrandName = 'A&W'; in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08';
SELECT CAST(COUNT(T1.BrandID) AS REAL) / 31 FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2014-08%' AND T3.BrandName = 'A&W'
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
talkingdata
What is the gender of the youngest user?
youngest user refers to MIN(age);
SELECT gender FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age )
CREATE TABLE `app_all` ( `app_id` INTEGER NOT NULL, PRIMARY KEY (`app_id`) ); CREATE TABLE `app_events` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `eve...
works_cycles
What are the sales tax records charged by multiple types of tax?
multiple types of tax refers to Name like '%+%';
SELECT SalesTaxRateID FROM SalesTaxRate WHERE Name LIKE '%+%'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ...
regional_sales
Provide order number, warehouse code of customers Elorac, Corp.
"Elorac, Corp" is the Customer Names
SELECT DISTINCT T1.OrderNumber, T1.WarehouseCode FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE T2.`Customer Names` = 'Elorac, Corp'
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT ...
car_retails
State 10 emails of UK Sales Rep who have the lowest credit limit.
UK is a country; Sales Rep is a job title;
SELECT DISTINCT T2.email FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' AND T1.country = 'UK' ORDER BY T1.creditLimit LIMIT 10
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ); CREATE...
airline
Among the flights on 2018/8/1, how many of them were scheduled to depart from John F. Kennedy International in New York?
on 2018/8/1 refers to FL_DATE = '2018/8/1'; depart from refers to ORIGIN; John F. Kennedy International in New York refers to Description = 'New York, NY: John F. Kennedy International';
SELECT COUNT(T1.Code) FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.ORIGIN WHERE T2.FL_DATE = '2018/8/1' AND T1.Description = 'New York, NY: John F. Kennedy International'
CREATE TABLE IF NOT EXISTS "Air Carriers" ( Code INTEGER primary key, Description TEXT ); CREATE TABLE Airports ( Code TEXT primary key, Description TEXT ); CREATE TABLE Airlines ( FL_DATE TEXT, OP_CARRIER_AIRLINE_ID INTEGER, TAIL_NUM ...
regional_sales
Please list the customer names whose order quantity was more than 5 on 6/1/2018.
order quantity was more than 5 on 6/1/2018 refers to Order Quantity > 5 where OrderDate = 6/1/2018;
SELECT T FROM ( SELECT DISTINCT CASE WHEN SUM(T1.`Order Quantity`) > 5 THEN T2.`Customer Names` END AS T FROM `Sales Orders` T1 INNER JOIN Customers T2 ON T2.CustomerID = T1._CustomerID WHERE T1.OrderDate = '6/1/18' GROUP BY T1._CustomerID ) WHERE T IS NOT NULL
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT ...
app_store
What is the total Sentiment polarity score of the most expensive app?
total sentiment polarity score = sum(Sentiment_Polarity); most expensive app refers to MAX(Price);
SELECT SUM(T2.Sentiment_Polarity) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Price = ( SELECT MAX(Price) FROM playstore )
CREATE TABLE IF NOT EXISTS "playstore" ( App TEXT, Category TEXT, Rating REAL, Reviews INTEGER, Size TEXT, Installs TEXT, Type TEXT, Price TEXT, "Content Rating" TEXT, Genres TEXT ); CREA...
retail_world
How many customers are located in London?
London refers to City = 'London'
SELECT COUNT(CustomerID) FROM Customers WHERE City = 'London'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, ...
world
What is the capital city and population of San Marino?
capital city refers to Capital; San Marino is a name of country;
SELECT T1.Capital, T2.Population FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'San Marino'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE `City` ( `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `Name` TEXT NOT NULL DEFAULT '', `CountryCode` TEXT NOT NULL DEFAULT '', `District` TEXT NOT NULL DEFAULT '', `Population` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY (`CountryCode`) REFERENCES `Countr...
sales
Has Alex purchased product with id 498?
WHEN ProductID = 498 AND FirstName = 'Alex' means that Alex purchased a product; WHEN ProductID = 498 AND FirstName NOT 'Alex' means Alex has not purchased a product;
SELECT IIF(T1.ProductID = 498, 'YES', 'NO') FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Alex'
CREATE TABLE Customers ( CustomerID INTEGER not null primary key, FirstName TEXT not null, MiddleInitial TEXT null, LastName TEXT not null ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, FirstName TEXT not null, MiddleIn...
cs_semester
What are the GPAs of the unpaid Research Assistants?
Unpaid Research Assistants undertake their work without payment in which salary = 'free';
SELECT T2.gpa FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'free'
CREATE TABLE IF NOT EXISTS "course" ( course_id INTEGER constraint course_pk primary key, name TEXT, credit INTEGER, diff INTEGER ); CREATE TABLE prof ( prof_id INTEGER constraint prof_pk primary key, gender TEXT, first_na...
airline
What are the air carriers of the flights that flew on August 25, 2018 that have departure delay of -5?
on August 25, 2018 refers to FL_DATE = '2018/8/25'; departure delay of -5 refers to DEP_DELAY = -5;
SELECT T1.Description FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.FL_DATE = '2018/8/25' GROUP BY T1.Description
CREATE TABLE IF NOT EXISTS "Air Carriers" ( Code INTEGER primary key, Description TEXT ); CREATE TABLE Airports ( Code TEXT primary key, Description TEXT ); CREATE TABLE Airlines ( FL_DATE TEXT, OP_CARRIER_AIRLINE_ID INTEGER, TAIL_NUM ...
food_inspection_2
How many restaurants were inspected on 2015/5/8?
restaurant refers to facility_type = 'Restaurant'; on 2015/5/8 refers to inspection_date = '2015-05-08'
SELECT COUNT(T2.license_no) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T2.inspection_date = '2015-05-08' AND T1.facility_type = 'Restaurant'
CREATE TABLE employee ( employee_id INTEGER primary key, first_name TEXT, last_name TEXT, address TEXT, city TEXT, state TEXT, zip INTEGER, phone TEXT, title TEXT, salary INTEGER, supervisor INTEGER, foreign key (s...
food_inspection
Which establishment has the highest number of inspections done? Give the name of the establishment and calculate for its average score per inspection.
establishment refers to business_id; the highest number of inspections refers to MAX(COUNT(business_id)); avg(score);
SELECT T2.name, AVG(T1.score) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id GROUP BY T2.name ORDER BY COUNT(T2.business_id) DESC LIMIT 1
CREATE TABLE `businesses` ( `business_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `address` TEXT DEFAULT NULL, `city` TEXT DEFAULT NULL, `postal_code` TEXT DEFAULT NULL, `latitude` REAL DEFAULT NULL, `longitude` REAL DEFAULT NULL, `phone_number` INTEGER DEFAULT NULL, `tax_code` TEXT DEFAULT NULL, `b...
restaurant
What cities are located in Northern California?
Northern California refers to region = 'northern california'
SELECT city FROM geographic WHERE region = 'northern california'
CREATE TABLE geographic ( city TEXT not null primary key, county TEXT null, region TEXT null ); CREATE TABLE generalinfo ( id_restaurant INTEGER not null primary key, label TEXT null, food_type TEXT null, city TEXT null, review REA...
food_inspection
What is the description of the low risk violation of Tiramisu Kitchen on 2014/1/14?
Tiramisu Kitchen is the name of the business; 2014/1/14 refers to date = '2014-01-14'; low risk violations refer to risk_category = 'Low Risk';
SELECT T1.description FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.`date` = '2014-01-14' AND T2.name = 'Tiramisu Kitchen' AND T1.risk_category = 'Low Risk'
CREATE TABLE `businesses` ( `business_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `address` TEXT DEFAULT NULL, `city` TEXT DEFAULT NULL, `postal_code` TEXT DEFAULT NULL, `latitude` REAL DEFAULT NULL, `longitude` REAL DEFAULT NULL, `phone_number` INTEGER DEFAULT NULL, `tax_code` TEXT DEFAULT NULL, `b...
language_corpus
List all the Catalan language wikipedia page title with less than 10 number of different words in these pages.
less than 10 number of different words refers to words < 10
SELECT title FROM pages WHERE words < 10
CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT, lang TEXT UNIQUE, locale TEXT UNIQUE, pages INTEGER DEFAULT 0, -- total pages in this language words INTEGER DEFAULT 0); CREATE TABLE sqlite_s...