db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
synthea
From 7/9/2010 to 10/29/2013, how many black patients were immunized with the meningococcal MCV4P vaccine?
From 7/9/2010 to 10/29/2013 refers to DATE between '2010-07-09' and '2013-10-29'; black patients refers to race = 'black'; immunized with the meningococcal MCV4P vaccine refers to immunizations.DESCRIPTION = 'meningococcal MCV4P';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'meningococcal MCV4P' AND T2.DATE BETWEEN '2010-07-09' AND '2013-10-29' AND T1.race = 'black'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
social_media
What gender of users retweet more than 30 times?
retweet more than 30 times refers to RetweetCount > 30
SELECT DISTINCT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.RetweetCount > 30
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, -- ...
bike_share_1
Find the average ride duration during the rain of more than 0.8 inches.
rain of more than 0.8 inches refers to events = rain where precipitation_inches>0.8; average ride duration = DIVIDE(SUM(duration), COUNT(duration));
SELECT AVG(T1.duration) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE (T2.events = 'Rain' AND T2.precipitation_inches > 0.8) OR (T2.events = 'rain' AND T2.precipitation_inches > 0.8)
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Among the coaches who have gotten in the Hall of Fame, how many of them have a weight of over 195?
weight of over 195 refers to weight>195
SELECT COUNT(DISTINCT T1.coachID) FROM Master AS T1 INNER JOIN HOF AS T2 ON T1.hofID = T2.hofID WHERE T1.weight > 195
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
How many times was Elly Koss given a care plan between 1/11/2009 and 10/23/2010?
between 1/11/2009 and 10/23/2010 refers to careplans.START between '2009-11-1' and '2010-10-23';
SELECT COUNT(T2.PATIENT) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.START BETWEEN '2009-01-11' AND '2010-10-23'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
What is the name of the course with the highest satisfaction from students?
sat refers to student's satisfaction degree with the course where sat = 5 stands for the highest satisfaction;
SELECT DISTINCT T2.name FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T1.sat = 5
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@...
bike_share_1
Among the rides during the rainy days, which ride was the longest? List the start station, end station, and duration of this ride.
rainy days refers to events = 'rain'; longest ride refers to MAX(duration); start station refers to start_station_name; end station refers to end_station_name; duration of the ride refers to duration;
SELECT T1.start_station_name, T1.end_station_name, T1.duration FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T2.events = 'Rain' OR T2.events = 'rain' ORDER BY T1.duration DESC LIMIT 1
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Please list the awards won by coaches who taught the NHL League and have already died.
have already died refers to deathYear IS NOT NULL; NHL league refers to lgID = 'NHL'
SELECT DISTINCT T2.award FROM Master AS T1 INNER JOIN AwardsCoaches AS T2 ON T1.coachID = T2.coachID WHERE T1.deathYear IS NOT NULL AND T2.lgID = 'NHL'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
How many white patients have the reason code of 10509002?
white refers to race = 'white'; reason code of 10509002 refers to careplans.REASONCODE = '10509002';
SELECT COUNT(DISTINCT T1.PATIENT) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.race = 'white' AND T1.REASONCODE = '10509002'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
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 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@...
bike_share_1
For the rides that started at Market at 10th station and ended at South Van Ness at Market station in August of 2013, which day had the coldest temperature?
started at refers to start_station_name; start_station_name = 'Market at 10th'; ended at refers to end_station_name; end_station_name = 'South Van Ness at Market'; in August of 2013 refers to start_date BETWEEN '8/1/2013 0:00' AND '8/31/2013 12:59'; day that had the coldest temperature refers to MIN(min_temperature_f);
SELECT T1.start_date FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code AND T2.date = SUBSTR(CAST(T1.start_date AS TEXT), 1, INSTR(T1.start_date, ' ') - 1) WHERE T2.date LIKE '8/%/2013' AND T1.start_station_name = 'Market at 10th' AND T1.end_station_name = 'South Van Ness at Market' AND T2.min_temper...
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Among the coaches who have received an award after the year 1940, how many of them have already died?
after the year 1940 refers to year>1940; have already died refers to deathYear IS NOT NULL
SELECT COUNT(T1.coachID) FROM Master AS T1 INNER JOIN AwardsCoaches AS T2 ON T1.coachID = T2.coachID WHERE T1.deathYear IS NOT NULL AND T2.year > 1940
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
State the description of the reason why Angelo Buckridge needs the care plan.
description of the reason of the care plan refers to careplans.REASONDESCRIPTION;
SELECT DISTINCT T1.REASONDESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Angelo' AND T2.last = 'Buckridge'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
bike_share_1
Find the longest ride on foggy day. What were the mean visibility, mean wind speed, and weather event during that ride? Also, list the coordinates and names of the start and end stations.
foggy day refers to events = 'fog'; longest ride on a foggy day refers to MAX(duration) where events = 'fog'; mean visibility refers to mean_visibility_miles; mean wind speed refers to mean_wind_speed_mph; weather event refers to events; coordinates refers to (lat, long); start station refers to start_station_id; end s...
SELECT T3.mean_visibility_miles, T3.mean_wind_speed_mph, T3.events, T1.lat, T1.long , T2.start_station_name, T2.end_station_name FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name INNER JOIN weather AS T3 ON T3.zip_code = T2.zip_code WHERE T3.events = 'Fog' ORDER BY T2.duration DESC LIMIT 1
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Among the coaches who have received an award in 1940, how many of them are born in Toronto?
born in Toronto refers to birthCountry = 'Toronto'
SELECT COUNT(T1.coachID) FROM Master AS T1 INNER JOIN AwardsCoaches AS T2 ON T1.coachID = T2.coachID WHERE T2.year = 1940 AND T1.birthCity = 'Toronto'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cs_semester
What is the popularity of the professor who advises the highest number of students with the highest research ability?
professor with the highest research ability refers to prof_id where MAX(capability);
SELECT T2.popularity FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id GROUP BY T1.prof_id, T1.capability ORDER BY COUNT(T1.student_id) DESC, T1.capability 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@...
bike_share_1
List the days in 2013 when rain and fog occurred together and find the id of bikes borrowed on these days.
in 2013 refers to year(date) = 2013; rain and fog ocurred together refers to events = 'Fog-Rain'; id of bikes refers to biked_id;
SELECT T2.date, T1.bike_id FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE SUBSTR(CAST(T2.date AS TEXT), -4) = '2013' AND T2.events = 'Fog-Rain'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Please list the awards won by coaches who were born in 1952.
born in 1977 refers to birthYear = '1977'
SELECT T2.award FROM Master AS T1 INNER JOIN AwardsCoaches AS T2 ON T1.coachID = T2.coachID WHERE T1.birthYear = 1952
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cs_semester
How many students does Ogdon Zywicki advise?
Ogdon Zywicki is a professor;
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T2.first_name = 'Ogdon' AND T2.last_name = 'Zywicki'
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@...
bike_share_1
Calculate the difference between the number of customers and the number of subscribers who did the trip in June 2013.
customer refers to subscription_type = 'Customer'; subscribers refers to subscription_type = 'Subscriber'; difference = SUBTRACT(SUM(subscription_type = 'Subscriber' t), SUM(subscription_type = 'Customer')); trip in June 2013 refers to start_date BETWEEN '6/1/2013 0:00'AND '6/31/2013 12:59';
SELECT SUM(IIF(subscription_type = 'Subscriber', 1, 0)) - SUM(IIF(subscription_type = 'Customer', 1, 0)) FROM trip WHERE start_date LIKE '6/%/2013%'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Among the coaches who have taught teams from the NHL League, how many of them are from Canada?
from Canada refers to birthCountry = 'Canada'; NHL league refers to lgID = 'NHL'
SELECT COUNT(T2.coachID) FROM Master AS T1 INNER JOIN Coaches AS T2 ON T1.coachID = T2.coachID WHERE T2.lgID = 'NHL' AND T1.birthCountry = 'Canada'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
List out the stop date of the care plan of dead patients.
stop date of the care plan refers to careplans.STOP; dead patients refers to deathdate is not null;
SELECT DISTINCT T1.STOP FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NOT NULL AND T1.STOP IS NOT NULL
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
Which of the two courses, "Advanced Operating System" or "Intro to BlockChain', did most of the students receive an A in?
A refers to an excellent grade in which grade = 'A';
SELECT T2.name FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T1.grade = 'A' AND T2.name IN ('Advanced Operating System', 'Intro to BlockChain') GROUP BY T2.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@...
bike_share_1
What are the average maximum and minimum temperatures in May 2015 when the mean humidity is between 65 and 75?
average maximum temperature = DIVIDE(SUM(max_temperature_f), COUNT(date)); average minimum temperature = DIVIDE(SUM(min_temperature_f), COUNT(date)); May 2015 refers to date BETWEEN '5/1/2015'AND '5/31/2015';
SELECT AVG(max_temperature_f), AVG(min_temperature_f) FROM weather WHERE date LIKE '5/%/2015' AND mean_humidity BETWEEN 65 AND 75
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
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 Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cs_semester
How many students taking a bachelor's degree received an A in all of the courses that they took?
bachelor's degree is an undergraduate degree in which type = 'UG'; A refers to an excellent grade in which grade = 'A';
SELECT COUNT(T2.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id WHERE T2.grade = 'A' AND T1.type = 'UG'
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@...
bike_share_1
Find the average ride time of the bikes that started at Steuart at Market station and ended at Embarcadero at Sansome station in July 2014.
started at refers to start_station_name; start_station_name = 'Steuart at Market'; ended at refers to end_station_name; end_station_name = 'Embarcadero at Sansome'; rides in July 2004 refers to start_date = '7/1/2014 0:00'AND end_date = '7/31/2014 12:59';average ride time = DIVIDE(SUM(duration), COUNT(id))
SELECT AVG(duration) FROM trip WHERE start_date = '7/1/2014%' AND end_date = '7/31/2014%' AND start_station_name = 'Steuart at Market' AND end_station_name = 'Embarcadero at Sansome'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Please list the awards the coaches who are born in Canada have won.
born in Canada refers to birthCountry = 'Canada'
SELECT DISTINCT T2.award FROM Master AS T1 INNER JOIN AwardsCoaches AS T2 ON T1.coachID = T2.coachID WHERE T1.birthCountry = 'Canada'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
olympics
What is the percentage of champions at the age of over 30?
DIVIDE(COUNT(competitor_id where age > 30), COUNT(competitor_id))as percentage where medal_id = 1;
SELECT CAST(COUNT(CASE WHEN T2.age > 30 THEN 1 END) AS REAL) * 100 / COUNT(T2.person_id) FROM competitor_event AS T1 INNER JOIN games_competitor AS T2 ON T1.competitor_id = T2.id WHERE T1.medal_id = 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
synthea
List out the start date of the care plan of alive patients.
start of the care plan refers to careplans.START; alive patients refers to deathdate is null;
SELECT DISTINCT T1.START FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NULL
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
What are the names of the courses that the students with the lowest intelligence are least satisfied with?
lower intelligence refers to intelligence = 1; sat refers to student's satisfaction degree with the course where least satisfaction refers to 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.intelligence = 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@...
bike_share_1
In 2014, what is the shortest duration of trips by subscribers which started at 2nd at Folsom and ended in the 5th at Howard stations, and by how much shorter than the average? Give me the minimum temperature, maximum gust speed and weather event on that trip.
the shortest duration refers to MIN(duration); subscription_type = 'Subscriber', start_station_name = '2nd at Folsom', end_station_name = '5th at Howard'; in 2014 refers to time period between start_date = '1/1/2014 0:00' and end_date = '12/31/2014 11:59; Average duration = DIVIDE(SUM(duration), COUNT(id));
SELECT MIN(T1.duration) , MIN(T1.duration) - AVG(T1.duration), T2.min_temperature_f FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T1.start_date = '1/1/2014 0:00' AND T1.end_date = '12/31/2014 11:59' AND T1.start_station_name = '2nd at Folsom' AND T1.end_station_name = '5th at Howard' AND T...
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Did the tallest player got in the Hall of Fame? If yes, please list the year when he got in the Hall of Fame.
tallest player refers to max(height)
SELECT CASE WHEN T1.hofID IS NULL THEN 'NO' ELSE T2.year END FROM Master AS T1 LEFT JOIN HOF AS T2 ON T1.hofID = T2.hofID WHERE T1.height = ( SELECT MAX(height) FROM Master )
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
How many black patients stopped their care plan in 2017?
black refers to race = 'black'; stopped their care plan in 2017 refers to substr(careplans.STOP, 1, 4) = '2017';
SELECT COUNT(DISTINCT T2.patient) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.race = 'black' AND strftime('%Y', T1.STOP) = '2017'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
How many students, who have a GPA between 3 to 4, failed a course?
GPA is an abbreviated name of Grade Point Average where GPA between 3 to 4 refers to gpa BETWEEN 3 AND 4; If grade is null or empty, it means that this student fails to pass this course;
SELECT COUNT(T2.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id WHERE T2.grade IS NULL AND T1.gpa BETWEEN 3 AND 4
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@...
bike_share_1
Please write down the trip IDs which ended on the days when the minimum temperature is less than 45 degrees Fahrenheit.
the minimum temperature is less than 45 degrees Fahrenheit refers to min_temperature_f<45;
SELECT T1.id FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T2.min_temperature_f < 45
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Please list the Nicknames of the players who got in the Hall of Fame in 2007.
nicknames refers to nameNick
SELECT DISTINCT T1.nameNick FROM Master AS T1 INNER JOIN HOF AS T2 ON T1.hofID = T2.hofID WHERE T2.year = 2007
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
List out full name of patients who have "Diabetic diet" in the description of the care plan.
full name = first, last; Diabetic diet refers to careplans.DESCRIPTION = 'Diabetic diet';
SELECT DISTINCT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Diabetic diet'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
social_media
Calculate the average number of male users who posted tweets in a week.
male user refers to Gender = 'Male'; average tweet in a week per user refers to Divide ( Divide(Count(TweetID), Count (UserID)), Divide(31, 7))
SELECT COUNT(DISTINCT T1.TweetID) / COUNT(DISTINCT T1.UserID) / 7 AS avg FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Male' AND T1.Day BETWEEN 1 AND 31
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, -- ...
bike_share_1
How many docks were available at the starting station of trip ID 912900?
null
SELECT SUM(T2.docks_available) FROM trip AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.start_station_id WHERE T1.zip_code = 912900
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Among the people who got into the Hall of Fame after the year 1980, how many of them belong to the category of "Player"?
after the year 1980 refers to year>1980
SELECT COUNT(hofID) FROM HOF WHERE year > 1980 AND category = 'Player'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
What is the percentage of female patients who started the care plan in 2010?
female patients refers to gender = 'F'; started the care plan in 2010 refers to substr(careplans.START, 1, 4) = '2010'; percentage = MULTIPLY(DIVIDE(COUNT(patients.patient WHERE patients.gender = 'F'), COUNT(patients.patient) WHERE substr(careplans.START, 1, 4) = '2010'), 100);
SELECT CAST(SUM(CASE WHEN T2.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.PATIENT) AS percentage FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE strftime('%Y', T1.START) = '2010'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
List the professors' IDs and students' IDs with the lowest research ability.
the lowest research ability refers to MIN(capability); professor’s ID refers to prof_id;
SELECT prof_id, student_id FROM RA WHERE capability = ( SELECT MIN(capability) FROM RA )
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@...
bike_share_1
Among the subscriber, how many of them finished the 2nd at Folsom and Civic Center BART (7th at Market) as their start and end stations respectively for no more than 490 seconds under minimum visibility of 4 miles.
subscription_type = 'Subscriber'; no more than 490 seconds refers to duration<490; start_station_name = '2nd at Folsom'; end_station_name = 'Civic Center BART (7th at Market)'; min_visibility_miles = 4;
SELECT COUNT(T1.id) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T1.subscription_type = 'Subscriber' AND T2.min_visibility_miles = 4 AND T1.duration < 490 AND T1.start_station_name = '2nd at Folsom' AND T1.end_station_name = 'Civic Center BART (7th at Market)'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
How many people were in the Hall of Fame's Builder category?
null
SELECT COUNT(hofID) FROM HOF WHERE category = 'Builder'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cs_semester
What is the average number of students who registered for the courses with a difficulty of 4?
diff refers to difficulty; DIVIDE(COUNT(student_id where diff = 4), COUNT(course_id where diff = 4));
SELECT CAST(COUNT(T1.student_id) AS REAL) / COUNT(DISTINCT T2.course_id) FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.diff = 4
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@...
bike_share_1
What were the max gust speed and cloud clover when the customer using bike no. 10 recorded the 386 seconds duration of the trip from MLK Library to San Salvador at 1st?
subscription_type = 'Customer'; duration = '364'; bike no. 10 refers to bike_id = 10; start_station_name = 'San Jose Civic Center'; end_station_name = 'San Jose City Hall';
SELECT T2.max_gust_speed_mph, T2.cloud_cover FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code AND T2.date = SUBSTR(CAST(T1.start_date AS TEXT), 1, INSTR(T1.start_date, ' ') - 1) WHERE T1.bike_id = 10 AND T2.mean_temperature_f > 62 AND T1.subscription_type = 'Customer' AND T1.start_station_name = 'M...
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Please list the name of the person who was in the Hall of Fame in the year 1978.
null
SELECT name FROM HOF WHERE year = 1978
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
In 2010, how many single patients took Nitrofurantoin 5 mg/ML [Furadantin] to cure cystitis?
in 2010 refers to substr(medications.START, 1, 4) = '2010' AND substr(medications.stop, 1, 4) = '2010'; Nitrofurantoin 5 mg/ML [Furadantin] refers to medications.DESCRIPTION = 'Nitrofurantoin 5 MG/ML [Furadantin]'; cystitis refers to medications.REASONDESCRIPTION = 'Cystitis';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.marital = 'S' AND T2.REASONDESCRIPTION = 'Cystitis' AND T2.DESCRIPTION = 'Nitrofurantoin 5 MG/ML [Furadantin]' AND strftime('%Y', T2.START) = '2010'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
bike_share_1
List down the trip IDs when bike no. 10 was used by subscribers and the weather's mean temperature is no less than 62 degress Fahrenheit.
bike no. 10 refers to bike_id = '10'; subscription_type = 'Subscriber'; the weather's mean temperature is no less than 62 degress Fahrenheit refers to mean_temperature_f>62;
SELECT T1.id FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T1.bike_id = 10 AND T2.mean_temperature_f > 62 AND T1.subscription_type = 'Subscriber'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
How many teams have the same total number of postseason wins and postseason loses?
same total number of postseason wins and postseason loses refers to PostW = PostL
SELECT DISTINCT COUNT(tmID) FROM Goalies WHERE PostW = PostL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
List the full names of patients with nut allergy.
full names = first, last; nut allergy refers to allergies.DESCRIPTION = 'Allergy to nut';
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to nut'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
List the courses' IDs and students' IDs who failed to pass the course.
If grade is null or empty, it means that this student fails to pass the course;
SELECT course_id, student_id FROM registration WHERE grade IS NULL OR grade = ''
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@...
bike_share_1
On 8/29/2013 at 6:14:01 PM, how many bikes were borrowed from San Jose Diridon Caltrain Station?
How many bikes borrowed can be computed as SUBTRACT(SUM(dock_count), bikes_available where name = 'San Jose Diridon Caltrain Station' and time = '2013/08/29 06:14:01');
SELECT SUM(T1.dock_count - T2.bikes_available) FROM station AS T1 INNER JOIN status AS T2 ON T1.id = T2.station_id WHERE T1.name = 'San Jose Diridon Caltrain Station' AND T2.time = '2013/08/29 06:14:01'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Please list the years in which the NHL League had shots recorded while the goalie was on the ice.
shots recorded while the goalie was on the ice refers to SA IS NOT NULL; NHL League refers to lgID = 'NHL'
SELECT DISTINCT year FROM Goalies WHERE lgID = 'NHL' AND SA IS NOT NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
How many Italian patients have the care plan code of 304510005?
Italian patients refers to ethnicity = 'italian';
SELECT COUNT(DISTINCT T2.patient) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ethnicity = 'italian' AND T1.CODE = '304510005'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
What is the average GPA of the students with the highest research capability and high salary? List the full names of the students.
the highest research capability refers to capability = 5; high salary refers to salary = 'high'; prof_id refers to professor’s ID; GPA is an abbreviated name of Grade Point Average where average GPA refers to AVG(gpa);
SELECT AVG(T2.gpa), T2.f_name, T2.l_name FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'high' AND T1.capability = 5 GROUP BY T2.student_id
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@...
bike_share_1
List down the trips in which their start and end station are similar. Give me their trip IDs and location coordinates.
start and end station are similar refers to start_station_name = end_station_name; latitude and longitude coordinates can be used to indicate a location;
SELECT T1.id, T2.lat, T2.long FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.start_station_name = T1.end_station_name
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
How many teams scored against their opponent who had pulled their goalie in the year 2005?
teams scored against their opponent who had pulled their goalie refers to ENG is not null
SELECT COUNT(tmID) FROM Goalies WHERE year = 2005 AND ENG IS NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
Provide the full names of patients who have been taking Penicillin V Potassium 250 MG since 1948.
full names = first, last; Penicillin V Potassium 250 MG refers to medications.DESCRIPTION = 'Penicillin V Potassium 250 MG'; since 1948 refers to substr(medications.START, 1, 4) > = '1948';
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Penicillin V Potassium 250 MG' AND strftime('%Y', T2.START) >= '1948'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
Describe the students' full names and GPAs under the supervision of the most popular professor.
student's full names = f_name, l_name; most popular refers to MAX(popularity);
SELECT T3.f_name, T3.l_name, T3.gpa 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 ORDER BY T1.popularity 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@...
bike_share_1
Write down the times when there is no available bike to borrow in a station. List down the stations name and location coordinate.
no available bike to borrow refers to bikes_available = 0; latitude and longitude coordinates can be used to indicate a location;
SELECT T2.time, T1.name, T1.lat, T1.long FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T2.bikes_available = 0
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
How many shoutouts are there in the regular season of 1977?
regular season refers to `R/P` = 'R'
SELECT COUNT(year) FROM CombinedShutouts WHERE year = 1977 AND `R/P` = 'R'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cs_semester
Name the professor who got graduation from the University of Boston.
Name the professor refers to full name which includes f_name and l_name;
SELECT first_name, last_name FROM prof WHERE graduate_from = 'University of Boston'
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@...
bike_share_1
What is the average duration of trips which are started at Adobe on Almaden station to Ryland Park?
trips refer to id; DIVIDE(SUM(duration where start_station_name = 'Adobe on Almaden', end_station_name = 'Ryland Park'), COUNT(id));
SELECT AVG(duration) FROM trip WHERE start_station_name = 'Adobe on Almaden' AND end_station_name = 'Ryland Park'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
How many coaches worked a temporary term in the year 2007?
worked a temporary term refers to notes = 'interim'
SELECT COUNT(coachID) FROM Coaches WHERE year = 2007 AND notes = 'interim'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
How many male patients have prediabetes condition?
male refers to gender = 'M'; prediabetes condition refers to conditions.DESCRIPTION = 'Prediabetes';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 WHERE T2.DESCRIPTION = 'Prediabetes' AND T1.gender = 'M'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
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 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@...
bike_share_1
List the name of stations that were installed from 8/5/2013 to 12/31/2013. Indicate their installation date and city name.
from 8/5/2013 to 12/31/2013 refers to installation_date between '8/5/2013' and '12/31/2013';
SELECT name, installation_date, city FROM station WHERE (SUBSTR(CAST(installation_date AS TEXT), 1, INSTR(installation_date, '/') - 1) = '5' AND SUBSTR(CAST(installation_date AS TEXT), INSTR(installation_date, '/') + 1, -6) >= '8' AND SUBSTR(CAST(installation_date AS TEXT), -4) = '2013') OR (SUBSTR(CAST(installation_da...
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Among the players who won an award in the year 1983, how many of them play the position of goalie?
position of goalie refers to pos = 'G'
SELECT COUNT(playerID) FROM AwardsPlayers WHERE pos = 'G' AND year = 1983
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
Among the patients with viral sinusitis condition, which patient's gender is most affected? Provide the number for each respectively.
viral sinusitis condition refers to conditions.DESCRIPTION = 'Viral sinusitis (disorder)'; gender that is most affected refers to MAX(COUNT(gender WHERE conditions.DESCRIPTION = 'Viral sinusitis (disorder)'));
SELECT SUM(CASE WHEN T1.gender = 'F' THEN 1 ELSE 0 END), SUM(CASE WHEN T1.gender = 'M' THEN 1 ELSE 0 END) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Viral sinusitis (disorder)'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
social_media
Please give the user ID of the user who has posted the most tweets.
users with the most tweet refers to UserID where Max(Count (TweetID))
SELECT UserID FROM twitter GROUP BY UserID ORDER BY COUNT(DISTINCT TweetID) 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, -- ...
bike_share_1
What is the route that has the longest duration? Indicate the city of where the stations are located.
route implies a course taken in getting from start_station_name to end_station_name; the longest duration refers to MAX(duration);
SELECT T1.start_station_name, T1.end_station_name, T2.city FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.duration = ( SELECT MAX(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name )
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
How many players and coaches are awarded after death?
awarded after death refers to note = 'posthumous'
SELECT COUNT(note) FROM AwardsMisc WHERE note IS NOT NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
In 2009, who among the married patients had undergone a care plan for more than 60 days?
in 2009 refers to year(careplans.START) = 2009; married patients refers to marital = 'M'; undergone a care plan for more than 60 days refers to SUBTRACT(careplans.STOP, careplans.START) > 60;
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.marital = 'M' AND strftime('%J', T2.STOP) - strftime('%J', T2.START) > 60
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
List the research assistants' full names, capabilities and GPAs who were under the supervision of Merwyn Conkay.
research assistant refers to the student who serves for research where the abbreviation is RA; full names = f_name, l_name;
SELECT T3.f_name, T3.l_name, T2.capability, T3.gpa 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 T1.first_name = 'Merwyn' AND T1.last_name = 'Conkay'
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@...
bike_share_1
What is the average duration of bike trips in the city of Palo Alto?
DIVIDE(SUM(duration where city = 'Palo Alto'), COUNT(start_station_id));
SELECT AVG(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Palo Alto'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
List all living goalies who have greater than 50% wins among all games played. State their last name and first name.
wins refers to W; all games played refers to GP;greater than 50% wins among all games played refers to DIVIDE(SUM(W),GP)*100>50
SELECT T1.firstName, T1.lastName FROM Master AS T1 INNER JOIN Goalies AS T2 ON T1.playerID = T2.playerID WHERE T1.deathYear IS NOT NULL GROUP BY T1.playerID HAVING CAST(SUM(T2.Min) AS REAL) / SUM(T2.GP) > 0.5
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
Which conditions the patient has when receiving the IPV immunization?
IPV immunization refers to immunizations.DESCRIPTION = 'IPV';
SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT INNER JOIN immunizations AS T3 ON T1.patient = T3.PATIENT WHERE T3.DESCRIPTION = 'IPV'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
What is the male and female ratio among the professors?
DIVIDE(COUNT(prof_id where gender = 'Male'), COUNT(prof_id where gender = 'Female'));
SELECT CAST(SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) FROM prof
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@...
bike_share_1
On 11/3/2013, which stations are often empty? Indicate the names of the stations.
time = '11/3/2013'; which stations are empty refers to bikes_available = '0';
SELECT DISTINCT T1.name FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T2.bikes_available = 0 AND T2.time LIKE '2013/11/03%'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
What is given name for player 'aebisda01'. Calculate the average time in minutes for the all his games played as goaltender.
played as goaltender refers to pos = 'G'; time in minutes refers to Min; all his games played refers to GP; average time in minutes refers to DIVIDE(SUM(Min)/SUM(GP))
SELECT T1.nameGiven, CAST(SUM(T2.Min) AS REAL) / SUM(T2.GP) FROM Master AS T1 INNER JOIN Goalies AS T2 ON T1.playerID = T2.playerID WHERE T1.playerID = 'aebisda01' GROUP BY T1.nameGiven
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cs_semester
Describe the full names and graduated universities of the professors who advised Olia Rabier.
full names of the professors = first_name, last_name; graduated universities of the professors refers to graduate_from;
SELECT T1.first_name, T1.last_name, 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.f_name = 'Olia' AND T3.l_name = 'Rabier'
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@...
bike_share_1
What is the name of the station that is less used by customers who borrow bikes from? Indicate when was the station installed.
less used station where bikes are borrowed from refers to start_station_name which has the least number of customers; subscription_type = 'Customer'; when installed refers to installation_date;
SELECT T1.start_station_name, T2.installation_date FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.subscription_type = 'Customer' GROUP BY T1.start_station_name ORDER BY COUNT(T1.subscription_type) LIMIT 1
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
List all goalies with more lost than won games for two seasons or more. State the name of the player and team he played.
lost refers to L; won refers to W
SELECT DISTINCT T1.firstName, T1.lastName, T3.name FROM Master AS T1 INNER JOIN Goalies AS T2 ON T1.playerID = T2.playerID INNER JOIN Teams AS T3 ON T2.year = T3.year AND T2.tmID = T3.tmID WHERE T1.pos = 'G' AND T2.L > T2.W GROUP BY T1.firstName, T1.lastName, T3.name HAVING COUNT(T3.year) > 2
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
Describe the condition of patient Wilmer Koepp.
null
SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Wilmer' AND T1.last = 'Koepp'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
Provide the full names and emails of unpaid research assistants.
full names = f_name, l_name; research assistant refers to the student who serves for research where the abbreviation is RA; unpaid research assistant refers to salary = 'free';
SELECT T2.f_name, T2.l_name, T2.email FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'free'
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@...
bike_share_1
Which day in the month of November, 2014 have a foggy weather in the zip code 94301 and in total, how many bikes were borrowed by subscribers from all of the stations in the said day?
day in the month of November, 2014 refers to start_date between '11/1/2014' and '11/30/2014'; foggy weather refers to events = 'Fog'; subscriber refers to subscription_type; all of the stations bikes were borrowed from refer to start_station_name;
SELECT T2.date, COUNT(T1.start_station_name) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T2.date LIKE '11/%/2014%' AND T2.zip_code = 94301 AND T2.events = 'Fog' AND T1.subscription_type = 'Subscriber'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Who is the coach who had coached the the most seasons in MTL? State his given name, date of birth and all teams he had coaches before.
date of birth refers to birthDay + birthMon + birthYear
SELECT T2.nameGiven , T2.birthYear, T2.birthMon, T2.birthDay, T3.name FROM Goalies AS T1 INNER JOIN Master AS T2 ON T2.playerID = T1.playerID INNER JOIN Teams AS T3 ON T3.lgID = T1.lgID WHERE T3.tmID = 'MTL' GROUP BY T2.nameGiven, T2.birthYear, T2.birthMon, T2.birthDay, T3.name ORDER BY COUNT(T2.coachID) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cs_semester
Among students registered for the most difficult course, list the students' full names who got grade A.
difficulty refers to diff; most difficult course refers to MAX(diff); student's full names = f_name, l_name;
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 T2.grade = 'A' ORDER BY T3.diff 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@...
bike_share_1
What is the maximum humidity in Powell Street BART when bike 496 was borrowed from the station on 8/29/2013?
Powell Street refers to start_station_name; bike 496 refers to bike_id = '496'; start_date = '8/29/2013';
SELECT T2.max_humidity FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T1.start_date LIKE '8/29/2013%' AND T1.bike_id = 496 AND T1.start_station_name = 'Powell Street BART'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Which coach has the best performance for team DET in history? What was the winning percentage? Name the coach and the year he coached.
winning percentage refers to DIVIDE(w,g)*100; team DET refers to tmID = 'DET'
SELECT CAST(T2.W AS REAL) / T2.G, T1.firstName, T1.lastName, T2.year FROM Master AS T1 INNER JOIN Coaches AS T2 ON T1.coachID = T2.coachID INNER JOIN ( SELECT coachID FROM Coaches ORDER BY CAST(w AS REAL) / g DESC LIMIT 1 ) AS T3 ON T2.coachID = T3.coachID
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
How many male patients have been described as immune to quadrivalent HPV?
male refers to gender = 'M'; immune to quadrivalent HPV refers to immunizations.DESCRIPTION = 'HPV quadrivalent';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'HPV quadrivalent' AND T1.gender = 'M'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
Calculate the GPA of the semester for Laughton Antonio.
GPA of the semester = DIVIDE(SUM(MULTIPLY(credit, grade)), SUM(credit)); grade 'A' refers to gpa = 4; grade 'B' refers to gpa = 3; grade 'C' refers to gpa = 2; grade 'D' refers to gpa = 1;
SELECT CAST(SUM(T3.credit * CASE T1.grade WHEN 'A' THEN 4 WHEN 'B' THEN 3 WHEN 'C' THEN 2 WHEN 'D' THEN 1 ELSE 1 END) AS REAL) / COUNT(T3.credit) 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 T2.f_name = 'Laughton' AND T2.l...
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@...
bike_share_1
Among the subscribers who rented a bike from South Van Ness at Market on 12/1/2013, whose duration was the shortest and to which station was the bike returned to? Indicate South Van Ness's dock count.
South Van Ness at Market refers to start_station_name; subscriber refers to subscription_type; start_date = '12/1/2013'; the shortest duration refers to MIN(duration); which station was the bike returned to refers to end_station_name;
SELECT MIN(T2.duration), T2.end_station_name, COUNT(T2.start_station_name) FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T2.start_date LIKE '12/1/2013%' AND T2.start_station_name = 'South Van Ness at Market' AND T2.subscription_type = 'Subscriber'
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
Among the coaches who was never a player, who has highest percentage of game winning? Provide the given name of the coach and team he coached.
highest percentage of game winning refers to MAX(DIVIDE(w,g)*100)
SELECT T2.nameGiven, T3.name FROM Coaches AS T1 INNER JOIN Master AS T2 ON T2.coachID = T1.coachID INNER JOIN Teams AS T3 ON T1.lgID = T3.lgID WHERE T1.coachID IS NOT NULL ORDER BY CAST(T1.w AS REAL) / T1.g DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
synthea
How many white patients whose birth year is 1935 have a stroke?
white refers to race = 'white'; birth year is 1935 refers to substr(birthdate, 1, 4) = '1935'; stroke refers to conditions.DESCRIPTION = 'Stroke';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.patient WHERE strftime('%Y', T1.birthdate) = '1935' AND T1.race = 'white' AND T2.DESCRIPTION = 'Stroke'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
cs_semester
Describe the students' full names and grades in Intro to BlockChain course.
student's full names = f_name, l_name;
SELECT T1.f_name, T1.l_name, T2.grade 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 = 'Intro to BlockChain'
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@...
bike_share_1
On 10/20/2014, what is the duration of the fastest trip which started from the station with latitude and longitudes of 37.789625 and -122.400811, respectively? Indicate the bike id.
lat = '37.789625' and long = '-122.400811' are latitude and longitude coordinates indicating location; started from the station refers to start_station_name; start_date = '10/20/2014'; duration of the fastest trip refers to MIN(duration);
SELECT MIN(T2.duration), T2.bike_id FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T2.start_date LIKE '10/20/2014%' AND T1.lat = 37.789625 AND T1.long = -122.400811
CREATE TABLE weather ( zip_code TEXT, -- Example Values: `94107`, `94063`, `94301`, `94041`, `95113` | Value Statics: Total count 3665 - Distinct count 5 - Null count 0 max_visibility_miles INTEGER, -- Example Values: `10`, `9`, `8`, `20`, `15` | Value Statics: Total count 3652 - Distinct count 11 - Null count 13 ...
hockey
For all players who becomes coach after retirement, state the given name of coach and which teams and years did they coach?
null
SELECT DISTINCT T2.nameGiven, T3.name, T3.year FROM Coaches AS T1 INNER JOIN Master AS T2 ON T2.coachID = T1.coachID INNER JOIN Teams AS T3 ON T1.lgID = T3.lgID WHERE T2.playerID IS NOT NULL AND T2.coachID IS NOT NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...