db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
public_review_platform
List the names of business in AZ with a rating of 5.
AZ refers to state = 'AZ'; rating refers to stars;
SELECT business_id FROM Business WHERE state LIKE 'AZ' AND stars = 5
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
regional_sales
Identify the store location and sales team who processed the sales order 'SO - 0001004'.
sales order 'SO - 0001004' refers to OrderNumber = 'SO - 0001004'; store location refers to City Name
SELECT T3.`Sales Team`, T1.`City Name` FROM `Store Locations` AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._StoreID = T1.StoreID INNER JOIN `Sales Team` AS T3 ON T3.SalesTeamID = T2._SalesTeamID WHERE T2.OrderNumber = 'SO - 0001004'
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
social_media
For the tweet which got the most likes, state the gender of the user who tweeted it.
most likes refers to Max(Likes)
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID ORDER BY T1.Likes DESC LIMIT 1
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
public_review_platform
How many more "Chinese" than "Filipino" Yelp businesses?
Chinese refers to category_name = 'Chinese'; Filipino refers to category_name = 'Filipino'; how many more = SUBTRACT(SUM(category_name = 'Chinese'), SUM(category_name = 'Filipino'));
SELECT SUM(CASE WHEN T1.category_name LIKE 'Chinese' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.category_name LIKE 'Filipino' THEN 1 ELSE 0 END) FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
european_football_1
How many matches played in the 2019 season of Scottish Championship league were ended with an equal result of 2-2?
matches refer to Div; Scottish Championship is a name of the league; equal result of 2-2 refers to FTAG = 2 AND FTHG = 2;
SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2019 AND T2.name = 'Scottish Championship' AND T1.FTAG = 2 AND T1.FTHG = 2
CREATE TABLE divisions ( division TEXT not null primary key, name TEXT, -- country TEXT, -- Example Values: `Belgium`, `Deutschland`, `England`, `France`, `Greece` | Value Statics: Total count 21 - Distinct count 11 - Null count 0 ); CREATE TABLE matchs ( Date DATE, -- HomeTeam TEXT, -- season INTEGER, ...
world_development_indicators
What's the agregation method for the indicator whose value is 133 in 1960 for the Arab World?
in 1960 refers to Year = 1960; for the Arab World refers to CountryName = 'Arab World'
SELECT T2.AggregationMethod FROM Indicators AS T1 INNER JOIN Series AS T2 ON T1.IndicatorName = T2.IndicatorName INNER JOIN Country AS T3 ON T1.CountryCode = T3.CountryCode WHERE T3.ShortName = 'Arab World' AND T1.Value = 133 AND T1.Year = 1960
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
social_media
Which state was the tweet `tw-685681052912873473` from? Give the state code.
tw-685681052912873473' is the TweetID
SELECT T2.StateCode FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.TweetID = 'tw-685681052912873473'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
public_review_platform
Who has got the most number of "funny" type of compliments? Give the user ID.
type of compliments refers to compliment_type; most number of funny type of compliments refers to MAX(COUNT(number of compliments = 'high' WHERE compliment_type = 'funny'));
SELECT user_id FROM Users_Compliments WHERE compliment_id IN ( SELECT compliment_id FROM Compliments WHERE compliment_type LIKE 'funny' )
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
professional_basketball
Which coach of the Chicago Bulls during the year 1981 won the NBA Coach of the Year award in the 1970s?
"Chicago Bull" is the name of team; during the year 1981 refers to year = 1981; 'NBA Coach of the Year' is the award; in the 1970s refers to year between 1970 to 1979
SELECT DISTINCT T2.coachID FROM coaches AS T1 INNER JOIN awards_coaches AS T2 ON T1.coachID = T2.coachID INNER JOIN teams AS T3 ON T3.tmID = T1.tmID WHERE T2.award = 'NBA Coach of the Year' AND T2.year BETWEEN 1970 AND 1979 AND T1.year = 1981 AND T3.name = 'Chicago Bulls'
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
social_media
What is the day of the week that tweet with ID tw-682712873332805633 was posted?
"tw-682712873332805633" is the TweetID; day of the week refers to Weekday
SELECT Weekday FROM twitter WHERE TweetID = 'tw-682712873332805633'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
public_review_platform
For the Yelp business which had the most number of "short" tips, which category does it belong to?
short tips refers to tip_length = 'short'; most number of short tips refers to MAX(COUNT(tip_length = 'short')); category refers to category_name;
SELECT DISTINCT T1.category_name FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id INNER JOIN Tips AS T4 ON T3.business_id = T4.business_id WHERE T4.tip_length LIKE 'short'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
world_development_indicators
What is the average value of Adolescent fertility rate in the country whose Alpha2Code is 1A?
average value = AVG(Value) where IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)'
SELECT CAST(SUM(T2.Value) AS REAL) * 100 / COUNT(T2.Year) FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.Alpha2Code = '1A' AND T2.IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)'
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
trains
Which direction do most of the trains with rectangle-shaped second cars run?
most of the trains refers to MAX(count(id)); second cars refers to position = 2
SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 2 AND T1.shape = 'rectangle' GROUP BY T2.direction ORDER BY COUNT(T2.id) DESC LIMIT 1
CREATE TABLE cars ( `id` INTEGER NOT NULL, -- `load_shape` TEXT DEFAULT NULL, -- Example Values: `circle`, `hexagon`, `triangle`, `rectangle`, `diamond` | Value Statics: Total count 63 - Distinct count 5 - Null count 0 `train_id` INTEGER DEFAULT NULL, -- `load_num` INTEGER DEFAULT NULL, -- Example Values: `1...
public_review_platform
User No."63469" has got "1" like for a tip to the Yelp business, which city is that business located in?
user No. refers to user_id;
SELECT T1.city FROM Business AS T1 INNER JOIN Tips AS T2 ON T1.business_id = T2.business_id WHERE T2.likes = 1 AND T2.user_id = 63469
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
regional_sales
How many sales orders were processed by the store located in Chandler in 2020?
"Chandler" is the City Name; orders refers to OrderDate; in 2020 refers to Substr(OrderDate, -2) = '20'
SELECT SUM(CASE WHEN T2.`City Name` = 'Chandler' AND T1.OrderDate LIKE '%/%/20' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
social_media
Count the total number of tweet IDs in `en`.
"en" is the language and refers to Lang = 'en'
SELECT COUNT(DISTINCT TweetID) FROM twitter WHERE Lang = 'en'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
world_development_indicators
For the country that has notes on the indicator Inflation, consumer prices, in which region is it in?
indicator Inflation, consumer prices refers to IndicatorName = 'Inflation, consumer prices (annual %)'
SELECT T1.Region FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode INNER JOIN Series AS T3 ON T2.Seriescode = T3.SeriesCode WHERE T3.IndicatorName = 'Inflation, consumer prices (annual %)'
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
social_media
What is the percentage of the tweets from California are positive?
"California" is the State; positive tweet refers to Sentiment > 0; percentage = Divide (Count(TweetID where Sentiment > 0), Count (TweetID)) * 100
SELECT SUM(CASE WHEN T1.Sentiment > 0 THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS percentage FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE State = 'California'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
public_review_platform
How many hours does the Yelp business No. "5734" open on Saturday?
how many hours = SUBTRACT(closing_time, opening_time); business No. refers to business_id; open on Saturday refers to day_of_week = 'Saturday';
SELECT T1.closing_time - T1.opening_time AS "hour" FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id WHERE T2.day_of_week LIKE 'Saturday' AND T1.business_id = 5734
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
world_development_indicators
How many countries have notes on the indicator Stocks traded, turnover ratio of domestic shares?
indicator Stocks traded, turnover ratio of domestic shares refers to IndicatorName = 'Stocks traded, turnover ratio of domestic shares (%)'
SELECT COUNT(T1.Countrycode) FROM CountryNotes AS T1 INNER JOIN Series AS T2 ON T1.Seriescode = T2.SeriesCode WHERE T2.IndicatorName = 'Stocks traded, turnover ratio of domestic shares (%)'
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
social_media
How many tweets have been posted on Wednesday?
"Wednesday" is the Weekday
SELECT COUNT(TweetID) FROM twitter WHERE Weekday = 'Wednesday'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
world_development_indicators
What is the percentage of increase of the indicator on Adolescent fertility rate from 1960 to 1961 in the country whose Alpha2Code is 1A?
the percentage of increase from 1960 to 1961 = divide(subtract(sum(value where Year = 1961), sum(Value where Year = 1960)), sum(Value where Year = 1960)) *100%; indicator on Adolescent fertility rate refers to IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)%'
SELECT (( SELECT T2.Value FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.Alpha2Code = '1A' AND T2.IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)' AND T2.Year = 1961 ) - ( SELECT T2.Value FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.Coun...
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
social_media
How many unique users have seen tweet with text `Happy New Year to all those AWS instances of ours!`?
"Happy New Year to all those AWS instances of ours!" is the text; seen unique users refers to Reach
SELECT Reach FROM twitter WHERE text = 'Happy New Year to all those AWS instances of ours!'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
mental_health_survey
How many questions were asked in the questionary for the mental health survey?
null
SELECT COUNT(questiontext) FROM Question
CREATE TABLE Answer ( SurveyID INTEGER constraint Answer_Survey_SurveyID_fk references Survey, -- Example Values: `2014`, `2016`, `2017`, `2018`, `2019` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 QuestionID INTEGER constraint Answer_Question_questionid_fk references Question, -- UserI...
public_review_platform
In which year did the user who has given the most number of "short" tips join the Yelp?
year the user join the Yelp refers to user_yelping_since_year; most number of short tips refers to MAX(COUNT(tip_length = 'Short'));
SELECT T2.user_yelping_since_year FROM Tips AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id WHERE T1.tip_length LIKE 'short' GROUP BY T2.user_yelping_since_year ORDER BY COUNT(T1.tip_length) DESC LIMIT 1
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
professional_basketball
Which are the teams coached by 'adelmri01' from year 1990-1995. List the team name, year and offense point.
year 1990-1995 refers to year between 1990 and 1995; 'adelmri01' is the coachID; offense point refers to o_fgm
SELECT T2.name, T1.year, T2.o_pts FROM coaches AS T1 INNER JOIN teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.year BETWEEN 1990 AND 1995 AND T1.coachID = 'adelmri01'
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
world_development_indicators
Please list the notes for Aruba on the indicators under the topic of Environment: Energy production & use.
note refers to Description; for Aruba refers to ShortName = 'Aruba'
SELECT T2.Description FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode INNER JOIN Series AS T3 ON T2.Seriescode = T3.SeriesCode WHERE T1.ShortName = 'Aruba' AND T3.Topic = 'Environment: Energy production & use'
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
social_media
List down the text of tweets posted by unknown gender users.
unknown gender user refers to Gender = 'Unknown'
SELECT T1.text FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Unknown'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
european_football_1
What is the most consecutive games tied by Ebbsfleet as an away team in the 2008 season?
consecutive games mean happen one after the other without interruption and refer to Date; tied refers to FTR = 'D';
SELECT COUNT(*) FROM matchs WHERE season = 2008 AND AwayTeam = 'Ebbsfleet' AND FTR = 'D'
CREATE TABLE divisions ( division TEXT not null primary key, name TEXT, -- country TEXT, -- Example Values: `Belgium`, `Deutschland`, `England`, `France`, `Greece` | Value Statics: Total count 21 - Distinct count 11 - Null count 0 ); CREATE TABLE matchs ( Date DATE, -- HomeTeam TEXT, -- season INTEGER, ...
world_development_indicators
What's the value of the indicator whose long definition is "Adolescent fertility rate is the number of births per 1,000 women ages 15-19." for the Arab World in 1960?
in 1960 refers to Year = 1960; for the Arab World refers to CountryName = 'Arab World'
SELECT T1.Value FROM Indicators AS T1 INNER JOIN Series AS T2 ON T1.IndicatorName = T2.IndicatorName INNER JOIN Country AS T3 ON T1.CountryCode = T3.CountryCode WHERE T2.LongDefinition = 'Adolescent fertility rate is the number of births per 1,000 women ages 15-19.' AND T3.ShortName = 'Arab World' AND T1.Year = 1960
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
social_media
Is 3751 the location ID for tweet with ID tw-682714048199311366?
"tw-682714048199311366" is the TweetID
SELECT LocationID FROM twitter WHERE TweetID = 'tw-682714048199311366'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
mental_health_survey
How many respondents of the mental health survey were diagnosed with 'Substance Use Disorder'?
respondents' and 'users' are synonyms
SELECT COUNT(AnswerText) FROM Answer WHERE AnswerText LIKE 'Substance Use Disorder'
CREATE TABLE Answer ( SurveyID INTEGER constraint Answer_Survey_SurveyID_fk references Survey, -- Example Values: `2014`, `2016`, `2017`, `2018`, `2019` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 QuestionID INTEGER constraint Answer_Question_questionid_fk references Question, -- UserI...
public_review_platform
Give the percentage of "Automotive" businesses among all the Yelp businesses.
automotive businesses refers to category_name = 'Automotive'; percentage = MULTIPLY(DIVIDE(SUM(category_name = 'Automotive'), COUNT(business_id)), 1.0);
SELECT CAST(SUM(CASE WHEN T2.category_name LIKE 'Automotive' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.business_id) AS "percentage" FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
professional_basketball
Which player, born in Winter Haven, played 12 minutes per season during the 1980s in the All-Stars?
born in Winter Haven refers to birthCity = 'Winter Haven'; during the 1980s in All-Stars refers to season_id = 1980; played in 12 minutes  per season refers to minutes = 12
SELECT DISTINCT T1.firstName, T1.middleName, T1.lastName FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T1.birthCity = 'Winter Haven' AND T2.season_id BETWEEN 1980 AND 1989 AND T2.minutes = 12
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
social_media
What is the gender of the user who posted a tweet with ID tw-682714583044243456?
"tw-682714583044243456" is the TweetID
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.TweetID = 'tw-682714583044243456'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
mental_health_survey
How many respondents who participated in the survey in 2014 work remotely at least 50% of the time?
respondents' and 'users' are synonyms; work remotely at least 50% of the time refers to AnswerText(SurveyID = 2014& QuestionID = 93) = 'Yes'
SELECT COUNT(T1.AnswerText) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.QuestionID = 93 AND T1.SurveyID = 2014 AND T1.AnswerText = 'Yes'
CREATE TABLE Answer ( SurveyID INTEGER constraint Answer_Survey_SurveyID_fk references Survey, -- Example Values: `2014`, `2016`, `2017`, `2018`, `2019` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 QuestionID INTEGER constraint Answer_Question_questionid_fk references Question, -- UserI...
professional_basketball
Between the years 1990 and 2007, of the total rebounds achieved by each player, how many managed to exceed 75% of defensive rebounds?
the year 1990 and 2007 refers to year BETWEEN 1990 AND 2007; exceed 75% of defensive rebounds refers to Divide (dRebounds, rebounds) * 100 > 75
SELECT COUNT(DISTINCT playerID) FROM player_allstar WHERE CAST(d_rebounds AS REAL) * 100 / rebounds > 75 AND season_id BETWEEN 1990 AND 2007
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
trains
How many trains are running west?
west is a direction
SELECT COUNT(id) FROM trains WHERE direction = 'west'
CREATE TABLE cars ( `id` INTEGER NOT NULL, -- `load_shape` TEXT DEFAULT NULL, -- Example Values: `circle`, `hexagon`, `triangle`, `rectangle`, `diamond` | Value Statics: Total count 63 - Distinct count 5 - Null count 0 `train_id` INTEGER DEFAULT NULL, -- `load_num` INTEGER DEFAULT NULL, -- Example Values: `1...
professional_basketball
Of all the All-star players who played in the Eastern Conference for no more than 5 minutes, how many went to Illinois College?
Eastern conference refers to conference = 'East'; no more than 5 minutes refers to minutes < 5
SELECT COUNT(DISTINCT T1.playerID) FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T2.conference = 'East' AND T2.minutes <= 5 AND T1.college = 'Illinois'
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
world_development_indicators
Which country's indicator for Adolescent fertility rate is the highest in 1960, please give its special notes.
indicator for Adolescent fertility rate is the highest refers to max(value where IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)'); in 1960 refers to year = '1960'
SELECT DISTINCT T1.CountryCode, T1.SpecialNotes FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T2.Value = ( SELECT Value FROM Indicators WHERE IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)' AND Year = 1960 ORDER BY Value DESC LIMIT 1 )
CREATE TABLE CountryNotes ( primary key (Countrycode, Seriescode), FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode), Seriescode TEXT NOT NULL, -- Countrycode TEXT NOT NULL, -- Description TEXT, -- FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode), ); CREATE TABLE Series ( BasePeriod TEXT, --...
social_media
Calculate the total number of male tweet IDs.
"Male" is the Gender
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Male'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
mental_health_survey
List the top three popular responses to the question of the survey in 2017 with the question ID no.85.
survey in 2017 refers to SurveyID = 2017; questionID = 85; MAX(COUNT(AnswerText))
SELECT AnswerText FROM Answer WHERE QuestionID = 85 AND SurveyID = 2017 GROUP BY AnswerText ORDER BY COUNT(AnswerText) DESC LIMIT 3
CREATE TABLE Answer ( SurveyID INTEGER constraint Answer_Survey_SurveyID_fk references Survey, -- Example Values: `2014`, `2016`, `2017`, `2018`, `2019` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 QuestionID INTEGER constraint Answer_Question_questionid_fk references Question, -- UserI...
public_review_platform
Please provide the attribute values ​​of the bussinesses with fashion in Scottsdale.
fashion refers to category_name = 'Fashion'; Scottsdale refers to city = 'Scottsdale';
SELECT T2.attribute_value FROM Business AS T1 INNER JOIN Business_Attributes AS T2 ON T1.business_id = T2.business_id INNER JOIN Business_Categories AS T3 ON T1.business_id = T3.business_id INNER JOIN Categories AS T4 ON T3.category_id = T4.category_id WHERE T4.category_name LIKE 'Fashion' AND T1.city LIKE 'Scottsdale'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
professional_basketball
in which year costela01 obtained the best balance of games won as a coach?
"costela01" is the coachID; best balance of game won refers to Max(Divide(won, Sum(won, lost)))
SELECT year FROM coaches WHERE coachID = 'costela01' ORDER BY CAST(won AS REAL) / (won + lost) DESC LIMIT 1
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
social_media
List down all of the texts posted on Twitter on Thursday.
"Thursday" is the Weekday
SELECT text FROM twitter WHERE Weekday = 'Thursday'
CREATE TABLE location ( StateCode TEXT, -- LocationID INTEGER constraint location_pk primary key, City TEXT, -- Country TEXT, -- State TEXT, -- ); CREATE TABLE twitter ( Reach INTEGER, -- Lang TEXT, -- Klout INTEGER, -- foreign key (LocationID) references location(LocationID), Hour INTEGER, -- ...
works_cycles
Which territory has the most customers as of 9/12/2014?
ModifiedDate between'2014-09-12 00:00:00' and '2014-09-12 23:59:59';
SELECT TerritoryID FROM Customer WHERE ModifiedDate < '2014-12-09' GROUP BY TerritoryID ORDER BY COUNT(TerritoryID) DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
What is the salary range of the student with an email of grosellg@hku.hk?
salary range refers to salary;
SELECT T1.salary FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T2.email = 'grosellg@hku.hk'
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
List all active vendors who offer a purchasing web service.
active vendors refers to ActiveFlag = 1; vendor who offer a purchasing web service refers to PurchasingWebServiceURL NOT null;
SELECT Name FROM Vendor WHERE ActiveFlag = 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
What percentage of students are highly satisfied with the Intro to Database 2 course?
percentage = MULTIPLY(DIVIDE(COUNT(MAX(sat)), (COUNT(student_id))), 1.0); highly satisfied refers to MAX(sat);
SELECT CAST(( SELECT COUNT(*) FROM course WHERE name = 'Intro to Database 2' AND course_id IN ( SELECT course_id FROM registration WHERE sat = ( SELECT MAX(sat) FROM registration ) ) ) AS REAL) * 100 / COUNT(T1.student_id) FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.name = '...
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
What is the business ID of the person who has made the most sales total year to date?
business ID refers to BusinessEntityID; sales total year to date refers to SalesYTD; most sales total year to date refers to MAX(SalesYTD);
SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesYTD DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
List the student's first and last name that got a C in the course named "Applied Deep Learning".
student's first name refers to f_name; student's last name refers to l_name; got a C refers to grade = 'C';
SELECT T1.f_name, T1.l_name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Applied Deep Learning ' AND T2.grade = 'C'
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
When is the modified date of the phone number "1500 555-0143"?
null
SELECT ModifiedDate FROM PersonPhone WHERE PhoneNumber = '1 (11) 500 555-0143'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Among professors with the highest teachability, how many of their students have high salary?
highest teachability refers to MAX(teachability); high salary refers to salary = 'high';
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T1.salary = 'high' ORDER BY T2.teachingability DESC LIMIT 1
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
What proportion of sales orders are made from the United Kingdom?
proportion = DIVIDE(SUM(Name = 'UK')), (COUNT(SalesOrderID))) as count;
SELECT CAST(SUM(CASE WHEN T2.Name = 'United Kingdom' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.SalesOrderID) FROM SalesOrderHeader AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Among courses with difficulty of 3, how many students have intellegence level of 2?
difficulty of 3 refers to diff = 3; intelligence = 2
SELECT COUNT(T1.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.diff = 3 AND T1.intelligence = 2
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
Among all the production technicians, how many have a below average pay rate for a production technician?
production technician is a job title; below average rate refers to Rate<AVG(Rate);
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' AND T2.Rate < ( SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ...
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Find the university from which the professor who advised most undergraduate students graduated.
university from which the professor graduated refers to graduate_from; undergraduate students refers to type = 'UG';
SELECT T1.graduate_from 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.type = 'UG' GROUP BY T1.prof_id ORDER BY COUNT(T2.student_id) DESC LIMIT 1
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
List the first names of the people with more than 65 sick leave hours.
SickLeaveHours>65;
SELECT T2.FirstName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.SickLeaveHours > 65
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Among the professors with more than average teaching ability, list the full name and email address of the professors who advise two or more students.
more than average teaching ability refers to teachingability > AVG(teachingability); full_name of the professor = first_name, last_name; email address of the professor refers to email; advises two or more students refers to COUNT(student_id) > = 2;
SELECT T2.first_name, T2.last_name, T2.email FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T2.teachingability > ( SELECT AVG(teachingability) FROM prof ) GROUP BY T2.prof_id HAVING COUNT(T1.student_id) >= 2
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
What is the shipping address for the sales order "43873"?
shipping address = AddressLine1+AddressLine2+City;
SELECT T1.ShipToAddressID FROM SalesOrderHeader AS T1 INNER JOIN Address AS T2 ON T1.BillToAddressID = T2.AddressID WHERE T1.SalesOrderID = 43873 GROUP BY T1.ShipToAddressID
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
For the students with an intelligence of 5, list the full name and courses taken by them who have less than a 3 GPA.
full name of the students = f_name, l_name; gpa < 3;
SELECT T1.f_name, T1.l_name, T3.name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T1.intelligence = 5 AND T1.gpa < 3
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
How many customers are there in Canada?
Canada is name of sales territory
SELECT COUNT(T2.CustomerID) FROM SalesTerritory AS T1 INNER JOIN Customer AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.Name = 'Canada'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Among the students with a capability below 3, what is the difference of undergraduate students from research postgraduate students?
capability < 3; difference = subtract(count(type = 'UG')), (count(type = 'RPG')); undergraduate students refers to type = 'UG'; research postgraduate students refers to type = 'RPG';
SELECT SUM(CASE WHEN T2.type = 'UG' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.type = 'RPG' THEN 1 ELSE 0 END) FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.capability < 3
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
What is the email address of the Facilities Manager?
Facilities Manager is a job title
SELECT T3.EmailAddress FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmailAddress AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.JobTitle = 'Facilities Manager'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Among students that gave satisfaction of value 4 for the course named "Statistical Learning", how many of them have a gpa of 3.8?
satisfaction refers to sat; sat = 4; gpa = 3.8
SELECT COUNT(T1.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Statistical learning' AND T2.sat = 4 AND T1.gpa = 3.8
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
How many sales orders did the salesperson David R. Campbell create?
SP is an abbreviation for Sales Person; PersonType = 'SP';
SELECT COUNT(T2.TotalDue) FROM Person AS T1 INNER JOIN SalesOrderHeader AS T2 ON T1.ModifiedDate = T2.DueDate WHERE T1.FirstName = 'David' AND T1.MiddleName = 'R' AND T1.LastName = 'Campbell' AND T1.PersonType = 'SP'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
How many professors are teaching course ID 18?
professors refers to taughtBy.p_id; course ID 18 refers to taughtBy.course_id
SELECT COUNT(DISTINCT p_id) FROM taughtBy WHERE course_id = 18
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
What is the total shipment by "cargo transport 5" cost of all purchase orders created on 12/14/2011?
Catgo Transport 5 is a name of shipping method; OrderDate = '2011-12-14'; total shipment cost = SUM(Freight);
SELECT SUM(t2.freight) FROM ShipMethod AS t1 INNER JOIN PurchaseOrderHeader AS t2 ON t1.shipmethodid = t2.shipmethodid WHERE t1.name = 'cargo transport 5' AND t2.orderdate = '2011-12-14'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Among research postgraduate students, give the name of the course with the student satisfaction value of 1.
research postgraduate students refers to type = 'RPG'; name of the course refers to name; satisfaction refers to sat; sat = 1;
SELECT T3.name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T2.sat = 1 AND T1.type = 'RPG'
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
Is the phone number "114-555-0100" a work number or a home number?
null
SELECT T2.Name FROM PersonPhone AS T1 INNER JOIN PhoneNumberType AS T2 ON T1.PhoneNumberTypeID = T2.PhoneNumberTypeID WHERE T1.PhoneNumber = '114-555-0100'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List all the purchase order ids of the vendor with a below average rating.
below average rating refers to CreditRating = 5;
SELECT T2.PurchaseOrderID FROM Vendor AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.BusinessEntityID = T2.VendorID WHERE T1.CreditRating = 5
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
How many courses are there for basic or medium undergraduate courses?
basic or medium undergraduate courses refers to courseLevel = 'Level_300'; courses refers to course.course_id
SELECT COUNT(course_id) FROM course WHERE courseLevel = 'Level_300'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
How many employees in the Information Service department work the evening shift?
Information Service is a name of department;
SELECT COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN Shift AS T3 ON T2.ShiftId = T3.ShiftId WHERE T1.Name = 'Information Services' AND T3.Name = 'Evening'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
What is the average number of students for each advisor?
students refers to advisedBy.p_id; advisor refers to p_id_dummy; average number = avg(count(advisedBy.p_id))
SELECT CAST(COUNT(p_id) AS REAL) / COUNT(DISTINCT p_id_dummy) AS avgnum FROM advisedBy GROUP BY p_id_dummy
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
What is the full name of the Vice President of Production?
full name = FirstName+MiddleName+LastName; Vice President of Production is a JobTitle;
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Vice President of Production'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
What are the courses taught by the advisors who gave advice to student with ID 376?
courses refers to course_id; advisors refers to p_id_dummy and taughtBy.p_id; student with ID 376 refers to advisedBy.p_id = 376
SELECT T3.course_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id INNER JOIN taughtBy AS T3 ON T2.p_id = T3.p_id WHERE T1.p_id = 141
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
What is the name of the territory assigned to the sales person with business id "277"?
business id refers to BusinessEntityID
SELECT T2.Name FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.BusinessEntityID = 277
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
List all the course IDs for professional or master/graduate courses.
professional or master/graduate courses refers to courseLevel = 'Level_500'
SELECT course_id FROM course WHERE courseLevel = 'Level_500'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
List all the pay rates of all employees that were hired at 20 years of age.
pay rate refers to Rate; 20 years old at the time of being hired refers to SUBTRACT(year(HireDate)), (year(BirthDate))) = 20;
SELECT T2.Rate FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) = 20
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
Provide the ID of professors who are teaching high-level or harder undergraduate course.
ID of professors refers to taughtBy.p_id; high-level or harder undergraduate course refers to courseLevel = 'Level_400'
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
List all of the credit cards that had expired by 2007.
card that expires in 2007 refers to ExpYear = 2007;
SELECT CardNumber FROM CreditCard WHERE ExpYear < 2007
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
What is the first and last name of students with highest gpa?
first name refers of students refers to f_name; last name of students refers to l_name; highest gpa refers to MAX(gpa);
SELECT f_name, l_name FROM student WHERE gpa = ( SELECT MAX(gpa) FROM student )
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
How many products with the id "989" were sold in August 2013?
TransactionDate BETWEEN '2013-08-01' AND '2013-08-30'; sold in refers to TransactionType = 'S' which means SalesOrder;
SELECT SUM(Quantity) FROM TransactionHistory WHERE TransactionDate LIKE '2013-08%' AND TransactionType = 'S' AND ProductID = 989
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
Which level of courses is taught by professor ID 297?
professor ID 297 refers to taughtBy.p_id = 297
SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id = 297
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
List all the names of the stores assigned to the sales person with the id "277".
null
SELECT Name FROM Store WHERE SalesPersonID = 277
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
List the ID of all professors who are not faculty member along with the courses taught by him/her.
ID of all professors refers to person.p_id where professor = 1; not faculty member refers to hasPosition = 0; courses refers to taughtBy.course_id
SELECT T2.p_id, T2.course_id FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition <> 0
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
Among the employees born before 1980 , how many of them are single?
BirthDate<'1980-01-01'; single refers to MaritalStatus = 'S' or null;
SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 's' AND BirthDate < '1980-1-1'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
List the ID and years in program for students taught by advisor with ID 5.
advisor with ID 5 refers to p_id_dummy = 5
SELECT T1.p_id, T2.yearsInProgram FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T1.p_id_dummy = 5
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
What is the name of the product with the id "475"?
null
SELECT Name FROM Product WHERE ProductID = 475
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
Name the advisors for students in Year 3 of the program.
advisors refers to p_id_dummy; students in Year 3 of the program refers to yearsInProgram = 'Year_3'
SELECT T1.p_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_3'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
How many types of credit cards are there and how many are vista?
type of credit card refers to CardType; CardType = 'Vista';
SELECT COUNT(CardNumber) FROM CreditCard WHERE CardType = 'vista'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
What level is course 165? List the professors who teach the course.
course 165 refers to course_id = 165; professors refers to taughtBy.p_id
SELECT T1.courseLevel, T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.course_id = 165
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
How much is the total bonus received by sales person and what is the percentage of it against the projected yearly sales quota in 2013?
projected yearly sales quota refers to SalesQuota; projected yearly sales quota in 2013 refers to year(QuotaDate) = 2013; percentage = (MULTIPLY(DIVIDE(SUM(Bonus)), (SUM(SalesQuota))) as percentage;
SELECT SUM(T1.Bonus) , CAST(SUM(T1.Bonus) AS REAL) * 100 / SUM(T1.SalesQuota) FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.QuotaDate) = '2013'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
Find the ID of advisor of student ID 80 and state the level of courses taught by him/her.
ID of advisor refers to p_id_dummy; student ID 80 refers to advisedBy.p_id = 80; level of courses refers to courseLevel
SELECT T1.p_id_dummy, T2.courseLevel FROM advisedBy AS T1 INNER JOIN course AS T2 ON T1.p_id = T2.course_id INNER JOIN taughtBy AS T3 ON T2.course_id = T3.course_id WHERE T1.p_id = 80
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
How many times is married non sales employees against single non-sales employees?
non-sales employee refers to PersonType = 'EM'; married refers to MaritalStatus = 'M'; single refers to MaritalStatus = 'S'; percentage = DIVIDE(SUM(MaritalStatus = 'M'), (SUM(MaritalStatus = 'S') as percentage;
SELECT CAST(SUM(CASE WHEN T1.MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.MaritalStatus = 'S' THEN 1 ELSE 0 END) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'EM'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
cs_semester
Please give the name of the course in which most numbers of the students got an A. Also, list the full name of the students who got an A in this course.
most number of students got an A refers MAX(COUNT(student_id WHERE grade = 'A')); full name = f_name, l_name; got an A refers to grade = 'A';
SELECT T3.name, T2.f_name, T2.l_name FROM registration AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T1.course_id = T3.course_id WHERE T1.grade = 'A' GROUP BY T3.name ORDER BY COUNT(T1.student_id) DESC LIMIT 1
CREATE TABLE prof ( teachingability INTEGER, -- Example Values: `5`, `1`, `2`, `3`, `4` | Value Statics: Total count 10 - Distinct count 5 - Null count 0 gender TEXT, -- Example Values: `Male`, `Female` | Value Statics: Total count 10 - Distinct count 2 - Null count 0 email TEXT, -- Example Values: `npigford0@...
works_cycles
Among the employees who wish to receive e-mail promotion from AdventureWorks, how many percent of them are female?
female refers to Gender = 'F'; employee who wish to receive email promotion refers to EmailPromotion = 1; percentage = DIVIDE(SUM(Gender = 'F')), (sum(Gender = 'F' or Gender = 'M'))) as percentage;
SELECT CAST(SUM(CASE WHEN T1.Gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Provide the business entity ID who did not achieved projected yearly sales quota in 2013.
projected yearly sales quota refers to SalesQuota; sales quota in 2013 refers to year(QuotaDate) = 2013; person who did not achieve projected yearly sales quota refers to SalesQuota>SalesYTD;
SELECT DISTINCT T1.BusinessEntityID FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.QuotaDate) = '2013' AND T1.SalesQuota < T1.SalesLastYear
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
computer_student
Which are the courses with the most number of professors? State the course ID and the level of the course.
courses refers taughtBy.course_id; most number of professors  refers to max(count(taughtBy.p_id)); level of the course refers to courseLevel
SELECT T1.course_id, T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_id, T1.courseLevel ORDER BY COUNT(T1.course_id) DESC LIMIT 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
works_cycles
What is the projected sales quota amount in 2013 and sales YTD amount for sales person with business entity ID 275?
projected sales quota refers to SalesQuota; projected sales quota in 2013 refers to year(QuotaDate) = 2013; projected sales quota for 2013 = SUM(SalesQuota where year(QuotaDate) = 2013);
SELECT SUM(T1.SalesQuota) FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.BusinessEntityID = 275 AND STRFTIME('%Y', QuotaDate) = '2013'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...