db_id
stringlengths
4
28
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
schema
stringlengths
352
37.3k
legislator
Please list the current official YouTube usernames of all the current female legislators.
official YouTube usernames refers to youtube; female refers to gender_bio = 'F'
SELECT T2.youtube FROM current AS T1 INNER JOIN `social-media` AS T2 ON T2.bioguide = T1.bioguide_id WHERE T1.gender_bio = 'F'
CREATE TABLE current ( ballotpedia_id TEXT, bioguide_id TEXT, birthday_bio DATE, cspan_id REAL, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id REAL, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id INTEGER, votesmart_id REAL, wikidata_id TEXT, wikipedia_id TEXT, primary key (bioguide_id, cspan_id) ); CREATE TABLE IF NOT EXISTS "current-terms" ( address TEXT, bioguide TEXT, caucus TEXT, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, primary key (bioguide, end), foreign key (bioguide) references current(bioguide_id) ); CREATE TABLE historical ( ballotpedia_id TEXT, bioguide_id TEXT primary key, bioguide_previous_id TEXT, birthday_bio TEXT, cspan_id TEXT, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_alternate_id TEXT, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id TEXT, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id TEXT, votesmart_id TEXT, wikidata_id TEXT, wikipedia_id TEXT ); CREATE TABLE IF NOT EXISTS "historical-terms" ( address TEXT, bioguide TEXT primary key, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, middle TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, foreign key (bioguide) references historical(bioguide_id) ); CREATE TABLE IF NOT EXISTS "social-media" ( bioguide TEXT primary key, facebook TEXT, facebook_id REAL, govtrack REAL, instagram TEXT, instagram_id REAL, thomas INTEGER, twitter TEXT, twitter_id REAL, youtube TEXT, youtube_id TEXT, foreign key (bioguide) references current(bioguide_id) );
video_games
What is the genre ID of the '2Xtreme' game?
the '2Xtreme' game refers to game_name = '2Xtreme'
SELECT T.genre_id FROM game AS T WHERE T.game_name = '2Xtreme'
CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE game ( id INTEGER not null primary key, genre_id INTEGER default NULL, game_name TEXT default NULL, foreign key (genre_id) references genre(id) ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL ); CREATE TABLE game_publisher ( id INTEGER not null primary key, game_id INTEGER default NULL, publisher_id INTEGER default NULL, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id) ); CREATE TABLE game_platform ( id INTEGER not null primary key, game_publisher_id INTEGER default NULL, platform_id INTEGER default NULL, release_year INTEGER default NULL, foreign key (game_publisher_id) references game_publisher(id), foreign key (platform_id) references platform(id) ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL ); CREATE TABLE region_sales ( region_id INTEGER default NULL, game_platform_id INTEGER default NULL, num_sales REAL default NULL, foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id) );
ice_hockey_draft
How many games did Per Mars play in the 1997-1998 season?
1997-1998 season refers to SEASON = '1997-1998';
SELECT T2.GP FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID WHERE T2.SEASON = '1997-1998' AND T1.PlayerName = 'Pavel Patera'
CREATE TABLE height_info ( height_id INTEGER primary key, height_in_cm INTEGER, height_in_inch TEXT ); CREATE TABLE weight_info ( weight_id INTEGER primary key, weight_in_kg INTEGER, weight_in_lbs INTEGER ); CREATE TABLE PlayerInfo ( ELITEID INTEGER primary key, PlayerName TEXT, birthdate TEXT, birthyear DATE, birthmonth INTEGER, birthday INTEGER, birthplace TEXT, nation TEXT, height INTEGER, weight INTEGER, position_info TEXT, shoots TEXT, draftyear INTEGER, draftround INTEGER, overall INTEGER, overallby TEXT, CSS_rank INTEGER, sum_7yr_GP INTEGER, sum_7yr_TOI INTEGER, GP_greater_than_0 TEXT, foreign key (height) references height_info(height_id), foreign key (weight) references weight_info(weight_id) ); CREATE TABLE SeasonStatus ( ELITEID INTEGER, SEASON TEXT, TEAM TEXT, LEAGUE TEXT, GAMETYPE TEXT, GP INTEGER, G INTEGER, A INTEGER, P INTEGER, PIM INTEGER, PLUSMINUS INTEGER, foreign key (ELITEID) references PlayerInfo(ELITEID) );
law_episode
What is the title of the episode that got the most 10-star votes?
the most refers to max(votes); 10-star refers to stars = 10
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 ORDER BY T2.votes DESC LIMIT 1
CREATE TABLE Episode ( episode_id TEXT primary key, series TEXT, season INTEGER, episode INTEGER, number_in_series INTEGER, title TEXT, summary TEXT, air_date DATE, episode_image TEXT, rating REAL, votes INTEGER ); CREATE TABLE Keyword ( episode_id TEXT, keyword TEXT, primary key (episode_id, keyword), foreign key (episode_id) references Episode(episode_id) ); CREATE TABLE Person ( person_id TEXT primary key, name TEXT, birthdate DATE, birth_name TEXT, birth_place TEXT, birth_region TEXT, birth_country TEXT, height_meters REAL, nickname TEXT ); CREATE TABLE Award ( award_id INTEGER primary key, organization TEXT, year INTEGER, award_category TEXT, award TEXT, series TEXT, episode_id TEXT, person_id TEXT, role TEXT, result TEXT, foreign key (episode_id) references Episode(episode_id), foreign key (person_id) references Person(person_id) ); CREATE TABLE Credit ( episode_id TEXT, person_id TEXT, category TEXT, role TEXT, credited TEXT, primary key (episode_id, person_id), foreign key (episode_id) references Episode(episode_id), foreign key (person_id) references Person(person_id) ); CREATE TABLE Vote ( episode_id TEXT, stars INTEGER, votes INTEGER, percent REAL, foreign key (episode_id) references Episode(episode_id) );
mondial_geo
List the full name its capital of all the countries with parliamentary democracy government.
Parliamentary democracy is a government form
SELECT T1.Capital FROM country AS T1 INNER JOIN politics AS T2 ON T1.Code = T2.Country WHERE T2.Government = 'parliamentary democracy'
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
synthea
What is the average body mass index for patients with higher total cholesterol?
average body mass index = DIVIDE(SUM(observations.VALUE), COUNT(PATIENT) WHERE observations.DESCRIPTION = 'Body Mass Index'); body mass index refers to observations.DESCRIPTION = 'Body Mass Index'; higher total cholesterol refers to observations.DESCRIPTION = 'Total Cholesterol' and observations.VALUE > = 200;
SELECT SUM(T1.VALUE) / COUNT(T1.PATIENT) FROM observations AS T1 INNER JOIN ( SELECT DISTINCT PATIENT FROM observations WHERE DESCRIPTION = 'Total Cholesterol' AND VALUE > 200 ) AS T2 ON T1.PATIENT = T2.PATIENT WHERE T1.DESCRIPTION = 'Body Mass Index'
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ); CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ); CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ); CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE IF NOT EXISTS "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER );
movies_4
List the genres of Forrest Gump movie.
genres refers to genre_name; Forrest Gump movie refers to title = 'Forrest Gump'
SELECT T3.genre_name FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id WHERE T1.title = 'Forrest Gump'
CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, country_name TEXT default NULL ); CREATE TABLE department ( department_id INTEGER not null primary key, department_name TEXT default NULL ); CREATE TABLE gender ( gender_id INTEGER not null primary key, gender TEXT default NULL ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL ); CREATE TABLE language ( language_id INTEGER not null primary key, language_code TEXT default NULL, language_name TEXT default NULL ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL ); CREATE TABLE movie ( movie_id INTEGER not null primary key, title TEXT default NULL, budget INTEGER default NULL, homepage TEXT default NULL, overview TEXT default NULL, popularity REAL default NULL, release_date DATE default NULL, revenue INTEGER default NULL, runtime INTEGER default NULL, movie_status TEXT default NULL, tagline TEXT default NULL, vote_average REAL default NULL, vote_count INTEGER default NULL ); CREATE TABLE movie_genres ( movie_id INTEGER default NULL, genre_id INTEGER default NULL, foreign key (genre_id) references genre(genre_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_languages ( movie_id INTEGER default NULL, language_id INTEGER default NULL, language_role_id INTEGER default NULL, foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), foreign key (language_role_id) references language_role(role_id) ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL ); CREATE TABLE movie_crew ( movie_id INTEGER default NULL, person_id INTEGER default NULL, department_id INTEGER default NULL, job TEXT default NULL, foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE production_company ( company_id INTEGER not null primary key, company_name TEXT default NULL ); CREATE TABLE production_country ( movie_id INTEGER default NULL, country_id INTEGER default NULL, foreign key (country_id) references country(country_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_cast ( movie_id INTEGER default NULL, person_id INTEGER default NULL, character_name TEXT default NULL, gender_id INTEGER default NULL, cast_order INTEGER default NULL, foreign key (gender_id) references gender(gender_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE IF NOT EXISTS "movie_keywords" ( movie_id INTEGER default NULL references movie, keyword_id INTEGER default NULL references keyword ); CREATE TABLE IF NOT EXISTS "movie_company" ( movie_id INTEGER default NULL references movie, company_id INTEGER default NULL references production_company );
mondial_geo
What is the population of African in 'Turks and Caicos Islands'?
African is the name of enthic groups in the country; Population of (African in Turks and Calcos Island) = (percentage of African) * (population of Turks and Calcos Island)
SELECT T2.Percentage * T1.Population FROM country AS T1 INNER JOIN ethnicGroup AS T2 ON T1.Code = T2.Country WHERE T2.Name = 'African' AND T1.Name = 'Turks and Caicos Islands'
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
chicago_crime
What kind of location in Austin reported the most number of crimes?
"Austin" is the district_name; the most number of crime refers to Max(Count(case_number)); kind of location refers to location_description
SELECT T2.location_description FROM District AS T1 INNER JOIN Crime AS T2 ON T2.district_no = T1.district_no WHERE T1.district_name = 'Austin' GROUP BY T2.location_description ORDER BY COUNT(T2.case_number) DESC LIMIT 1
CREATE TABLE Community_Area ( community_area_no INTEGER primary key, community_area_name TEXT, side TEXT, population TEXT ); CREATE TABLE District ( district_no INTEGER primary key, district_name TEXT, address TEXT, zip_code INTEGER, commander TEXT, email TEXT, phone TEXT, fax TEXT, tty TEXT, twitter TEXT ); CREATE TABLE FBI_Code ( fbi_code_no TEXT primary key, title TEXT, description TEXT, crime_against TEXT ); CREATE TABLE IUCR ( iucr_no TEXT primary key, primary_description TEXT, secondary_description TEXT, index_code TEXT ); CREATE TABLE Neighborhood ( neighborhood_name TEXT primary key, community_area_no INTEGER, foreign key (community_area_no) references Community_Area(community_area_no) ); CREATE TABLE Ward ( ward_no INTEGER primary key, alderman_first_name TEXT, alderman_last_name TEXT, alderman_name_suffix TEXT, ward_office_address TEXT, ward_office_zip TEXT, ward_email TEXT, ward_office_phone TEXT, ward_office_fax TEXT, city_hall_office_room INTEGER, city_hall_office_phone TEXT, city_hall_office_fax TEXT, Population INTEGER ); CREATE TABLE Crime ( report_no INTEGER primary key, case_number TEXT, date TEXT, block TEXT, iucr_no TEXT, location_description TEXT, arrest TEXT, domestic TEXT, beat INTEGER, district_no INTEGER, ward_no INTEGER, community_area_no INTEGER, fbi_code_no TEXT, latitude TEXT, longitude TEXT, foreign key (ward_no) references Ward(ward_no), foreign key (iucr_no) references IUCR(iucr_no), foreign key (district_no) references District(district_no), foreign key (community_area_no) references Community_Area(community_area_no), foreign key (fbi_code_no) references FBI_Code(fbi_code_no) );
coinmarketcap
Name the coin that have higher than average percentage price changed from the previous 24 hours for transaction on 2013/6/22.
average percentage price changed from the previous 24 hours refers to AVG(percent_change_24h); on 15/5/2013 refers to DATE = '2013-04-15'
SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2020-06-22' GROUP BY T1.name HAVING AVG(T2.percent_change_24h) > T2.PRICE
CREATE TABLE coins ( id INTEGER not null primary key, name TEXT, slug TEXT, symbol TEXT, status TEXT, category TEXT, description TEXT, subreddit TEXT, notice TEXT, tags TEXT, tag_names TEXT, website TEXT, platform_id INTEGER, date_added TEXT, date_launched TEXT ); CREATE TABLE IF NOT EXISTS "historical" ( date DATE, coin_id INTEGER, cmc_rank INTEGER, market_cap REAL, price REAL, open REAL, high REAL, low REAL, close REAL, time_high TEXT, time_low TEXT, volume_24h REAL, percent_change_1h REAL, percent_change_24h REAL, percent_change_7d REAL, circulating_supply REAL, total_supply REAL, max_supply REAL, num_market_pairs INTEGER );
mondial_geo
Which two countries have the longest border in the world? Give the full name of the country.
SELECT T2.Country1, T2.Country2 FROM country AS T1 INNER JOIN borders AS T2 ON T1.Code = T2.Country1 ORDER BY T2.Length DESC LIMIT 1
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
books
How many books were ordered by customer Kandy Adamec?
SELECT COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Kandy' AND T3.last_name = 'Adamec'
CREATE TABLE address_status ( status_id INTEGER primary key, address_status TEXT ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT ); CREATE TABLE book_language ( language_id INTEGER primary key, language_code TEXT, language_name TEXT ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT ); CREATE TABLE address ( address_id INTEGER primary key, street_number TEXT, street_name TEXT, city TEXT, country_id INTEGER, foreign key (country_id) references country(country_id) ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, last_name TEXT, email TEXT ); CREATE TABLE customer_address ( customer_id INTEGER, address_id INTEGER, status_id INTEGER, primary key (customer_id, address_id), foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id) ); CREATE TABLE order_status ( status_id INTEGER primary key, status_value TEXT ); CREATE TABLE publisher ( publisher_id INTEGER primary key, publisher_name TEXT ); CREATE TABLE book ( book_id INTEGER primary key, title TEXT, isbn13 TEXT, language_id INTEGER, num_pages INTEGER, publication_date DATE, publisher_id INTEGER, foreign key (language_id) references book_language(language_id), foreign key (publisher_id) references publisher(publisher_id) ); CREATE TABLE book_author ( book_id INTEGER, author_id INTEGER, primary key (book_id, author_id), foreign key (author_id) references author(author_id), foreign key (book_id) references book(book_id) ); CREATE TABLE shipping_method ( method_id INTEGER primary key, method_name TEXT, cost REAL ); CREATE TABLE IF NOT EXISTS "cust_order" ( order_id INTEGER primary key autoincrement, order_date DATETIME, customer_id INTEGER references customer, shipping_method_id INTEGER references shipping_method, dest_address_id INTEGER references address ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "order_history" ( history_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, status_id INTEGER references order_status, status_date DATETIME ); CREATE TABLE IF NOT EXISTS "order_line" ( line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, book_id INTEGER references book, price REAL );
image_and_language
List out the number of object samples in image no.41 which are in the class of "kitchen"?
object samples in the class of "kitchen" refer to OBJ_CLASS_ID where OBJ_CLASS = 'kitchen'; image no.41 refers to IMG_ID = 41 ;
SELECT SUM(CASE WHEN T2.OBJ_CLASS = 'kitchen' THEN 1 ELSE 0 END) FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.IMG_ID = 41
CREATE TABLE ATT_CLASSES ( ATT_CLASS_ID INTEGER default 0 not null primary key, ATT_CLASS TEXT not null ); CREATE TABLE OBJ_CLASSES ( OBJ_CLASS_ID INTEGER default 0 not null primary key, OBJ_CLASS TEXT not null ); CREATE TABLE IMG_OBJ ( IMG_ID INTEGER default 0 not null, OBJ_SAMPLE_ID INTEGER default 0 not null, OBJ_CLASS_ID INTEGER null, X INTEGER null, Y INTEGER null, W INTEGER null, H INTEGER null, primary key (IMG_ID, OBJ_SAMPLE_ID), foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID) ); CREATE TABLE IMG_OBJ_ATT ( IMG_ID INTEGER default 0 not null, ATT_CLASS_ID INTEGER default 0 not null, OBJ_SAMPLE_ID INTEGER default 0 not null, primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID), foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID), foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID) ); CREATE TABLE PRED_CLASSES ( PRED_CLASS_ID INTEGER default 0 not null primary key, PRED_CLASS TEXT not null ); CREATE TABLE IMG_REL ( IMG_ID INTEGER default 0 not null, PRED_CLASS_ID INTEGER default 0 not null, OBJ1_SAMPLE_ID INTEGER default 0 not null, OBJ2_SAMPLE_ID INTEGER default 0 not null, primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID), foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID), foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID), foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID) );
superstore
Indicate the profit of product Sauder Camden County Barrister Bookcase, Planked Cherry Finish.
Sauder Camden County Barrister Bookcase, Planked Cherry Finish' refers to "Product Name"
SELECT DISTINCT T1.Profit FROM south_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.`Product Name` = 'Sauder Camden County Barrister Bookcase, Planked Cherry Finish'
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TEXT, "Product Name" TEXT, Category TEXT, "Sub-Category" TEXT, Region TEXT, primary key ("Product ID", Region) ); CREATE TABLE central_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE east_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE south_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE west_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) );
regional_sales
From 2018 to 2020, which year did the George Lewis group have the highest number of orders?
George Lewis refers to Sales Team; the highest number of orders refers to MAX(COUNT(OrderNumber)); which year from 2018 to 2020 refers to SUBSTR(OrderDate, -2) IN ('18', '19', '20') GROUP BY SUBSTR(OrderDate, -2);
SELECT SUBSTR(T1.OrderDate, -2, 2) FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.`Sales Team` = 'George Lewis' GROUP BY SUBSTR(T1.OrderDate, -2, 2) ORDER BY COUNT(T1.OrderNumber) DESC LIMIT 1
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT constraint Regions_pk primary key, State TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Sales Team" ( SalesTeamID INTEGER constraint "Sales Team_pk" primary key, "Sales Team" TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Store Locations" ( StoreID INTEGER constraint "Store Locations_pk" primary key, "City Name" TEXT, County TEXT, StateCode TEXT constraint "Store Locations_Regions_StateCode_fk" references Regions(StateCode), State TEXT, Type TEXT, Latitude REAL, Longitude REAL, AreaCode INTEGER, Population INTEGER, "Household Income" INTEGER, "Median Income" INTEGER, "Land Area" INTEGER, "Water Area" INTEGER, "Time Zone" TEXT ); CREATE TABLE IF NOT EXISTS "Sales Orders" ( OrderNumber TEXT constraint "Sales Orders_pk" primary key, "Sales Channel" TEXT, WarehouseCode TEXT, ProcuredDate TEXT, OrderDate TEXT, ShipDate TEXT, DeliveryDate TEXT, CurrencyCode TEXT, _SalesTeamID INTEGER constraint "Sales Orders_Sales Team_SalesTeamID_fk" references "Sales Team"(SalesTeamID), _CustomerID INTEGER constraint "Sales Orders_Customers_CustomerID_fk" references Customers(CustomerID), _StoreID INTEGER constraint "Sales Orders_Store Locations_StoreID_fk" references "Store Locations"(StoreID), _ProductID INTEGER constraint "Sales Orders_Products_ProductID_fk" references Products(ProductID), "Order Quantity" INTEGER, "Discount Applied" REAL, "Unit Price" TEXT, "Unit Cost" TEXT );
sales
What is the name of the product that is most sold by sale person id 20?
most sold refers to MAX(Quantity);
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesPersonID = 20 ORDER BY T2.Quantity DESC LIMIT 1
CREATE TABLE Customers ( CustomerID INTEGER not null primary key, FirstName TEXT not null, MiddleInitial TEXT null, LastName TEXT not null ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, FirstName TEXT not null, MiddleInitial TEXT null, LastName TEXT not null ); CREATE TABLE Products ( ProductID INTEGER not null primary key, Name TEXT not null, Price REAL null ); CREATE TABLE Sales ( SalesID INTEGER not null primary key, SalesPersonID INTEGER not null, CustomerID INTEGER not null, ProductID INTEGER not null, Quantity INTEGER not null, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade );
works_cycles
How many vendors does Adventure Works still work with but are not preferable?
not preferable refers to PreferredVendorStatus = 0; still work refers to ActiveFlag = 1;
SELECT COUNT(BusinessEntityID) FROM Vendor WHERE PreferredVendorStatus = 0 AND ActiveFlag = 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ( CultureID TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Currency ( CurrencyCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE CountryRegionCurrency ( CountryRegionCode TEXT not null, CurrencyCode TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (CountryRegionCode, CurrencyCode), foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode), foreign key (CurrencyCode) references Currency(CurrencyCode) ); CREATE TABLE Person ( BusinessEntityID INTEGER not null primary key, PersonType TEXT not null, NameStyle INTEGER default 0 not null, Title TEXT, FirstName TEXT not null, MiddleName TEXT, LastName TEXT not null, Suffix TEXT, EmailPromotion INTEGER default 0 not null, AdditionalContactInfo TEXT, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE BusinessEntityContact ( BusinessEntityID INTEGER not null, PersonID INTEGER not null, ContactTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, PersonID, ContactTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (ContactTypeID) references ContactType(ContactTypeID), foreign key (PersonID) references Person(BusinessEntityID) ); CREATE TABLE EmailAddress ( BusinessEntityID INTEGER not null, EmailAddressID INTEGER, EmailAddress TEXT, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (EmailAddressID, BusinessEntityID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Employee ( BusinessEntityID INTEGER not null primary key, NationalIDNumber TEXT not null unique, LoginID TEXT not null unique, OrganizationNode TEXT, OrganizationLevel INTEGER, JobTitle TEXT not null, BirthDate DATE not null, MaritalStatus TEXT not null, Gender TEXT not null, HireDate DATE not null, SalariedFlag INTEGER default 1 not null, VacationHours INTEGER default 0 not null, SickLeaveHours INTEGER default 0 not null, CurrentFlag INTEGER default 1 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Password ( BusinessEntityID INTEGER not null primary key, PasswordHash TEXT not null, PasswordSalt TEXT not null, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE PersonCreditCard ( BusinessEntityID INTEGER not null, CreditCardID INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, CreditCardID), foreign key (CreditCardID) references CreditCard(CreditCardID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE ProductCategory ( ProductCategoryID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductDescription ( ProductDescriptionID INTEGER primary key autoincrement, Description TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModel ( ProductModelID INTEGER primary key autoincrement, Name TEXT not null unique, CatalogDescription TEXT, Instructions TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModelProductDescriptionCulture ( ProductModelID INTEGER not null, ProductDescriptionID INTEGER not null, CultureID TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductModelID, ProductDescriptionID, CultureID), foreign key (ProductModelID) references ProductModel(ProductModelID), foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID), foreign key (CultureID) references Culture(CultureID) ); CREATE TABLE ProductPhoto ( ProductPhotoID INTEGER primary key autoincrement, ThumbNailPhoto BLOB, ThumbnailPhotoFileName TEXT, LargePhoto BLOB, LargePhotoFileName TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductSubcategory ( ProductSubcategoryID INTEGER primary key autoincrement, ProductCategoryID INTEGER not null, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID) ); CREATE TABLE SalesReason ( SalesReasonID INTEGER primary key autoincrement, Name TEXT not null, ReasonType TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SalesTerritory ( TerritoryID INTEGER primary key autoincrement, Name TEXT not null unique, CountryRegionCode TEXT not null, "Group" TEXT not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, CostYTD REAL default 0.0000 not null, CostLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode) ); CREATE TABLE SalesPerson ( BusinessEntityID INTEGER not null primary key, TerritoryID INTEGER, SalesQuota REAL, Bonus REAL default 0.0000 not null, CommissionPct REAL default 0.0000 not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references Employee(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE SalesPersonQuotaHistory ( BusinessEntityID INTEGER not null, QuotaDate DATETIME not null, SalesQuota REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, QuotaDate), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesTerritoryHistory ( BusinessEntityID INTEGER not null, TerritoryID INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, StartDate, TerritoryID), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE ScrapReason ( ScrapReasonID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE Shift ( ShiftID INTEGER primary key autoincrement, Name TEXT not null unique, StartTime TEXT not null, EndTime TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StartTime, EndTime) ); CREATE TABLE ShipMethod ( ShipMethodID INTEGER primary key autoincrement, Name TEXT not null unique, ShipBase REAL default 0.0000 not null, ShipRate REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SpecialOffer ( SpecialOfferID INTEGER primary key autoincrement, Description TEXT not null, DiscountPct REAL default 0.0000 not null, Type TEXT not null, Category TEXT not null, StartDate DATETIME not null, EndDate DATETIME not null, MinQty INTEGER default 0 not null, MaxQty INTEGER, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE BusinessEntityAddress ( BusinessEntityID INTEGER not null, AddressID INTEGER not null, AddressTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, AddressID, AddressTypeID), foreign key (AddressID) references Address(AddressID), foreign key (AddressTypeID) references AddressType(AddressTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE SalesTaxRate ( SalesTaxRateID INTEGER primary key autoincrement, StateProvinceID INTEGER not null, TaxType INTEGER not null, TaxRate REAL default 0.0000 not null, Name TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceID, TaxType), foreign key (StateProvinceID) references StateProvince(StateProvinceID) ); CREATE TABLE Store ( BusinessEntityID INTEGER not null primary key, Name TEXT not null, SalesPersonID INTEGER, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (SalesPersonID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesOrderHeaderSalesReason ( SalesOrderID INTEGER not null, SalesReasonID INTEGER not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SalesOrderID, SalesReasonID), foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SalesReasonID) references SalesReason(SalesReasonID) ); CREATE TABLE TransactionHistoryArchive ( TransactionID INTEGER not null primary key, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE UnitMeasure ( UnitMeasureCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductCostHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, StandardCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ProductDocument ( ProductID INTEGER not null, DocumentNode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, DocumentNode), foreign key (ProductID) references Product(ProductID), foreign key (DocumentNode) references Document(DocumentNode) ); CREATE TABLE ProductInventory ( ProductID INTEGER not null, LocationID INTEGER not null, Shelf TEXT not null, Bin INTEGER not null, Quantity INTEGER default 0 not null, rowguid TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, LocationID), foreign key (ProductID) references Product(ProductID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE ProductProductPhoto ( ProductID INTEGER not null, ProductPhotoID INTEGER not null, "Primary" INTEGER default 0 not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, ProductPhotoID), foreign key (ProductID) references Product(ProductID), foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID) ); CREATE TABLE ProductReview ( ProductReviewID INTEGER primary key autoincrement, ProductID INTEGER not null, ReviewerName TEXT not null, ReviewDate DATETIME default CURRENT_TIMESTAMP not null, EmailAddress TEXT not null, Rating INTEGER not null, Comments TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ShoppingCartItem ( ShoppingCartItemID INTEGER primary key autoincrement, ShoppingCartID TEXT not null, Quantity INTEGER default 1 not null, ProductID INTEGER not null, DateCreated DATETIME default CURRENT_TIMESTAMP not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SpecialOfferProduct ( SpecialOfferID INTEGER not null, ProductID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SpecialOfferID, ProductID), foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SalesOrderDetail ( SalesOrderID INTEGER not null, SalesOrderDetailID INTEGER primary key autoincrement, CarrierTrackingNumber TEXT, OrderQty INTEGER not null, ProductID INTEGER not null, SpecialOfferID INTEGER not null, UnitPrice REAL not null, UnitPriceDiscount REAL default 0.0000 not null, LineTotal REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID) ); CREATE TABLE TransactionHistory ( TransactionID INTEGER primary key autoincrement, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE Vendor ( BusinessEntityID INTEGER not null primary key, AccountNumber TEXT not null unique, Name TEXT not null, CreditRating INTEGER not null, PreferredVendorStatus INTEGER default 1 not null, ActiveFlag INTEGER default 1 not null, PurchasingWebServiceURL TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE ProductVendor ( ProductID INTEGER not null, BusinessEntityID INTEGER not null, AverageLeadTime INTEGER not null, StandardPrice REAL not null, LastReceiptCost REAL, LastReceiptDate DATETIME, MinOrderQty INTEGER not null, MaxOrderQty INTEGER not null, OnOrderQty INTEGER, UnitMeasureCode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, BusinessEntityID), foreign key (ProductID) references Product(ProductID), foreign key (BusinessEntityID) references Vendor(BusinessEntityID), foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode) ); CREATE TABLE PurchaseOrderHeader ( PurchaseOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, Status INTEGER default 1 not null, EmployeeID INTEGER not null, VendorID INTEGER not null, ShipMethodID INTEGER not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, ShipDate DATETIME, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (EmployeeID) references Employee(BusinessEntityID), foreign key (VendorID) references Vendor(BusinessEntityID), foreign key (ShipMethodID) references ShipMethod(ShipMethodID) ); CREATE TABLE PurchaseOrderDetail ( PurchaseOrderID INTEGER not null, PurchaseOrderDetailID INTEGER primary key autoincrement, DueDate DATETIME not null, OrderQty INTEGER not null, ProductID INTEGER not null, UnitPrice REAL not null, LineTotal REAL not null, ReceivedQty REAL not null, RejectedQty REAL not null, StockedQty REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE WorkOrder ( WorkOrderID INTEGER primary key autoincrement, ProductID INTEGER not null, OrderQty INTEGER not null, StockedQty INTEGER not null, ScrappedQty INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, DueDate DATETIME not null, ScrapReasonID INTEGER, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID), foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID) ); CREATE TABLE WorkOrderRouting ( WorkOrderID INTEGER not null, ProductID INTEGER not null, OperationSequence INTEGER not null, LocationID INTEGER not null, ScheduledStartDate DATETIME not null, ScheduledEndDate DATETIME not null, ActualStartDate DATETIME, ActualEndDate DATETIME, ActualResourceHrs REAL, PlannedCost REAL not null, ActualCost REAL, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (WorkOrderID, ProductID, OperationSequence), foreign key (WorkOrderID) references WorkOrder(WorkOrderID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE Customer ( CustomerID INTEGER primary key, PersonID INTEGER, StoreID INTEGER, TerritoryID INTEGER, AccountNumber TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (PersonID) references Person(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID), foreign key (StoreID) references Store(BusinessEntityID) ); CREATE TABLE ProductListPriceHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, ListPrice REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE IF NOT EXISTS "Address" ( AddressID INTEGER primary key autoincrement, AddressLine1 TEXT not null, AddressLine2 TEXT, City TEXT not null, StateProvinceID INTEGER not null references StateProvince, PostalCode TEXT not null, SpatialLocation TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode) ); CREATE TABLE IF NOT EXISTS "AddressType" ( AddressTypeID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "BillOfMaterials" ( BillOfMaterialsID INTEGER primary key autoincrement, ProductAssemblyID INTEGER references Product, ComponentID INTEGER not null references Product, StartDate DATETIME default current_timestamp not null, EndDate DATETIME, UnitMeasureCode TEXT not null references UnitMeasure, BOMLevel INTEGER not null, PerAssemblyQty REAL default 1.00 not null, ModifiedDate DATETIME default current_timestamp not null, unique (ProductAssemblyID, ComponentID, StartDate) ); CREATE TABLE IF NOT EXISTS "BusinessEntity" ( BusinessEntityID INTEGER primary key autoincrement, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "ContactType" ( ContactTypeID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "CurrencyRate" ( CurrencyRateID INTEGER primary key autoincrement, CurrencyRateDate DATETIME not null, FromCurrencyCode TEXT not null references Currency, ToCurrencyCode TEXT not null references Currency, AverageRate REAL not null, EndOfDayRate REAL not null, ModifiedDate DATETIME default current_timestamp not null, unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode) ); CREATE TABLE IF NOT EXISTS "Department" ( DepartmentID INTEGER primary key autoincrement, Name TEXT not null unique, GroupName TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory" ( BusinessEntityID INTEGER not null references Employee, DepartmentID INTEGER not null references Department, ShiftID INTEGER not null references Shift, StartDate DATE not null, EndDate DATE, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID) ); CREATE TABLE IF NOT EXISTS "EmployeePayHistory" ( BusinessEntityID INTEGER not null references Employee, RateChangeDate DATETIME not null, Rate REAL not null, PayFrequency INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, RateChangeDate) ); CREATE TABLE IF NOT EXISTS "JobCandidate" ( JobCandidateID INTEGER primary key autoincrement, BusinessEntityID INTEGER references Employee, Resume TEXT, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Location" ( LocationID INTEGER primary key autoincrement, Name TEXT not null unique, CostRate REAL default 0.0000 not null, Availability REAL default 0.00 not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "PhoneNumberType" ( PhoneNumberTypeID INTEGER primary key autoincrement, Name TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Product" ( ProductID INTEGER primary key autoincrement, Name TEXT not null unique, ProductNumber TEXT not null unique, MakeFlag INTEGER default 1 not null, FinishedGoodsFlag INTEGER default 1 not null, Color TEXT, SafetyStockLevel INTEGER not null, ReorderPoint INTEGER not null, StandardCost REAL not null, ListPrice REAL not null, Size TEXT, SizeUnitMeasureCode TEXT references UnitMeasure, WeightUnitMeasureCode TEXT references UnitMeasure, Weight REAL, DaysToManufacture INTEGER not null, ProductLine TEXT, Class TEXT, Style TEXT, ProductSubcategoryID INTEGER references ProductSubcategory, ProductModelID INTEGER references ProductModel, SellStartDate DATETIME not null, SellEndDate DATETIME, DiscontinuedDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Document" ( DocumentNode TEXT not null primary key, DocumentLevel INTEGER, Title TEXT not null, Owner INTEGER not null references Employee, FolderFlag INTEGER default 0 not null, FileName TEXT not null, FileExtension TEXT not null, Revision TEXT not null, ChangeNumber INTEGER default 0 not null, Status INTEGER not null, DocumentSummary TEXT, Document BLOB, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (DocumentLevel, DocumentNode) ); CREATE TABLE IF NOT EXISTS "StateProvince" ( StateProvinceID INTEGER primary key autoincrement, StateProvinceCode TEXT not null, CountryRegionCode TEXT not null references CountryRegion, IsOnlyStateProvinceFlag INTEGER default 1 not null, Name TEXT not null unique, TerritoryID INTEGER not null references SalesTerritory, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceCode, CountryRegionCode) ); CREATE TABLE IF NOT EXISTS "CreditCard" ( CreditCardID INTEGER primary key autoincrement, CardType TEXT not null, CardNumber TEXT not null unique, ExpMonth INTEGER not null, ExpYear INTEGER not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "SalesOrderHeader" ( SalesOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, DueDate DATETIME not null, ShipDate DATETIME, Status INTEGER default 1 not null, OnlineOrderFlag INTEGER default 1 not null, SalesOrderNumber TEXT not null unique, PurchaseOrderNumber TEXT, AccountNumber TEXT, CustomerID INTEGER not null references Customer, SalesPersonID INTEGER references SalesPerson, TerritoryID INTEGER references SalesTerritory, BillToAddressID INTEGER not null references Address, ShipToAddressID INTEGER not null references Address, ShipMethodID INTEGER not null references Address, CreditCardID INTEGER references CreditCard, CreditCardApprovalCode TEXT, CurrencyRateID INTEGER references CurrencyRate, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, Comment TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null );
retail_complains
Among all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals?
SELECT COUNT(T2.Issue) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Issue = 'Deposits and withdrawals' AND T1.city = 'New York City'
CREATE TABLE state ( StateCode TEXT constraint state_pk primary key, State TEXT, Region TEXT ); CREATE TABLE callcenterlogs ( "Date received" DATE, "Complaint ID" TEXT, "rand client" TEXT, phonefinal TEXT, "vru+line" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, primary key ("Complaint ID"), foreign key ("rand client") references client(client_id) ); CREATE TABLE client ( client_id TEXT primary key, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, foreign key (district_id) references district(district_id) ); CREATE TABLE district ( district_id INTEGER primary key, city TEXT, state_abbrev TEXT, division TEXT, foreign key (state_abbrev) references state(StateCode) ); CREATE TABLE events ( "Date received" DATE, Product TEXT, "Sub-product" TEXT, Issue TEXT, "Sub-issue" TEXT, "Consumer complaint narrative" TEXT, Tags TEXT, "Consumer consent provided?" TEXT, "Submitted via" TEXT, "Date sent to company" TEXT, "Company response to consumer" TEXT, "Timely response?" TEXT, "Consumer disputed?" TEXT, "Complaint ID" TEXT, Client_ID TEXT, primary key ("Complaint ID", Client_ID), foreign key ("Complaint ID") references callcenterlogs("Complaint ID"), foreign key (Client_ID) references client(client_id) ); CREATE TABLE reviews ( "Date" DATE primary key, Stars INTEGER, Reviews TEXT, Product TEXT, district_id INTEGER, foreign key (district_id) references district(district_id) );
olympics
Please list the names of the Olympic games that were held in London.
held in London refers to city_name = 'London';
SELECT T3.games_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'London'
CREATE TABLE city ( id INTEGER not null primary key, city_name TEXT default NULL ); CREATE TABLE games ( id INTEGER not null primary key, games_year INTEGER default NULL, games_name TEXT default NULL, season TEXT default NULL ); CREATE TABLE games_city ( games_id INTEGER default NULL, city_id INTEGER default NULL, foreign key (city_id) references city(id), foreign key (games_id) references games(id) ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL ); CREATE TABLE noc_region ( id INTEGER not null primary key, noc TEXT default NULL, region_name TEXT default NULL ); CREATE TABLE person ( id INTEGER not null primary key, full_name TEXT default NULL, gender TEXT default NULL, height INTEGER default NULL, weight INTEGER default NULL ); CREATE TABLE games_competitor ( id INTEGER not null primary key, games_id INTEGER default NULL, person_id INTEGER default NULL, age INTEGER default NULL, foreign key (games_id) references games(id), foreign key (person_id) references person(id) ); CREATE TABLE person_region ( person_id INTEGER default NULL, region_id INTEGER default NULL, foreign key (person_id) references person(id), foreign key (region_id) references noc_region(id) ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL ); CREATE TABLE event ( id INTEGER not null primary key, sport_id INTEGER default NULL, event_name TEXT default NULL, foreign key (sport_id) references sport(id) ); CREATE TABLE competitor_event ( event_id INTEGER default NULL, competitor_id INTEGER default NULL, medal_id INTEGER default NULL, foreign key (competitor_id) references games_competitor(id), foreign key (event_id) references event(id), foreign key (medal_id) references medal(id) );
codebase_comments
Please provide a link to the most well-known repository's Github address.
link refers to Url; well-known repository refers to MAX(Watchers);
SELECT Url FROM Repo WHERE Watchers = ( SELECT MAX(Watchers) FROM Repo )
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "Method" ( Id INTEGER not null primary key autoincrement, Name TEXT, FullComment TEXT, Summary TEXT, ApiCalls TEXT, CommentIsXml INTEGER, SampledAt INTEGER, SolutionId INTEGER, Lang TEXT, NameTokenized TEXT ); CREATE TABLE IF NOT EXISTS "MethodParameter" ( Id INTEGER not null primary key autoincrement, MethodId TEXT, Type TEXT, Name TEXT ); CREATE TABLE Repo ( Id INTEGER not null primary key autoincrement, Url TEXT, Stars INTEGER, Forks INTEGER, Watchers INTEGER, ProcessedTime INTEGER ); CREATE TABLE Solution ( Id INTEGER not null primary key autoincrement, RepoId INTEGER, Path TEXT, ProcessedTime INTEGER, WasCompiled INTEGER );
movie_3
What is the full name of the customer who rented the highest number of movies of all time?
full name refers to first_name, last_name; customer who rented the most film refers to Max(count(rental_id))
SELECT T.first_name, T.last_name FROM ( SELECT T2.first_name, T2.last_name, COUNT(T1.rental_id) AS num FROM rental AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.first_name, T2.last_name ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
college_completion
Name the state with the most number of graduate cohort in 2012 from private institute for profit? List all such institutes in the mentioned state.
most number of graduate cohort refers to MAX(SUM(grad_cohort)); in 2012 refers to year = 2012; private institute for profit refers to control = 'Private for-profit'; institutes refers to chronname;
SELECT T1.state, T1.chronname FROM institution_details AS T1 INNER JOIN state_sector_grads AS T2 ON T1.state = T2.state WHERE T2.year = 2012 AND T1.control = 'Private for-profit' GROUP BY T2.grad_cohort ORDER BY COUNT(T2.grad_cohort) DESC LIMIT 1
CREATE TABLE institution_details ( unitid INTEGER constraint institution_details_pk primary key, chronname TEXT, city TEXT, state TEXT, level TEXT, control TEXT, basic TEXT, hbcu TEXT, flagship TEXT, long_x REAL, lat_y REAL, site TEXT, student_count INTEGER, awards_per_value REAL, awards_per_state_value REAL, awards_per_natl_value REAL, exp_award_value INTEGER, exp_award_state_value INTEGER, exp_award_natl_value INTEGER, exp_award_percentile INTEGER, ft_pct REAL, fte_value INTEGER, fte_percentile INTEGER, med_sat_value TEXT, med_sat_percentile TEXT, aid_value INTEGER, aid_percentile INTEGER, endow_value TEXT, endow_percentile TEXT, grad_100_value REAL, grad_100_percentile INTEGER, grad_150_value REAL, grad_150_percentile INTEGER, pell_value REAL, pell_percentile INTEGER, retain_value REAL, retain_percentile INTEGER, ft_fac_value REAL, ft_fac_percentile INTEGER, vsa_year TEXT, vsa_grad_after4_first TEXT, vsa_grad_elsewhere_after4_first TEXT, vsa_enroll_after4_first TEXT, vsa_enroll_elsewhere_after4_first TEXT, vsa_grad_after6_first TEXT, vsa_grad_elsewhere_after6_first TEXT, vsa_enroll_after6_first TEXT, vsa_enroll_elsewhere_after6_first TEXT, vsa_grad_after4_transfer TEXT, vsa_grad_elsewhere_after4_transfer TEXT, vsa_enroll_after4_transfer TEXT, vsa_enroll_elsewhere_after4_transfer TEXT, vsa_grad_after6_transfer TEXT, vsa_grad_elsewhere_after6_transfer TEXT, vsa_enroll_after6_transfer TEXT, vsa_enroll_elsewhere_after6_transfer TEXT, similar TEXT, state_sector_ct INTEGER, carnegie_ct INTEGER, counted_pct TEXT, nicknames TEXT, cohort_size INTEGER ); CREATE TABLE institution_grads ( unitid INTEGER, year INTEGER, gender TEXT, race TEXT, cohort TEXT, grad_cohort TEXT, grad_100 TEXT, grad_150 TEXT, grad_100_rate TEXT, grad_150_rate TEXT, foreign key (unitid) references institution_details(unitid) ); CREATE TABLE state_sector_grads ( stateid INTEGER, state TEXT, state_abbr TEXT, control TEXT, level TEXT, year INTEGER, gender TEXT, race TEXT, cohort TEXT, grad_cohort TEXT, grad_100 TEXT, grad_150 TEXT, grad_100_rate TEXT, grad_150_rate TEXT, grad_cohort_ct INTEGER, foreign key (state) references institution_details(state), foreign key (stateid) references state_sector_details(stateid) ); CREATE TABLE IF NOT EXISTS "state_sector_details" ( stateid INTEGER, state TEXT references institution_details (state), state_post TEXT, level TEXT, control TEXT, schools_count INTEGER, counted_pct TEXT, awards_per_state_value TEXT, awards_per_natl_value REAL, exp_award_state_value TEXT, exp_award_natl_value INTEGER, state_appr_value TEXT, state_appr_rank TEXT, grad_rate_rank TEXT, awards_per_rank TEXT, primary key (stateid, level, control) );
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 = 'MLK Library' AND T1.end_station_name = 'San Salvador at 1st' AND T1.duration = 386
CREATE TABLE IF NOT EXISTS "station" ( id INTEGER not null primary key, name TEXT, lat REAL, long REAL, dock_count INTEGER, city TEXT, installation_date TEXT ); CREATE TABLE IF NOT EXISTS "status" ( station_id INTEGER, bikes_available INTEGER, docks_available INTEGER, time TEXT ); CREATE TABLE IF NOT EXISTS "trip" ( id INTEGER not null primary key, duration INTEGER, start_date TEXT, start_station_name TEXT, start_station_id INTEGER, end_date TEXT, end_station_name TEXT, end_station_id INTEGER, bike_id INTEGER, subscription_type TEXT, zip_code INTEGER ); CREATE TABLE IF NOT EXISTS "weather" ( date TEXT, max_temperature_f INTEGER, mean_temperature_f INTEGER, min_temperature_f INTEGER, max_dew_point_f INTEGER, mean_dew_point_f INTEGER, min_dew_point_f INTEGER, max_humidity INTEGER, mean_humidity INTEGER, min_humidity INTEGER, max_sea_level_pressure_inches REAL, mean_sea_level_pressure_inches REAL, min_sea_level_pressure_inches REAL, max_visibility_miles INTEGER, mean_visibility_miles INTEGER, min_visibility_miles INTEGER, max_wind_Speed_mph INTEGER, mean_wind_speed_mph INTEGER, max_gust_speed_mph INTEGER, precipitation_inches TEXT, cloud_cover INTEGER, events TEXT, wind_dir_degrees INTEGER, zip_code TEXT );
movie_3
How many customers did not rent material at Mike's store?
not at Mike's store refers to staff.first_name ! = 'Mike'
SELECT COUNT(T1.customer_id) FROM customer AS T1 INNER JOIN store AS T2 ON T1.store_id = T2.store_id INNER JOIN staff AS T3 ON T2.manager_staff_id = T3.staff_id WHERE T3.first_name != 'Mike'
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
mondial_geo
Provide a list of all organisations with headquarters in London?
London is a city
SELECT Name FROM organization WHERE City = 'London'
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
synthea
State the average period of Ms. Angelena Kertzmann's several normal pregnancies.
DIVIDE(SUBTRACT(stop time - start time), COUNT(DESCRIPTION = 'Normal pregnancy')));
SELECT CAST(SUM(strftime('%J', T2.STOP) - strftime('%J', T2.START)) AS REAL) / COUNT(T2.PATIENT) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Ms.' AND T1.first = 'Angelena' AND T1.last = 'Kertzmann' AND T2.description = 'Normal pregnancy'
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ); CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ); CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ); CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE IF NOT EXISTS "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER );
talkingdata
Please list the categories of the app users who are not active when event no.2 happened.
not active refers to is_active = 0; event no. refers to event_id; event_id = 2;
SELECT DISTINCT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.event_id = 2 AND T3.is_active = 0
CREATE TABLE `app_all` ( `app_id` INTEGER NOT NULL, PRIMARY KEY (`app_id`) ); CREATE TABLE `app_events` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_events_relevant` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER DEFAULT NULL, `is_active` INTEGER DEFAULT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_labels` ( `app_id` INTEGER NOT NULL, `label_id` INTEGER NOT NULL, FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `events` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME DEFAULT NULL, `longitude` REAL DEFAULT NULL, `latitude` REAL DEFAULT NULL, PRIMARY KEY (`event_id`) ); CREATE TABLE `events_relevant` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME NOT NULL, `longitude` REAL NOT NULL, `latitude` REAL NOT NULL, PRIMARY KEY (`event_id`), FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`), FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age_test` ( `device_id` INTEGER NOT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `gender_age_train` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `label_categories` ( `label_id` INTEGER NOT NULL, `category` TEXT DEFAULT NULL, PRIMARY KEY (`label_id`) ); CREATE TABLE `phone_brand_device_model2` ( `device_id` INTEGER NOT NULL, `phone_brand` TEXT NOT NULL, `device_model` TEXT NOT NULL, PRIMARY KEY (`device_id`,`phone_brand`,`device_model`) ); CREATE TABLE `sample_submission` ( `device_id` INTEGER NOT NULL, `F23-` REAL DEFAULT NULL, `F24-26` REAL DEFAULT NULL, `F27-28` REAL DEFAULT NULL, `F29-32` REAL DEFAULT NULL, `F33-42` REAL DEFAULT NULL, `F43+` REAL DEFAULT NULL, `M22-` REAL DEFAULT NULL, `M23-26` REAL DEFAULT NULL, `M27-28` REAL DEFAULT NULL, `M29-31` REAL DEFAULT NULL, `M32-38` REAL DEFAULT NULL, `M39+` REAL DEFAULT NULL, PRIMARY KEY (`device_id`) );
hockey
For the team which had three different goalies in the 2011 postseason games, how many games did they win in the regular season?
three different goalies refer to count(playerID) = 3; game won refers to W
SELECT SUM(T2.W) FROM Goalies AS T1 INNER JOIN Teams AS T2 ON T1.tmID = T2.tmID WHERE T2.year = 2011 GROUP BY T1.tmID HAVING COUNT(DISTINCT T1.playerID) = 3
CREATE TABLE AwardsMisc ( name TEXT not null primary key, ID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT ); CREATE TABLE HOF ( year INTEGER, hofID TEXT not null primary key, name TEXT, category TEXT ); CREATE TABLE Teams ( year INTEGER not null, lgID TEXT, tmID TEXT not null, franchID TEXT, confID TEXT, divID TEXT, rank INTEGER, playoff TEXT, G INTEGER, W INTEGER, L INTEGER, T INTEGER, OTL TEXT, Pts INTEGER, SoW TEXT, SoL TEXT, GF INTEGER, GA INTEGER, name TEXT, PIM TEXT, BenchMinor TEXT, PPG TEXT, PPC TEXT, SHA TEXT, PKG TEXT, PKC TEXT, SHF TEXT, primary key (year, tmID) ); CREATE TABLE Coaches ( coachID TEXT not null, year INTEGER not null, tmID TEXT not null, lgID TEXT, stint INTEGER not null, notes TEXT, g INTEGER, w INTEGER, l INTEGER, t INTEGER, postg TEXT, postw TEXT, postl TEXT, postt TEXT, primary key (coachID, year, tmID, stint), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE AwardsCoaches ( coachID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT, foreign key (coachID) references Coaches (coachID) ); CREATE TABLE Master ( playerID TEXT, coachID TEXT, hofID TEXT, firstName TEXT, lastName TEXT not null, nameNote TEXT, nameGiven TEXT, nameNick TEXT, height TEXT, weight TEXT, shootCatch TEXT, legendsID TEXT, ihdbID TEXT, hrefID TEXT, firstNHL TEXT, lastNHL TEXT, firstWHA TEXT, lastWHA TEXT, pos TEXT, birthYear TEXT, birthMon TEXT, birthDay TEXT, birthCountry TEXT, birthState TEXT, birthCity TEXT, deathYear TEXT, deathMon TEXT, deathDay TEXT, deathCountry TEXT, deathState TEXT, deathCity TEXT, foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade ); CREATE TABLE AwardsPlayers ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT, note TEXT, pos TEXT, primary key (playerID, award, year), foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE CombinedShutouts ( year INTEGER, month INTEGER, date INTEGER, tmID TEXT, oppID TEXT, "R/P" TEXT, IDgoalie1 TEXT, IDgoalie2 TEXT, foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE Goalies ( playerID TEXT not null, year INTEGER not null, stint INTEGER not null, tmID TEXT, lgID TEXT, GP TEXT, Min TEXT, W TEXT, L TEXT, "T/OL" TEXT, ENG TEXT, SHO TEXT, GA TEXT, SA TEXT, PostGP TEXT, PostMin TEXT, PostW TEXT, PostL TEXT, PostT TEXT, PostENG TEXT, PostSHO TEXT, PostGA TEXT, PostSA TEXT, primary key (playerID, year, stint), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE GoaliesSC ( playerID TEXT not null, year INTEGER not null, tmID TEXT, lgID TEXT, GP INTEGER, Min INTEGER, W INTEGER, L INTEGER, T INTEGER, SHO INTEGER, GA INTEGER, primary key (playerID, year), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE GoaliesShootout ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, W INTEGER, L INTEGER, SA INTEGER, GA INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE Scoring ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, lgID TEXT, pos TEXT, GP INTEGER, G INTEGER, A INTEGER, Pts INTEGER, PIM INTEGER, "+/-" TEXT, PPG TEXT, PPA TEXT, SHG TEXT, SHA TEXT, GWG TEXT, GTG TEXT, SOG TEXT, PostGP TEXT, PostG TEXT, PostA TEXT, PostPts TEXT, PostPIM TEXT, "Post+/-" TEXT, PostPPG TEXT, PostPPA TEXT, PostSHG TEXT, PostSHA TEXT, PostGWG TEXT, PostSOG TEXT, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringSC ( playerID TEXT, year INTEGER, tmID TEXT, lgID TEXT, pos TEXT, GP INTEGER, G INTEGER, A INTEGER, Pts INTEGER, PIM INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringShootout ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, S INTEGER, G INTEGER, GDG INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringSup ( playerID TEXT, year INTEGER, PPA TEXT, SHA TEXT, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE SeriesPost ( year INTEGER, round TEXT, series TEXT, tmIDWinner TEXT, lgIDWinner TEXT, tmIDLoser TEXT, lgIDLoser TEXT, W INTEGER, L INTEGER, T INTEGER, GoalsWinner INTEGER, GoalsLoser INTEGER, note TEXT, foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamSplits ( year INTEGER not null, lgID TEXT, tmID TEXT not null, hW INTEGER, hL INTEGER, hT INTEGER, hOTL TEXT, rW INTEGER, rL INTEGER, rT INTEGER, rOTL TEXT, SepW TEXT, SepL TEXT, SepT TEXT, SepOL TEXT, OctW TEXT, OctL TEXT, OctT TEXT, OctOL TEXT, NovW TEXT, NovL TEXT, NovT TEXT, NovOL TEXT, DecW TEXT, DecL TEXT, DecT TEXT, DecOL TEXT, JanW INTEGER, JanL INTEGER, JanT INTEGER, JanOL TEXT, FebW INTEGER, FebL INTEGER, FebT INTEGER, FebOL TEXT, MarW TEXT, MarL TEXT, MarT TEXT, MarOL TEXT, AprW TEXT, AprL TEXT, AprT TEXT, AprOL TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamVsTeam ( year INTEGER not null, lgID TEXT, tmID TEXT not null, oppID TEXT not null, W INTEGER, L INTEGER, T INTEGER, OTL TEXT, primary key (year, tmID, oppID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE TeamsHalf ( year INTEGER not null, lgID TEXT, tmID TEXT not null, half INTEGER not null, rank INTEGER, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, primary key (year, tmID, half), foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE TeamsPost ( year INTEGER not null, lgID TEXT, tmID TEXT not null, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, PIM TEXT, BenchMinor TEXT, PPG TEXT, PPC TEXT, SHA TEXT, PKG TEXT, PKC TEXT, SHF TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamsSC ( year INTEGER not null, lgID TEXT, tmID TEXT not null, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, PIM TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE abbrev ( Type TEXT not null, Code TEXT not null, Fullname TEXT, primary key (Type, Code) );
legislator
Give the religion of the legislator whose YouTube name is MaxineWaters.
MaxineWaters relates to youtube
SELECT T2.religion_bio FROM `social-media` AS T1 INNER JOIN current AS T2 ON T1.bioguide = T2.bioguide_id WHERE T1.youtube = 'MaxineWaters'
CREATE TABLE current ( ballotpedia_id TEXT, bioguide_id TEXT, birthday_bio DATE, cspan_id REAL, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id REAL, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id INTEGER, votesmart_id REAL, wikidata_id TEXT, wikipedia_id TEXT, primary key (bioguide_id, cspan_id) ); CREATE TABLE IF NOT EXISTS "current-terms" ( address TEXT, bioguide TEXT, caucus TEXT, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, primary key (bioguide, end), foreign key (bioguide) references current(bioguide_id) ); CREATE TABLE historical ( ballotpedia_id TEXT, bioguide_id TEXT primary key, bioguide_previous_id TEXT, birthday_bio TEXT, cspan_id TEXT, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_alternate_id TEXT, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id TEXT, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id TEXT, votesmart_id TEXT, wikidata_id TEXT, wikipedia_id TEXT ); CREATE TABLE IF NOT EXISTS "historical-terms" ( address TEXT, bioguide TEXT primary key, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, middle TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, foreign key (bioguide) references historical(bioguide_id) ); CREATE TABLE IF NOT EXISTS "social-media" ( bioguide TEXT primary key, facebook TEXT, facebook_id REAL, govtrack REAL, instagram TEXT, instagram_id REAL, thomas INTEGER, twitter TEXT, twitter_id REAL, youtube TEXT, youtube_id TEXT, foreign key (bioguide) references current(bioguide_id) );
food_inspection_2
How many employees have salary greater than 70000 but fail the inspection?
salary greater than 70000 refers to salary > 70000; fail the inspection refers to results = 'Fail'
SELECT COUNT(DISTINCT T1.employee_id) FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T2.results = 'Fail' AND T1.salary > 70000
CREATE TABLE employee ( employee_id INTEGER primary key, first_name TEXT, last_name TEXT, address TEXT, city TEXT, state TEXT, zip INTEGER, phone TEXT, title TEXT, salary INTEGER, supervisor INTEGER, foreign key (supervisor) references employee(employee_id) ); CREATE TABLE establishment ( license_no INTEGER primary key, dba_name TEXT, aka_name TEXT, facility_type TEXT, risk_level INTEGER, address TEXT, city TEXT, state TEXT, zip INTEGER, latitude REAL, longitude REAL, ward INTEGER ); CREATE TABLE inspection ( inspection_id INTEGER primary key, inspection_date DATE, inspection_type TEXT, results TEXT, employee_id INTEGER, license_no INTEGER, followup_to INTEGER, foreign key (employee_id) references employee(employee_id), foreign key (license_no) references establishment(license_no), foreign key (followup_to) references inspection(inspection_id) ); CREATE TABLE inspection_point ( point_id INTEGER primary key, Description TEXT, category TEXT, code TEXT, fine INTEGER, point_level TEXT ); CREATE TABLE violation ( inspection_id INTEGER, point_id INTEGER, fine INTEGER, inspector_comment TEXT, primary key (inspection_id, point_id), foreign key (inspection_id) references inspection(inspection_id), foreign key (point_id) references inspection_point(point_id) );
app_store
What is the average review number for application with 5 rating?
average review = AVG(Review); application refers to app; Rating = 5;
SELECT AVG(Reviews) FROM playstore WHERE Rating = 5
CREATE TABLE IF NOT EXISTS "playstore" ( App TEXT, Category TEXT, Rating REAL, Reviews INTEGER, Size TEXT, Installs TEXT, Type TEXT, Price TEXT, "Content Rating" TEXT, Genres TEXT ); CREATE TABLE IF NOT EXISTS "user_reviews" ( App TEXT references "playstore" (App), Translated_Review TEXT, Sentiment TEXT, Sentiment_Polarity TEXT, Sentiment_Subjectivity TEXT );
simpson_episodes
What is the birth place of the cast or crew member who won the Best Voice-Over Performance in Online Film & Television Association in 2009?
won refers to result = 'Winner'; 'Best Voice-Over Performance' is the award; ' Online Film & Television Association' is the organization; in 2009 refers to year = 2009
SELECT T1.birth_place FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.award = 'Best Voice-Over Performance' AND T2.organization = 'Online Film & Television Association' AND T2.year = 2009;
CREATE TABLE IF NOT EXISTS "Episode" ( episode_id TEXT constraint Episode_pk primary key, season INTEGER, episode INTEGER, number_in_series INTEGER, title TEXT, summary TEXT, air_date TEXT, episode_image TEXT, rating REAL, votes INTEGER ); CREATE TABLE Person ( name TEXT constraint Person_pk primary key, birthdate TEXT, birth_name TEXT, birth_place TEXT, birth_region TEXT, birth_country TEXT, height_meters REAL, nickname TEXT ); CREATE TABLE Award ( award_id INTEGER primary key, organization TEXT, year INTEGER, award_category TEXT, award TEXT, person TEXT, role TEXT, episode_id TEXT, season TEXT, song TEXT, result TEXT, foreign key (person) references Person(name), foreign key (episode_id) references Episode(episode_id) ); CREATE TABLE Character_Award ( award_id INTEGER, character TEXT, foreign key (award_id) references Award(award_id) ); CREATE TABLE Credit ( episode_id TEXT, category TEXT, person TEXT, role TEXT, credited TEXT, foreign key (episode_id) references Episode(episode_id), foreign key (person) references Person(name) ); CREATE TABLE Keyword ( episode_id TEXT, keyword TEXT, primary key (episode_id, keyword), foreign key (episode_id) references Episode(episode_id) ); CREATE TABLE Vote ( episode_id TEXT, stars INTEGER, votes INTEGER, percent REAL, foreign key (episode_id) references Episode(episode_id) );
superstore
Please list any three orders that caused a loss to the company.
caused a loss to the company refers to Profit < 0
SELECT `Order ID` FROM central_superstore WHERE Profit < 0 LIMIT 3
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TEXT, "Product Name" TEXT, Category TEXT, "Sub-Category" TEXT, Region TEXT, primary key ("Product ID", Region) ); CREATE TABLE central_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE east_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE south_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE west_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) );
chicago_crime
What is the average number of crimes in a neighborhood in Central Chicago?
Central Chicago refers to side = 'Central'; average number = divide(count(report_no), count(community_area_no))
SELECT CAST(COUNT(T1.report_no) AS REAL) / COUNT(T2.community_area_no) FROM Crime AS T1 INNER JOIN Community_Area AS T2 ON T1.community_area_no = T2.community_area_no WHERE T2.side = 'Central'
CREATE TABLE Community_Area ( community_area_no INTEGER primary key, community_area_name TEXT, side TEXT, population TEXT ); CREATE TABLE District ( district_no INTEGER primary key, district_name TEXT, address TEXT, zip_code INTEGER, commander TEXT, email TEXT, phone TEXT, fax TEXT, tty TEXT, twitter TEXT ); CREATE TABLE FBI_Code ( fbi_code_no TEXT primary key, title TEXT, description TEXT, crime_against TEXT ); CREATE TABLE IUCR ( iucr_no TEXT primary key, primary_description TEXT, secondary_description TEXT, index_code TEXT ); CREATE TABLE Neighborhood ( neighborhood_name TEXT primary key, community_area_no INTEGER, foreign key (community_area_no) references Community_Area(community_area_no) ); CREATE TABLE Ward ( ward_no INTEGER primary key, alderman_first_name TEXT, alderman_last_name TEXT, alderman_name_suffix TEXT, ward_office_address TEXT, ward_office_zip TEXT, ward_email TEXT, ward_office_phone TEXT, ward_office_fax TEXT, city_hall_office_room INTEGER, city_hall_office_phone TEXT, city_hall_office_fax TEXT, Population INTEGER ); CREATE TABLE Crime ( report_no INTEGER primary key, case_number TEXT, date TEXT, block TEXT, iucr_no TEXT, location_description TEXT, arrest TEXT, domestic TEXT, beat INTEGER, district_no INTEGER, ward_no INTEGER, community_area_no INTEGER, fbi_code_no TEXT, latitude TEXT, longitude TEXT, foreign key (ward_no) references Ward(ward_no), foreign key (iucr_no) references IUCR(iucr_no), foreign key (district_no) references District(district_no), foreign key (community_area_no) references Community_Area(community_area_no), foreign key (fbi_code_no) references FBI_Code(fbi_code_no) );
codebase_comments
What is the full comment on the method whose solution path is "bmatzelle_nini\Source\Nini.sln" with a tokenized name of "alias text add alias"?
SELECT T2.FullComment FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.Path = 'bmatzelle_niniSourceNini.sln' AND T2.NameTokenized = 'alias text add alias'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "Method" ( Id INTEGER not null primary key autoincrement, Name TEXT, FullComment TEXT, Summary TEXT, ApiCalls TEXT, CommentIsXml INTEGER, SampledAt INTEGER, SolutionId INTEGER, Lang TEXT, NameTokenized TEXT ); CREATE TABLE IF NOT EXISTS "MethodParameter" ( Id INTEGER not null primary key autoincrement, MethodId TEXT, Type TEXT, Name TEXT ); CREATE TABLE Repo ( Id INTEGER not null primary key autoincrement, Url TEXT, Stars INTEGER, Forks INTEGER, Watchers INTEGER, ProcessedTime INTEGER ); CREATE TABLE Solution ( Id INTEGER not null primary key autoincrement, RepoId INTEGER, Path TEXT, ProcessedTime INTEGER, WasCompiled INTEGER );
beer_factory
Which brand of root beer did Jayne Collins give the lowest rating?
brand of root beer refers to BrandName; lowest rating refers to MIN(StarRating);
SELECT T3.BrandName FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T1.First = 'Jayne' AND T1.Last = 'Collins' AND T2.StarRating = 1
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, PhoneNumber TEXT, FirstPurchaseDate DATE, SubscribedToEmailList TEXT, Gender TEXT ); CREATE TABLE geolocation ( LocationID INTEGER primary key, Latitude REAL, Longitude REAL, foreign key (LocationID) references location(LocationID) ); CREATE TABLE location ( LocationID INTEGER primary key, LocationName TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, foreign key (LocationID) references geolocation(LocationID) ); CREATE TABLE rootbeerbrand ( BrandID INTEGER primary key, BrandName TEXT, FirstBrewedYear INTEGER, BreweryName TEXT, City TEXT, State TEXT, Country TEXT, Description TEXT, CaneSugar TEXT, CornSyrup TEXT, Honey TEXT, ArtificialSweetener TEXT, Caffeinated TEXT, Alcoholic TEXT, AvailableInCans TEXT, AvailableInBottles TEXT, AvailableInKegs TEXT, Website TEXT, FacebookPage TEXT, Twitter TEXT, WholesaleCost REAL, CurrentRetailPrice REAL ); CREATE TABLE rootbeer ( RootBeerID INTEGER primary key, BrandID INTEGER, ContainerType TEXT, LocationID INTEGER, PurchaseDate DATE, foreign key (LocationID) references geolocation(LocationID), foreign key (LocationID) references location(LocationID), foreign key (BrandID) references rootbeerbrand(BrandID) ); CREATE TABLE rootbeerreview ( CustomerID INTEGER, BrandID INTEGER, StarRating INTEGER, ReviewDate DATE, Review TEXT, primary key (CustomerID, BrandID), foreign key (CustomerID) references customers(CustomerID), foreign key (BrandID) references rootbeerbrand(BrandID) ); CREATE TABLE IF NOT EXISTS "transaction" ( TransactionID INTEGER primary key, CreditCardNumber INTEGER, CustomerID INTEGER, TransactionDate DATE, CreditCardType TEXT, LocationID INTEGER, RootBeerID INTEGER, PurchasePrice REAL, foreign key (CustomerID) references customers(CustomerID), foreign key (LocationID) references location(LocationID), foreign key (RootBeerID) references rootbeer(RootBeerID) );
address
Give the alias of the cities with an Asian population of 7.
Asian population of 7 refers to asian_population = 7;
SELECT T1.alias FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.asian_population = 7
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name TEXT, CID TEXT, party TEXT, state TEXT, abbreviation TEXT, House TEXT, District INTEGER, land_area REAL, foreign key (abbreviation) references state(abbreviation) ); CREATE TABLE zip_data ( zip_code INTEGER primary key, city TEXT, state TEXT, multi_county TEXT, type TEXT, organization TEXT, time_zone TEXT, daylight_savings TEXT, latitude REAL, longitude REAL, elevation INTEGER, state_fips INTEGER, county_fips INTEGER, region TEXT, division TEXT, population_2020 INTEGER, population_2010 INTEGER, households INTEGER, avg_house_value INTEGER, avg_income_per_household INTEGER, persons_per_household REAL, white_population INTEGER, black_population INTEGER, hispanic_population INTEGER, asian_population INTEGER, american_indian_population INTEGER, hawaiian_population INTEGER, other_population INTEGER, male_population INTEGER, female_population INTEGER, median_age REAL, male_median_age REAL, female_median_age REAL, residential_mailboxes INTEGER, business_mailboxes INTEGER, total_delivery_receptacles INTEGER, businesses INTEGER, "1st_quarter_payroll" INTEGER, annual_payroll INTEGER, employees INTEGER, water_area REAL, land_area REAL, single_family_delivery_units INTEGER, multi_family_delivery_units INTEGER, total_beneficiaries INTEGER, retired_workers INTEGER, disabled_workers INTEGER, parents_and_widowed INTEGER, spouses INTEGER, children INTEGER, over_65 INTEGER, monthly_benefits_all INTEGER, monthly_benefits_retired_workers INTEGER, monthly_benefits_widowed INTEGER, CBSA INTEGER, foreign key (state) references state(abbreviation), foreign key (CBSA) references CBSA(CBSA) ); CREATE TABLE alias ( zip_code INTEGER primary key, alias TEXT, foreign key (zip_code) references zip_data(zip_code) ); CREATE TABLE area_code ( zip_code INTEGER, area_code INTEGER, primary key (zip_code, area_code), foreign key (zip_code) references zip_data(zip_code) ); CREATE TABLE avoid ( zip_code INTEGER, bad_alias TEXT, primary key (zip_code, bad_alias), foreign key (zip_code) references zip_data(zip_code) ); CREATE TABLE country ( zip_code INTEGER, county TEXT, state TEXT, primary key (zip_code, county), foreign key (zip_code) references zip_data(zip_code), foreign key (state) references state(abbreviation) ); CREATE TABLE zip_congress ( zip_code INTEGER, district TEXT, primary key (zip_code, district), foreign key (district) references congress(cognress_rep_id), foreign key (zip_code) references zip_data(zip_code) );
menu
Among the menu pages on which the dish "Paysanne Soup" had appeared, how many of them had a stable price for the dish?
Paysanne Soup is a name of dish; stable price refers to highest_price is null;
SELECT SUM(CASE WHEN T1.name = 'Paysanne Soup' THEN 1 ELSE 0 END) FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.highest_price IS NULL
CREATE TABLE Dish ( id INTEGER primary key, name TEXT, description TEXT, menus_appeared INTEGER, times_appeared INTEGER, first_appeared INTEGER, last_appeared INTEGER, lowest_price REAL, highest_price REAL ); CREATE TABLE Menu ( id INTEGER primary key, name TEXT, sponsor TEXT, event TEXT, venue TEXT, place TEXT, physical_description TEXT, occasion TEXT, notes TEXT, call_number TEXT, keywords TEXT, language TEXT, date DATE, location TEXT, location_type TEXT, currency TEXT, currency_symbol TEXT, status TEXT, page_count INTEGER, dish_count INTEGER ); CREATE TABLE MenuPage ( id INTEGER primary key, menu_id INTEGER, page_number INTEGER, image_id REAL, full_height INTEGER, full_width INTEGER, uuid TEXT, foreign key (menu_id) references Menu(id) ); CREATE TABLE MenuItem ( id INTEGER primary key, menu_page_id INTEGER, price REAL, high_price REAL, dish_id INTEGER, created_at TEXT, updated_at TEXT, xpos REAL, ypos REAL, foreign key (dish_id) references Dish(id), foreign key (menu_page_id) references MenuPage(id) );
movie_platform
What is the name of the movie whose critic received the highest amount of likes? Indicate the URL to the rating on Mubi.
critic received the highest amount of likes refers to MAX(critic_likes);
SELECT T2.movie_title, T1.rating_url FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.critic_likes DESC LIMIT 1
CREATE TABLE IF NOT EXISTS "lists" ( user_id INTEGER references lists_users (user_id), list_id INTEGER not null primary key, list_title TEXT, list_movie_number INTEGER, list_update_timestamp_utc TEXT, list_creation_timestamp_utc TEXT, list_followers INTEGER, list_url TEXT, list_comments INTEGER, list_description TEXT, list_cover_image_url TEXT, list_first_image_url TEXT, list_second_image_url TEXT, list_third_image_url TEXT ); CREATE TABLE IF NOT EXISTS "movies" ( movie_id INTEGER not null primary key, movie_title TEXT, movie_release_year INTEGER, movie_url TEXT, movie_title_language TEXT, movie_popularity INTEGER, movie_image_url TEXT, director_id TEXT, director_name TEXT, director_url TEXT ); CREATE TABLE IF NOT EXISTS "ratings_users" ( user_id INTEGER references lists_users (user_id), rating_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER ); CREATE TABLE lists_users ( user_id INTEGER not null , list_id INTEGER not null , list_update_date_utc TEXT, list_creation_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial TEXT, user_has_payment_method TEXT, primary key (user_id, list_id), foreign key (list_id) references lists(list_id), foreign key (user_id) references lists(user_id) ); CREATE TABLE ratings ( movie_id INTEGER, rating_id INTEGER, rating_url TEXT, rating_score INTEGER, rating_timestamp_utc TEXT, critic TEXT, critic_likes INTEGER, critic_comments INTEGER, user_id INTEGER, user_trialist INTEGER, user_subscriber INTEGER, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER, foreign key (movie_id) references movies(movie_id), foreign key (user_id) references lists_users(user_id), foreign key (rating_id) references ratings(rating_id), foreign key (user_id) references ratings_users(user_id) );
movie_3
Who is the manager of the store with the largest collection of films?
Who refers to first_name, last_name; the largest collection of films refers to MAX(film_id)
SELECT T.first_name, T.last_name FROM ( SELECT T3.first_name, T3.last_name, COUNT(T1.film_id) AS num FROM inventory AS T1 INNER JOIN store AS T2 ON T1.store_id = T2.store_id INNER JOIN staff AS T3 ON T2.manager_staff_id = T3.staff_id GROUP BY T3.first_name, T3.last_name ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
cookbook
How many ingredients are there in the recipe that is best in helping your body's natural defence against illness and infection?
best in helping your body's natural defence against illness and infection refers to MAX(vitamin_a);
SELECT COUNT(*) FROM Nutrition AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.vitamin_a > 0
CREATE TABLE Ingredient ( ingredient_id INTEGER primary key, category TEXT, name TEXT, plural TEXT ); CREATE TABLE Recipe ( recipe_id INTEGER primary key, title TEXT, subtitle TEXT, servings INTEGER, yield_unit TEXT, prep_min INTEGER, cook_min INTEGER, stnd_min INTEGER, source TEXT, intro TEXT, directions TEXT ); CREATE TABLE Nutrition ( recipe_id INTEGER primary key, protein REAL, carbo REAL, alcohol REAL, total_fat REAL, sat_fat REAL, cholestrl REAL, sodium REAL, iron REAL, vitamin_c REAL, vitamin_a REAL, fiber REAL, pcnt_cal_carb REAL, pcnt_cal_fat REAL, pcnt_cal_prot REAL, calories REAL, foreign key (recipe_id) references Recipe(recipe_id) ); CREATE TABLE Quantity ( quantity_id INTEGER primary key, recipe_id INTEGER, ingredient_id INTEGER, max_qty REAL, min_qty REAL, unit TEXT, preparation TEXT, optional TEXT, foreign key (recipe_id) references Recipe(recipe_id), foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id) );
video_games
How many action games are there in total?
action game refers to genre_name = 'Action'
SELECT COUNT(T1.id) FROM game AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.id WHERE T2.genre_name = 'Action'
CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE game ( id INTEGER not null primary key, genre_id INTEGER default NULL, game_name TEXT default NULL, foreign key (genre_id) references genre(id) ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL ); CREATE TABLE game_publisher ( id INTEGER not null primary key, game_id INTEGER default NULL, publisher_id INTEGER default NULL, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id) ); CREATE TABLE game_platform ( id INTEGER not null primary key, game_publisher_id INTEGER default NULL, platform_id INTEGER default NULL, release_year INTEGER default NULL, foreign key (game_publisher_id) references game_publisher(id), foreign key (platform_id) references platform(id) ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL ); CREATE TABLE region_sales ( region_id INTEGER default NULL, game_platform_id INTEGER default NULL, num_sales REAL default NULL, foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id) );
sales_in_weather
Provide the sunrise time recorded by the home weather station of store no.30 on 2014/2/21.
store no. 30 refers to store_nbr = 30; on 2014/2/21 refers to date = '2014-02-21'
SELECT T1.sunrise FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2014-02-21' AND store_nbr = 30
CREATE TABLE sales_in_weather ( date DATE, store_nbr INTEGER, item_nbr INTEGER, units INTEGER, primary key (store_nbr, date, item_nbr) ); CREATE TABLE weather ( station_nbr INTEGER, date DATE, tmax INTEGER, tmin INTEGER, tavg INTEGER, depart INTEGER, dewpoint INTEGER, wetbulb INTEGER, heat INTEGER, cool INTEGER, sunrise TEXT, sunset TEXT, codesum TEXT, snowfall REAL, preciptotal REAL, stnpressure REAL, sealevel REAL, resultspeed REAL, resultdir INTEGER, avgspeed REAL, primary key (station_nbr, date) ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr) );
sales_in_weather
Tell the wet-bulb temperature of the weather station which contained store no.6 on 2012/2/15.
store no.6 refers to store_nbr = 6; on 2012/2/15 refers to date = '2012-02-15'; wet-bulb temperature refers to wetbulb
SELECT T1.wetbulb FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 14 AND T1.`date` = '2012-02-15'
CREATE TABLE sales_in_weather ( date DATE, store_nbr INTEGER, item_nbr INTEGER, units INTEGER, primary key (store_nbr, date, item_nbr) ); CREATE TABLE weather ( station_nbr INTEGER, date DATE, tmax INTEGER, tmin INTEGER, tavg INTEGER, depart INTEGER, dewpoint INTEGER, wetbulb INTEGER, heat INTEGER, cool INTEGER, sunrise TEXT, sunset TEXT, codesum TEXT, snowfall REAL, preciptotal REAL, stnpressure REAL, sealevel REAL, resultspeed REAL, resultdir INTEGER, avgspeed REAL, primary key (station_nbr, date) ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr) );
beer_factory
What are the brands of the root beers that received 5-star ratings from no less than 5 customers?
brand of the root beer refers to BrandName; 5-star ratings refers to StarRating = 5; no less than 5 customers refers to COUNT(CustomerID) > = 5;
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 GROUP BY T2.BrandID HAVING COUNT(T2.StarRating) >= 5
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, PhoneNumber TEXT, FirstPurchaseDate DATE, SubscribedToEmailList TEXT, Gender TEXT ); CREATE TABLE geolocation ( LocationID INTEGER primary key, Latitude REAL, Longitude REAL, foreign key (LocationID) references location(LocationID) ); CREATE TABLE location ( LocationID INTEGER primary key, LocationName TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, foreign key (LocationID) references geolocation(LocationID) ); CREATE TABLE rootbeerbrand ( BrandID INTEGER primary key, BrandName TEXT, FirstBrewedYear INTEGER, BreweryName TEXT, City TEXT, State TEXT, Country TEXT, Description TEXT, CaneSugar TEXT, CornSyrup TEXT, Honey TEXT, ArtificialSweetener TEXT, Caffeinated TEXT, Alcoholic TEXT, AvailableInCans TEXT, AvailableInBottles TEXT, AvailableInKegs TEXT, Website TEXT, FacebookPage TEXT, Twitter TEXT, WholesaleCost REAL, CurrentRetailPrice REAL ); CREATE TABLE rootbeer ( RootBeerID INTEGER primary key, BrandID INTEGER, ContainerType TEXT, LocationID INTEGER, PurchaseDate DATE, foreign key (LocationID) references geolocation(LocationID), foreign key (LocationID) references location(LocationID), foreign key (BrandID) references rootbeerbrand(BrandID) ); CREATE TABLE rootbeerreview ( CustomerID INTEGER, BrandID INTEGER, StarRating INTEGER, ReviewDate DATE, Review TEXT, primary key (CustomerID, BrandID), foreign key (CustomerID) references customers(CustomerID), foreign key (BrandID) references rootbeerbrand(BrandID) ); CREATE TABLE IF NOT EXISTS "transaction" ( TransactionID INTEGER primary key, CreditCardNumber INTEGER, CustomerID INTEGER, TransactionDate DATE, CreditCardType TEXT, LocationID INTEGER, RootBeerID INTEGER, PurchasePrice REAL, foreign key (CustomerID) references customers(CustomerID), foreign key (LocationID) references location(LocationID), foreign key (RootBeerID) references rootbeer(RootBeerID) );
university
Provide the score of the most populated university in 2011.
most populated university refers to MAX(num_students); in 2011 refers to year = 2011;
SELECT T2.score FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T1.year = 2011 ORDER BY T1.num_students DESC LIMIT 1
CREATE TABLE country ( id INTEGER not null primary key, country_name TEXT default NULL ); CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, criteria_name TEXT default NULL, foreign key (ranking_system_id) references ranking_system(id) ); CREATE TABLE university ( id INTEGER not null primary key, country_id INTEGER default NULL, university_name TEXT default NULL, foreign key (country_id) references country(id) ); CREATE TABLE university_ranking_year ( university_id INTEGER default NULL, ranking_criteria_id INTEGER default NULL, year INTEGER default NULL, score INTEGER default NULL, foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id) ); CREATE TABLE university_year ( university_id INTEGER default NULL, year INTEGER default NULL, num_students INTEGER default NULL, student_staff_ratio REAL default NULL, pct_international_students INTEGER default NULL, pct_female_students INTEGER default NULL, foreign key (university_id) references university(id) );
software_company
Among the male customers with an level of education of 4 and below, list their income K.
male customers with an level of education of 4 and below refer to SEX = 'Male' where EDUCATIONNUM < 4;
SELECT INCOME_K FROM Demog WHERE GEOID IN ( SELECT GEOID FROM Customers WHERE EDUCATIONNUM < 4 AND SEX = 'Male' )
CREATE TABLE Demog ( GEOID INTEGER constraint Demog_pk primary key, INHABITANTS_K REAL, INCOME_K REAL, A_VAR1 REAL, A_VAR2 REAL, A_VAR3 REAL, A_VAR4 REAL, A_VAR5 REAL, A_VAR6 REAL, A_VAR7 REAL, A_VAR8 REAL, A_VAR9 REAL, A_VAR10 REAL, A_VAR11 REAL, A_VAR12 REAL, A_VAR13 REAL, A_VAR14 REAL, A_VAR15 REAL, A_VAR16 REAL, A_VAR17 REAL, A_VAR18 REAL ); CREATE TABLE mailings3 ( REFID INTEGER constraint mailings3_pk primary key, REF_DATE DATETIME, RESPONSE TEXT ); CREATE TABLE IF NOT EXISTS "Customers" ( ID INTEGER constraint Customers_pk primary key, SEX TEXT, MARITAL_STATUS TEXT, GEOID INTEGER constraint Customers_Demog_GEOID_fk references Demog, EDUCATIONNUM INTEGER, OCCUPATION TEXT, age INTEGER ); CREATE TABLE IF NOT EXISTS "Mailings1_2" ( REFID INTEGER constraint Mailings1_2_pk primary key constraint Mailings1_2_Customers_ID_fk references Customers, REF_DATE DATETIME, RESPONSE TEXT ); CREATE TABLE IF NOT EXISTS "Sales" ( EVENTID INTEGER constraint Sales_pk primary key, REFID INTEGER references Customers, EVENT_DATE DATETIME, AMOUNT REAL );
ice_hockey_draft
What is the weight in kilograms of the player with the highest number of goal differential of all time?
weight in kilograms refers to weight_in_kg; highest number of goal differential of all time refers to MAX(PLUSMINUS);
SELECT T3.weight_in_kg FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID INNER JOIN weight_info AS T3 ON T2.weight = T3.weight_id ORDER BY T1.PLUSMINUS DESC LIMIT 1
CREATE TABLE height_info ( height_id INTEGER primary key, height_in_cm INTEGER, height_in_inch TEXT ); CREATE TABLE weight_info ( weight_id INTEGER primary key, weight_in_kg INTEGER, weight_in_lbs INTEGER ); CREATE TABLE PlayerInfo ( ELITEID INTEGER primary key, PlayerName TEXT, birthdate TEXT, birthyear DATE, birthmonth INTEGER, birthday INTEGER, birthplace TEXT, nation TEXT, height INTEGER, weight INTEGER, position_info TEXT, shoots TEXT, draftyear INTEGER, draftround INTEGER, overall INTEGER, overallby TEXT, CSS_rank INTEGER, sum_7yr_GP INTEGER, sum_7yr_TOI INTEGER, GP_greater_than_0 TEXT, foreign key (height) references height_info(height_id), foreign key (weight) references weight_info(weight_id) ); CREATE TABLE SeasonStatus ( ELITEID INTEGER, SEASON TEXT, TEAM TEXT, LEAGUE TEXT, GAMETYPE TEXT, GP INTEGER, G INTEGER, A INTEGER, P INTEGER, PIM INTEGER, PLUSMINUS INTEGER, foreign key (ELITEID) references PlayerInfo(ELITEID) );
retail_world
List down the company names which supplied products for the order on 14th August, 1996.
products refers to Order_Details.ProductID; on 14th August, 1996 refers to OrderDate = '8/14/1996'
SELECT T1.CompanyName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID INNER JOIN Orders AS T4 ON T3.OrderID = T4.OrderID WHERE date(T4.OrderDate) = '1996-08-14'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
superstore
Which product did Phillina Ober buy?
product refers to "Product Name"
SELECT DISTINCT T3.`Product Name` FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T2.`Product ID` WHERE T1.`Customer Name` = 'Phillina Ober'
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TEXT, "Product Name" TEXT, Category TEXT, "Sub-Category" TEXT, Region TEXT, primary key ("Product ID", Region) ); CREATE TABLE central_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE east_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE south_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE west_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) );
university
Give the name of the country that has the most universities.
has the most universities refers to MAX(COUNT(id)); name of the country refers to country_name
SELECT T2.country_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id GROUP BY T2.country_name ORDER BY COUNT(T1.university_name) DESC LIMIT 1
CREATE TABLE country ( id INTEGER not null primary key, country_name TEXT default NULL ); CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, criteria_name TEXT default NULL, foreign key (ranking_system_id) references ranking_system(id) ); CREATE TABLE university ( id INTEGER not null primary key, country_id INTEGER default NULL, university_name TEXT default NULL, foreign key (country_id) references country(id) ); CREATE TABLE university_ranking_year ( university_id INTEGER default NULL, ranking_criteria_id INTEGER default NULL, year INTEGER default NULL, score INTEGER default NULL, foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id) ); CREATE TABLE university_year ( university_id INTEGER default NULL, year INTEGER default NULL, num_students INTEGER default NULL, student_staff_ratio REAL default NULL, pct_international_students INTEGER default NULL, pct_female_students INTEGER default NULL, foreign key (university_id) references university(id) );
restaurant
What is the name of the restaurant that is located in El Dorado County, Lake Tahoe region?
restaurant name refers to label
SELECT T2.label FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.region = 'lake tahoe' AND T1.county = 'el dorado county'
CREATE TABLE geographic ( city TEXT not null primary key, county TEXT null, region TEXT null ); CREATE TABLE generalinfo ( id_restaurant INTEGER not null primary key, label TEXT null, food_type TEXT null, city TEXT null, review REAL null, foreign key (city) references geographic(city) on update cascade on delete cascade ); CREATE TABLE location ( id_restaurant INTEGER not null primary key, street_num INTEGER null, street_name TEXT null, city TEXT null, foreign key (city) references geographic (city) on update cascade on delete cascade, foreign key (id_restaurant) references generalinfo (id_restaurant) on update cascade on delete cascade );
shooting
Of the black officers, how many of them investigated cases between the years 2010 and 2015?
black refers to race = 'B'; between the years 2010 and 2015 refers to date between '2010-01-01' and '2015-12-31'; case refers to case_number
SELECT COUNT(T1.case_number) FROM officers AS T1 INNER JOIN incidents AS T2 ON T2.case_number = T1.case_number WHERE T1.race = 'B' AND T2.date BETWEEN '2010-01-01' AND '2015-12-31'
CREATE TABLE incidents ( case_number TEXT not null primary key, date DATE not null, location TEXT not null, subject_statuses TEXT not null, subject_weapon TEXT not null, subjects TEXT not null, subject_count INTEGER not null, officers TEXT not null ); CREATE TABLE officers ( case_number TEXT not null, race TEXT null, gender TEXT not null, last_name TEXT not null, first_name TEXT null, full_name TEXT not null, foreign key (case_number) references incidents (case_number) ); CREATE TABLE subjects ( case_number TEXT not null, race TEXT not null, gender TEXT not null, last_name TEXT not null, first_name TEXT null, full_name TEXT not null, foreign key (case_number) references incidents (case_number) );
human_resources
In which state does Emily Wood work?
Emily Wood is the full name of an employee; full name = firstname, lastname;
SELECT T2.state FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID WHERE T1.firstname = 'Emily' AND T1.lastname = 'Wood'
CREATE TABLE location ( locationID INTEGER constraint location_pk primary key, locationcity TEXT, address TEXT, state TEXT, zipcode INTEGER, officephone TEXT ); CREATE TABLE position ( positionID INTEGER constraint position_pk primary key, positiontitle TEXT, educationrequired TEXT, minsalary TEXT, maxsalary TEXT ); CREATE TABLE employee ( ssn TEXT primary key, lastname TEXT, firstname TEXT, hiredate TEXT, salary TEXT, gender TEXT, performance TEXT, positionID INTEGER, locationID INTEGER, foreign key (locationID) references location(locationID), foreign key (positionID) references position(positionID) );
books
What is the total price of all the books ordered by Lucas Wyldbore?
total price refers to Sum(price)
SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'
CREATE TABLE address_status ( status_id INTEGER primary key, address_status TEXT ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT ); CREATE TABLE book_language ( language_id INTEGER primary key, language_code TEXT, language_name TEXT ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT ); CREATE TABLE address ( address_id INTEGER primary key, street_number TEXT, street_name TEXT, city TEXT, country_id INTEGER, foreign key (country_id) references country(country_id) ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, last_name TEXT, email TEXT ); CREATE TABLE customer_address ( customer_id INTEGER, address_id INTEGER, status_id INTEGER, primary key (customer_id, address_id), foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id) ); CREATE TABLE order_status ( status_id INTEGER primary key, status_value TEXT ); CREATE TABLE publisher ( publisher_id INTEGER primary key, publisher_name TEXT ); CREATE TABLE book ( book_id INTEGER primary key, title TEXT, isbn13 TEXT, language_id INTEGER, num_pages INTEGER, publication_date DATE, publisher_id INTEGER, foreign key (language_id) references book_language(language_id), foreign key (publisher_id) references publisher(publisher_id) ); CREATE TABLE book_author ( book_id INTEGER, author_id INTEGER, primary key (book_id, author_id), foreign key (author_id) references author(author_id), foreign key (book_id) references book(book_id) ); CREATE TABLE shipping_method ( method_id INTEGER primary key, method_name TEXT, cost REAL ); CREATE TABLE IF NOT EXISTS "cust_order" ( order_id INTEGER primary key autoincrement, order_date DATETIME, customer_id INTEGER references customer, shipping_method_id INTEGER references shipping_method, dest_address_id INTEGER references address ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "order_history" ( history_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, status_id INTEGER references order_status, status_date DATETIME ); CREATE TABLE IF NOT EXISTS "order_line" ( line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, book_id INTEGER references book, price REAL );
food_inspection_2
Write down the last name of employee who did inspection ID 52238?
SELECT T1.last_name FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T2.inspection_id = 52238
CREATE TABLE employee ( employee_id INTEGER primary key, first_name TEXT, last_name TEXT, address TEXT, city TEXT, state TEXT, zip INTEGER, phone TEXT, title TEXT, salary INTEGER, supervisor INTEGER, foreign key (supervisor) references employee(employee_id) ); CREATE TABLE establishment ( license_no INTEGER primary key, dba_name TEXT, aka_name TEXT, facility_type TEXT, risk_level INTEGER, address TEXT, city TEXT, state TEXT, zip INTEGER, latitude REAL, longitude REAL, ward INTEGER ); CREATE TABLE inspection ( inspection_id INTEGER primary key, inspection_date DATE, inspection_type TEXT, results TEXT, employee_id INTEGER, license_no INTEGER, followup_to INTEGER, foreign key (employee_id) references employee(employee_id), foreign key (license_no) references establishment(license_no), foreign key (followup_to) references inspection(inspection_id) ); CREATE TABLE inspection_point ( point_id INTEGER primary key, Description TEXT, category TEXT, code TEXT, fine INTEGER, point_level TEXT ); CREATE TABLE violation ( inspection_id INTEGER, point_id INTEGER, fine INTEGER, inspector_comment TEXT, primary key (inspection_id, point_id), foreign key (inspection_id) references inspection(inspection_id), foreign key (point_id) references inspection_point(point_id) );
image_and_language
What are the id of all the objects belonging to the transportation class?
id of all the objects belonging to the transportation class refers to OBJ_CLASS_ID and OBJ_CLASS IN ('bus', 'train', 'aeroplane', 'car', 'etc.')
SELECT OBJ_CLASS_ID FROM OBJ_CLASSES WHERE OBJ_CLASS IN ('bus', 'train', 'aeroplane', 'car', 'etc')
CREATE TABLE ATT_CLASSES ( ATT_CLASS_ID INTEGER default 0 not null primary key, ATT_CLASS TEXT not null ); CREATE TABLE OBJ_CLASSES ( OBJ_CLASS_ID INTEGER default 0 not null primary key, OBJ_CLASS TEXT not null ); CREATE TABLE IMG_OBJ ( IMG_ID INTEGER default 0 not null, OBJ_SAMPLE_ID INTEGER default 0 not null, OBJ_CLASS_ID INTEGER null, X INTEGER null, Y INTEGER null, W INTEGER null, H INTEGER null, primary key (IMG_ID, OBJ_SAMPLE_ID), foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID) ); CREATE TABLE IMG_OBJ_ATT ( IMG_ID INTEGER default 0 not null, ATT_CLASS_ID INTEGER default 0 not null, OBJ_SAMPLE_ID INTEGER default 0 not null, primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID), foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID), foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID) ); CREATE TABLE PRED_CLASSES ( PRED_CLASS_ID INTEGER default 0 not null primary key, PRED_CLASS TEXT not null ); CREATE TABLE IMG_REL ( IMG_ID INTEGER default 0 not null, PRED_CLASS_ID INTEGER default 0 not null, OBJ1_SAMPLE_ID INTEGER default 0 not null, OBJ2_SAMPLE_ID INTEGER default 0 not null, primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID), foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID), foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID), foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID) );
donor
What was the title for the project which got the biggest donation?
biggest donation refers to donation_total = 'max';
SELECT T1.title FROM essays AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T2.donation_total = ( SELECT MAX(donation_total) FROM donations )
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "essays" ( projectid TEXT, teacher_acctid TEXT, title TEXT, short_description TEXT, need_statement TEXT, essay TEXT ); CREATE TABLE IF NOT EXISTS "projects" ( projectid TEXT not null primary key, teacher_acctid TEXT, schoolid TEXT, school_ncesid TEXT, school_latitude REAL, school_longitude REAL, school_city TEXT, school_state TEXT, school_zip INTEGER, school_metro TEXT, school_district TEXT, school_county TEXT, school_charter TEXT, school_magnet TEXT, school_year_round TEXT, school_nlns TEXT, school_kipp TEXT, school_charter_ready_promise TEXT, teacher_prefix TEXT, teacher_teach_for_america TEXT, teacher_ny_teaching_fellow TEXT, primary_focus_subject TEXT, primary_focus_area TEXT, secondary_focus_subject TEXT, secondary_focus_area TEXT, resource_type TEXT, poverty_level TEXT, grade_level TEXT, fulfillment_labor_materials REAL, total_price_excluding_optional_support REAL, total_price_including_optional_support REAL, students_reached INTEGER, eligible_double_your_impact_match TEXT, eligible_almost_home_match TEXT, date_posted DATE ); CREATE TABLE donations ( donationid TEXT not null primary key, projectid TEXT, donor_acctid TEXT, donor_city TEXT, donor_state TEXT, donor_zip TEXT, is_teacher_acct TEXT, donation_timestamp DATETIME, donation_to_project REAL, donation_optional_support REAL, donation_total REAL, dollar_amount TEXT, donation_included_optional_support TEXT, payment_method TEXT, payment_included_acct_credit TEXT, payment_included_campaign_gift_card TEXT, payment_included_web_purchased_gift_card TEXT, payment_was_promo_matched TEXT, via_giving_page TEXT, for_honoree TEXT, donation_message TEXT, foreign key (projectid) references projects(projectid) ); CREATE TABLE resources ( resourceid TEXT not null primary key, projectid TEXT, vendorid INTEGER, vendor_name TEXT, project_resource_type TEXT, item_name TEXT, item_number TEXT, item_unit_price REAL, item_quantity INTEGER, foreign key (projectid) references projects(projectid) );
restaurant
How many Thai restaurants can be found in San Pablo Ave, Albany?
Thai restaurant refers to food_type = 'thai'; San Pablo Ave Albany refers to street_name = 'san pablo ave' AND T1.city = 'albany'
SELECT COUNT(T1.id_restaurant) FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.food_type = 'thai' AND T1.city = 'albany' AND T2.street_name = 'san pablo ave'
CREATE TABLE geographic ( city TEXT not null primary key, county TEXT null, region TEXT null ); CREATE TABLE generalinfo ( id_restaurant INTEGER not null primary key, label TEXT null, food_type TEXT null, city TEXT null, review REAL null, foreign key (city) references geographic(city) on update cascade on delete cascade ); CREATE TABLE location ( id_restaurant INTEGER not null primary key, street_num INTEGER null, street_name TEXT null, city TEXT null, foreign key (city) references geographic (city) on update cascade on delete cascade, foreign key (id_restaurant) references generalinfo (id_restaurant) on update cascade on delete cascade );
movie_3
What are the addresses of the inactive customers?
inactive customers refers to active = 0;
SELECT T2.address FROM customer AS T1 INNER JOIN address AS T2 ON T1.address_id = T2.address_id WHERE T1.active = 0
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
authors
What are the journal homepages and author ID of the papers published in 2000 to 2005 with a word "social" in its title?
in 2000 to 2005 refers to Year BETWEEN 2000 AND 2005; a word "social" in its title refers to Title = '%SOCIAL%'
SELECT T3.HomePage, T2.AuthorId FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId INNER JOIN Journal AS T3 ON T1.JournalId = T3.Id WHERE T1.Year BETWEEN 2000 AND 2005 AND T1.Title LIKE '%SOCIAL%'
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE IF NOT EXISTS "Journal" ( Id INTEGER constraint Journal_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE Paper ( Id INTEGER primary key, Title TEXT, Year INTEGER, ConferenceId INTEGER, JournalId INTEGER, Keyword TEXT, foreign key (ConferenceId) references Conference(Id), foreign key (JournalId) references Journal(Id) ); CREATE TABLE PaperAuthor ( PaperId INTEGER, AuthorId INTEGER, Name TEXT, Affiliation TEXT, foreign key (PaperId) references Paper(Id), foreign key (AuthorId) references Author(Id) );
codebase_comments
How many language code of method is used for the github address "https://github.com/managedfusion/managedfusion.git "?
language code of method refers to Lang; github address refers to Url; Url = 'https://github.com/managedfusion/managedfusion.git';
SELECT COUNT(DISTINCT T3.Lang) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId INNER JOIN Method AS T3 ON T2.Id = T3.SolutionId WHERE T1.Url = 'https://github.com/managedfusion/managedfusion.git'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "Method" ( Id INTEGER not null primary key autoincrement, Name TEXT, FullComment TEXT, Summary TEXT, ApiCalls TEXT, CommentIsXml INTEGER, SampledAt INTEGER, SolutionId INTEGER, Lang TEXT, NameTokenized TEXT ); CREATE TABLE IF NOT EXISTS "MethodParameter" ( Id INTEGER not null primary key autoincrement, MethodId TEXT, Type TEXT, Name TEXT ); CREATE TABLE Repo ( Id INTEGER not null primary key autoincrement, Url TEXT, Stars INTEGER, Forks INTEGER, Watchers INTEGER, ProcessedTime INTEGER ); CREATE TABLE Solution ( Id INTEGER not null primary key autoincrement, RepoId INTEGER, Path TEXT, ProcessedTime INTEGER, WasCompiled INTEGER );
video_games
How many games were released in 2001?
released in 2001 refers to release_year = 2001
SELECT COUNT(T.id) FROM game_platform AS T WHERE T.release_year = 2001
CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE game ( id INTEGER not null primary key, genre_id INTEGER default NULL, game_name TEXT default NULL, foreign key (genre_id) references genre(id) ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL ); CREATE TABLE game_publisher ( id INTEGER not null primary key, game_id INTEGER default NULL, publisher_id INTEGER default NULL, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id) ); CREATE TABLE game_platform ( id INTEGER not null primary key, game_publisher_id INTEGER default NULL, platform_id INTEGER default NULL, release_year INTEGER default NULL, foreign key (game_publisher_id) references game_publisher(id), foreign key (platform_id) references platform(id) ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL ); CREATE TABLE region_sales ( region_id INTEGER default NULL, game_platform_id INTEGER default NULL, num_sales REAL default NULL, foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id) );
movie_3
How many films have a duration between 100 to 110 minutes?
duration between 100 to 110 minutes refers to length between 100 and 110
SELECT COUNT(film_id) FROM film WHERE length BETWEEN 100 AND 110
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
retail_world
What is the category of the product that has the highest number of discontinued products?
discontinued products refers to Discontinued = 1; highest number of discontinued products refers to MAX(Discontinued = 1)
SELECT T2.CategoryName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.Discontinued = 1 GROUP BY T2.CategoryName ORDER BY COUNT(T1.ProductID) DESC LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
sales_in_weather
How many units of item no.5 were sold in store no.3 on the day in 2012 when the max temperature was the highest?
item no.5 refers to item_nbr = 5; store no. 3 refers to store_nbr = 3; when the max temperature was highest refers to Max(tmax); in 2012 refers to SUBSTR(date, 1, 4) = '2012'
SELECT T1.units FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND SUBSTR(T1.`date`, 1, 4) = '2012' AND T1.item_nbr = 5 ORDER BY tmax DESC LIMIT 1
CREATE TABLE sales_in_weather ( date DATE, store_nbr INTEGER, item_nbr INTEGER, units INTEGER, primary key (store_nbr, date, item_nbr) ); CREATE TABLE weather ( station_nbr INTEGER, date DATE, tmax INTEGER, tmin INTEGER, tavg INTEGER, depart INTEGER, dewpoint INTEGER, wetbulb INTEGER, heat INTEGER, cool INTEGER, sunrise TEXT, sunset TEXT, codesum TEXT, snowfall REAL, preciptotal REAL, stnpressure REAL, sealevel REAL, resultspeed REAL, resultdir INTEGER, avgspeed REAL, primary key (station_nbr, date) ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr) );
movie_3
How many customers rented for an above-average period?
rented period refers to SUBTRACT(return_date, rental_date); calculation = rented period > (AVG(rented period))
SELECT COUNT(customer_id) FROM rental WHERE return_date - rental_date > ( SELECT AVG(return_date - rental_date) FROM rental )
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
donor
What is the total number of students impacted by the projects with a donation from a donor with zip code "22205"?
zip code "22205" refers to donor_zip = '22205'; students impacted refers to students_reached
SELECT SUM(T2.students_reached) FROM donations AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.donor_zip = 22205
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "essays" ( projectid TEXT, teacher_acctid TEXT, title TEXT, short_description TEXT, need_statement TEXT, essay TEXT ); CREATE TABLE IF NOT EXISTS "projects" ( projectid TEXT not null primary key, teacher_acctid TEXT, schoolid TEXT, school_ncesid TEXT, school_latitude REAL, school_longitude REAL, school_city TEXT, school_state TEXT, school_zip INTEGER, school_metro TEXT, school_district TEXT, school_county TEXT, school_charter TEXT, school_magnet TEXT, school_year_round TEXT, school_nlns TEXT, school_kipp TEXT, school_charter_ready_promise TEXT, teacher_prefix TEXT, teacher_teach_for_america TEXT, teacher_ny_teaching_fellow TEXT, primary_focus_subject TEXT, primary_focus_area TEXT, secondary_focus_subject TEXT, secondary_focus_area TEXT, resource_type TEXT, poverty_level TEXT, grade_level TEXT, fulfillment_labor_materials REAL, total_price_excluding_optional_support REAL, total_price_including_optional_support REAL, students_reached INTEGER, eligible_double_your_impact_match TEXT, eligible_almost_home_match TEXT, date_posted DATE ); CREATE TABLE donations ( donationid TEXT not null primary key, projectid TEXT, donor_acctid TEXT, donor_city TEXT, donor_state TEXT, donor_zip TEXT, is_teacher_acct TEXT, donation_timestamp DATETIME, donation_to_project REAL, donation_optional_support REAL, donation_total REAL, dollar_amount TEXT, donation_included_optional_support TEXT, payment_method TEXT, payment_included_acct_credit TEXT, payment_included_campaign_gift_card TEXT, payment_included_web_purchased_gift_card TEXT, payment_was_promo_matched TEXT, via_giving_page TEXT, for_honoree TEXT, donation_message TEXT, foreign key (projectid) references projects(projectid) ); CREATE TABLE resources ( resourceid TEXT not null primary key, projectid TEXT, vendorid INTEGER, vendor_name TEXT, project_resource_type TEXT, item_name TEXT, item_number TEXT, item_unit_price REAL, item_quantity INTEGER, foreign key (projectid) references projects(projectid) );
works_cycles
Which seasonal discount had the highest discount percentage?
seasonal discount is a type of special offer; discount percentage refers to DiscountPct; highest discount percentage refers to MAX(DiscountPct);
SELECT Description FROM SpecialOffer WHERE Type = 'Seasonal Discount' ORDER BY DiscountPct DESC LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ( CultureID TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Currency ( CurrencyCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE CountryRegionCurrency ( CountryRegionCode TEXT not null, CurrencyCode TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (CountryRegionCode, CurrencyCode), foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode), foreign key (CurrencyCode) references Currency(CurrencyCode) ); CREATE TABLE Person ( BusinessEntityID INTEGER not null primary key, PersonType TEXT not null, NameStyle INTEGER default 0 not null, Title TEXT, FirstName TEXT not null, MiddleName TEXT, LastName TEXT not null, Suffix TEXT, EmailPromotion INTEGER default 0 not null, AdditionalContactInfo TEXT, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE BusinessEntityContact ( BusinessEntityID INTEGER not null, PersonID INTEGER not null, ContactTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, PersonID, ContactTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (ContactTypeID) references ContactType(ContactTypeID), foreign key (PersonID) references Person(BusinessEntityID) ); CREATE TABLE EmailAddress ( BusinessEntityID INTEGER not null, EmailAddressID INTEGER, EmailAddress TEXT, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (EmailAddressID, BusinessEntityID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Employee ( BusinessEntityID INTEGER not null primary key, NationalIDNumber TEXT not null unique, LoginID TEXT not null unique, OrganizationNode TEXT, OrganizationLevel INTEGER, JobTitle TEXT not null, BirthDate DATE not null, MaritalStatus TEXT not null, Gender TEXT not null, HireDate DATE not null, SalariedFlag INTEGER default 1 not null, VacationHours INTEGER default 0 not null, SickLeaveHours INTEGER default 0 not null, CurrentFlag INTEGER default 1 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Password ( BusinessEntityID INTEGER not null primary key, PasswordHash TEXT not null, PasswordSalt TEXT not null, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE PersonCreditCard ( BusinessEntityID INTEGER not null, CreditCardID INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, CreditCardID), foreign key (CreditCardID) references CreditCard(CreditCardID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE ProductCategory ( ProductCategoryID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductDescription ( ProductDescriptionID INTEGER primary key autoincrement, Description TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModel ( ProductModelID INTEGER primary key autoincrement, Name TEXT not null unique, CatalogDescription TEXT, Instructions TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModelProductDescriptionCulture ( ProductModelID INTEGER not null, ProductDescriptionID INTEGER not null, CultureID TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductModelID, ProductDescriptionID, CultureID), foreign key (ProductModelID) references ProductModel(ProductModelID), foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID), foreign key (CultureID) references Culture(CultureID) ); CREATE TABLE ProductPhoto ( ProductPhotoID INTEGER primary key autoincrement, ThumbNailPhoto BLOB, ThumbnailPhotoFileName TEXT, LargePhoto BLOB, LargePhotoFileName TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductSubcategory ( ProductSubcategoryID INTEGER primary key autoincrement, ProductCategoryID INTEGER not null, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID) ); CREATE TABLE SalesReason ( SalesReasonID INTEGER primary key autoincrement, Name TEXT not null, ReasonType TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SalesTerritory ( TerritoryID INTEGER primary key autoincrement, Name TEXT not null unique, CountryRegionCode TEXT not null, "Group" TEXT not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, CostYTD REAL default 0.0000 not null, CostLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode) ); CREATE TABLE SalesPerson ( BusinessEntityID INTEGER not null primary key, TerritoryID INTEGER, SalesQuota REAL, Bonus REAL default 0.0000 not null, CommissionPct REAL default 0.0000 not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references Employee(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE SalesPersonQuotaHistory ( BusinessEntityID INTEGER not null, QuotaDate DATETIME not null, SalesQuota REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, QuotaDate), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesTerritoryHistory ( BusinessEntityID INTEGER not null, TerritoryID INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, StartDate, TerritoryID), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE ScrapReason ( ScrapReasonID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE Shift ( ShiftID INTEGER primary key autoincrement, Name TEXT not null unique, StartTime TEXT not null, EndTime TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StartTime, EndTime) ); CREATE TABLE ShipMethod ( ShipMethodID INTEGER primary key autoincrement, Name TEXT not null unique, ShipBase REAL default 0.0000 not null, ShipRate REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SpecialOffer ( SpecialOfferID INTEGER primary key autoincrement, Description TEXT not null, DiscountPct REAL default 0.0000 not null, Type TEXT not null, Category TEXT not null, StartDate DATETIME not null, EndDate DATETIME not null, MinQty INTEGER default 0 not null, MaxQty INTEGER, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE BusinessEntityAddress ( BusinessEntityID INTEGER not null, AddressID INTEGER not null, AddressTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, AddressID, AddressTypeID), foreign key (AddressID) references Address(AddressID), foreign key (AddressTypeID) references AddressType(AddressTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE SalesTaxRate ( SalesTaxRateID INTEGER primary key autoincrement, StateProvinceID INTEGER not null, TaxType INTEGER not null, TaxRate REAL default 0.0000 not null, Name TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceID, TaxType), foreign key (StateProvinceID) references StateProvince(StateProvinceID) ); CREATE TABLE Store ( BusinessEntityID INTEGER not null primary key, Name TEXT not null, SalesPersonID INTEGER, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (SalesPersonID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesOrderHeaderSalesReason ( SalesOrderID INTEGER not null, SalesReasonID INTEGER not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SalesOrderID, SalesReasonID), foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SalesReasonID) references SalesReason(SalesReasonID) ); CREATE TABLE TransactionHistoryArchive ( TransactionID INTEGER not null primary key, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE UnitMeasure ( UnitMeasureCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductCostHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, StandardCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ProductDocument ( ProductID INTEGER not null, DocumentNode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, DocumentNode), foreign key (ProductID) references Product(ProductID), foreign key (DocumentNode) references Document(DocumentNode) ); CREATE TABLE ProductInventory ( ProductID INTEGER not null, LocationID INTEGER not null, Shelf TEXT not null, Bin INTEGER not null, Quantity INTEGER default 0 not null, rowguid TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, LocationID), foreign key (ProductID) references Product(ProductID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE ProductProductPhoto ( ProductID INTEGER not null, ProductPhotoID INTEGER not null, "Primary" INTEGER default 0 not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, ProductPhotoID), foreign key (ProductID) references Product(ProductID), foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID) ); CREATE TABLE ProductReview ( ProductReviewID INTEGER primary key autoincrement, ProductID INTEGER not null, ReviewerName TEXT not null, ReviewDate DATETIME default CURRENT_TIMESTAMP not null, EmailAddress TEXT not null, Rating INTEGER not null, Comments TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ShoppingCartItem ( ShoppingCartItemID INTEGER primary key autoincrement, ShoppingCartID TEXT not null, Quantity INTEGER default 1 not null, ProductID INTEGER not null, DateCreated DATETIME default CURRENT_TIMESTAMP not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SpecialOfferProduct ( SpecialOfferID INTEGER not null, ProductID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SpecialOfferID, ProductID), foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SalesOrderDetail ( SalesOrderID INTEGER not null, SalesOrderDetailID INTEGER primary key autoincrement, CarrierTrackingNumber TEXT, OrderQty INTEGER not null, ProductID INTEGER not null, SpecialOfferID INTEGER not null, UnitPrice REAL not null, UnitPriceDiscount REAL default 0.0000 not null, LineTotal REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID) ); CREATE TABLE TransactionHistory ( TransactionID INTEGER primary key autoincrement, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE Vendor ( BusinessEntityID INTEGER not null primary key, AccountNumber TEXT not null unique, Name TEXT not null, CreditRating INTEGER not null, PreferredVendorStatus INTEGER default 1 not null, ActiveFlag INTEGER default 1 not null, PurchasingWebServiceURL TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE ProductVendor ( ProductID INTEGER not null, BusinessEntityID INTEGER not null, AverageLeadTime INTEGER not null, StandardPrice REAL not null, LastReceiptCost REAL, LastReceiptDate DATETIME, MinOrderQty INTEGER not null, MaxOrderQty INTEGER not null, OnOrderQty INTEGER, UnitMeasureCode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, BusinessEntityID), foreign key (ProductID) references Product(ProductID), foreign key (BusinessEntityID) references Vendor(BusinessEntityID), foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode) ); CREATE TABLE PurchaseOrderHeader ( PurchaseOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, Status INTEGER default 1 not null, EmployeeID INTEGER not null, VendorID INTEGER not null, ShipMethodID INTEGER not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, ShipDate DATETIME, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (EmployeeID) references Employee(BusinessEntityID), foreign key (VendorID) references Vendor(BusinessEntityID), foreign key (ShipMethodID) references ShipMethod(ShipMethodID) ); CREATE TABLE PurchaseOrderDetail ( PurchaseOrderID INTEGER not null, PurchaseOrderDetailID INTEGER primary key autoincrement, DueDate DATETIME not null, OrderQty INTEGER not null, ProductID INTEGER not null, UnitPrice REAL not null, LineTotal REAL not null, ReceivedQty REAL not null, RejectedQty REAL not null, StockedQty REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE WorkOrder ( WorkOrderID INTEGER primary key autoincrement, ProductID INTEGER not null, OrderQty INTEGER not null, StockedQty INTEGER not null, ScrappedQty INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, DueDate DATETIME not null, ScrapReasonID INTEGER, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID), foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID) ); CREATE TABLE WorkOrderRouting ( WorkOrderID INTEGER not null, ProductID INTEGER not null, OperationSequence INTEGER not null, LocationID INTEGER not null, ScheduledStartDate DATETIME not null, ScheduledEndDate DATETIME not null, ActualStartDate DATETIME, ActualEndDate DATETIME, ActualResourceHrs REAL, PlannedCost REAL not null, ActualCost REAL, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (WorkOrderID, ProductID, OperationSequence), foreign key (WorkOrderID) references WorkOrder(WorkOrderID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE Customer ( CustomerID INTEGER primary key, PersonID INTEGER, StoreID INTEGER, TerritoryID INTEGER, AccountNumber TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (PersonID) references Person(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID), foreign key (StoreID) references Store(BusinessEntityID) ); CREATE TABLE ProductListPriceHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, ListPrice REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE IF NOT EXISTS "Address" ( AddressID INTEGER primary key autoincrement, AddressLine1 TEXT not null, AddressLine2 TEXT, City TEXT not null, StateProvinceID INTEGER not null references StateProvince, PostalCode TEXT not null, SpatialLocation TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode) ); CREATE TABLE IF NOT EXISTS "AddressType" ( AddressTypeID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "BillOfMaterials" ( BillOfMaterialsID INTEGER primary key autoincrement, ProductAssemblyID INTEGER references Product, ComponentID INTEGER not null references Product, StartDate DATETIME default current_timestamp not null, EndDate DATETIME, UnitMeasureCode TEXT not null references UnitMeasure, BOMLevel INTEGER not null, PerAssemblyQty REAL default 1.00 not null, ModifiedDate DATETIME default current_timestamp not null, unique (ProductAssemblyID, ComponentID, StartDate) ); CREATE TABLE IF NOT EXISTS "BusinessEntity" ( BusinessEntityID INTEGER primary key autoincrement, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "ContactType" ( ContactTypeID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "CurrencyRate" ( CurrencyRateID INTEGER primary key autoincrement, CurrencyRateDate DATETIME not null, FromCurrencyCode TEXT not null references Currency, ToCurrencyCode TEXT not null references Currency, AverageRate REAL not null, EndOfDayRate REAL not null, ModifiedDate DATETIME default current_timestamp not null, unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode) ); CREATE TABLE IF NOT EXISTS "Department" ( DepartmentID INTEGER primary key autoincrement, Name TEXT not null unique, GroupName TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory" ( BusinessEntityID INTEGER not null references Employee, DepartmentID INTEGER not null references Department, ShiftID INTEGER not null references Shift, StartDate DATE not null, EndDate DATE, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID) ); CREATE TABLE IF NOT EXISTS "EmployeePayHistory" ( BusinessEntityID INTEGER not null references Employee, RateChangeDate DATETIME not null, Rate REAL not null, PayFrequency INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, RateChangeDate) ); CREATE TABLE IF NOT EXISTS "JobCandidate" ( JobCandidateID INTEGER primary key autoincrement, BusinessEntityID INTEGER references Employee, Resume TEXT, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Location" ( LocationID INTEGER primary key autoincrement, Name TEXT not null unique, CostRate REAL default 0.0000 not null, Availability REAL default 0.00 not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "PhoneNumberType" ( PhoneNumberTypeID INTEGER primary key autoincrement, Name TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Product" ( ProductID INTEGER primary key autoincrement, Name TEXT not null unique, ProductNumber TEXT not null unique, MakeFlag INTEGER default 1 not null, FinishedGoodsFlag INTEGER default 1 not null, Color TEXT, SafetyStockLevel INTEGER not null, ReorderPoint INTEGER not null, StandardCost REAL not null, ListPrice REAL not null, Size TEXT, SizeUnitMeasureCode TEXT references UnitMeasure, WeightUnitMeasureCode TEXT references UnitMeasure, Weight REAL, DaysToManufacture INTEGER not null, ProductLine TEXT, Class TEXT, Style TEXT, ProductSubcategoryID INTEGER references ProductSubcategory, ProductModelID INTEGER references ProductModel, SellStartDate DATETIME not null, SellEndDate DATETIME, DiscontinuedDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Document" ( DocumentNode TEXT not null primary key, DocumentLevel INTEGER, Title TEXT not null, Owner INTEGER not null references Employee, FolderFlag INTEGER default 0 not null, FileName TEXT not null, FileExtension TEXT not null, Revision TEXT not null, ChangeNumber INTEGER default 0 not null, Status INTEGER not null, DocumentSummary TEXT, Document BLOB, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (DocumentLevel, DocumentNode) ); CREATE TABLE IF NOT EXISTS "StateProvince" ( StateProvinceID INTEGER primary key autoincrement, StateProvinceCode TEXT not null, CountryRegionCode TEXT not null references CountryRegion, IsOnlyStateProvinceFlag INTEGER default 1 not null, Name TEXT not null unique, TerritoryID INTEGER not null references SalesTerritory, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceCode, CountryRegionCode) ); CREATE TABLE IF NOT EXISTS "CreditCard" ( CreditCardID INTEGER primary key autoincrement, CardType TEXT not null, CardNumber TEXT not null unique, ExpMonth INTEGER not null, ExpYear INTEGER not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "SalesOrderHeader" ( SalesOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, DueDate DATETIME not null, ShipDate DATETIME, Status INTEGER default 1 not null, OnlineOrderFlag INTEGER default 1 not null, SalesOrderNumber TEXT not null unique, PurchaseOrderNumber TEXT, AccountNumber TEXT, CustomerID INTEGER not null references Customer, SalesPersonID INTEGER references SalesPerson, TerritoryID INTEGER references SalesTerritory, BillToAddressID INTEGER not null references Address, ShipToAddressID INTEGER not null references Address, ShipMethodID INTEGER not null references Address, CreditCardID INTEGER references CreditCard, CreditCardApprovalCode TEXT, CurrencyRateID INTEGER references CurrencyRate, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, Comment TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null );
chicago_crime
Who was the alderman of the legislative district where case No. JB103470 took place? Give the full name.
case No. JB103470 refers to case_number = 'JB103470'; full name refers to alderman_first_name, alderman_last_name
SELECT T1.alderman_first_name, T1.alderman_last_name FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.case_number = 'JB103470'
CREATE TABLE Community_Area ( community_area_no INTEGER primary key, community_area_name TEXT, side TEXT, population TEXT ); CREATE TABLE District ( district_no INTEGER primary key, district_name TEXT, address TEXT, zip_code INTEGER, commander TEXT, email TEXT, phone TEXT, fax TEXT, tty TEXT, twitter TEXT ); CREATE TABLE FBI_Code ( fbi_code_no TEXT primary key, title TEXT, description TEXT, crime_against TEXT ); CREATE TABLE IUCR ( iucr_no TEXT primary key, primary_description TEXT, secondary_description TEXT, index_code TEXT ); CREATE TABLE Neighborhood ( neighborhood_name TEXT primary key, community_area_no INTEGER, foreign key (community_area_no) references Community_Area(community_area_no) ); CREATE TABLE Ward ( ward_no INTEGER primary key, alderman_first_name TEXT, alderman_last_name TEXT, alderman_name_suffix TEXT, ward_office_address TEXT, ward_office_zip TEXT, ward_email TEXT, ward_office_phone TEXT, ward_office_fax TEXT, city_hall_office_room INTEGER, city_hall_office_phone TEXT, city_hall_office_fax TEXT, Population INTEGER ); CREATE TABLE Crime ( report_no INTEGER primary key, case_number TEXT, date TEXT, block TEXT, iucr_no TEXT, location_description TEXT, arrest TEXT, domestic TEXT, beat INTEGER, district_no INTEGER, ward_no INTEGER, community_area_no INTEGER, fbi_code_no TEXT, latitude TEXT, longitude TEXT, foreign key (ward_no) references Ward(ward_no), foreign key (iucr_no) references IUCR(iucr_no), foreign key (district_no) references District(district_no), foreign key (community_area_no) references Community_Area(community_area_no), foreign key (fbi_code_no) references FBI_Code(fbi_code_no) );
movies_4
How many movies released in 1995 did Quentin Tarantino appear in?
released in 1995 refers to release_date LIKE '1995%'
SELECT COUNT(T1.movie_id) FROM movie AS T1 INNER JOIN movie_cast AS T2 ON T1.movie_id = T2.movie_id INNER JOIN person AS T3 ON T2.person_id = T3.person_id WHERE T3.person_name = 'Quentin Tarantino' AND CAST(STRFTIME('%Y', T1.release_date) AS INT) = 1995
CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, country_name TEXT default NULL ); CREATE TABLE department ( department_id INTEGER not null primary key, department_name TEXT default NULL ); CREATE TABLE gender ( gender_id INTEGER not null primary key, gender TEXT default NULL ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL ); CREATE TABLE language ( language_id INTEGER not null primary key, language_code TEXT default NULL, language_name TEXT default NULL ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL ); CREATE TABLE movie ( movie_id INTEGER not null primary key, title TEXT default NULL, budget INTEGER default NULL, homepage TEXT default NULL, overview TEXT default NULL, popularity REAL default NULL, release_date DATE default NULL, revenue INTEGER default NULL, runtime INTEGER default NULL, movie_status TEXT default NULL, tagline TEXT default NULL, vote_average REAL default NULL, vote_count INTEGER default NULL ); CREATE TABLE movie_genres ( movie_id INTEGER default NULL, genre_id INTEGER default NULL, foreign key (genre_id) references genre(genre_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_languages ( movie_id INTEGER default NULL, language_id INTEGER default NULL, language_role_id INTEGER default NULL, foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), foreign key (language_role_id) references language_role(role_id) ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL ); CREATE TABLE movie_crew ( movie_id INTEGER default NULL, person_id INTEGER default NULL, department_id INTEGER default NULL, job TEXT default NULL, foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE production_company ( company_id INTEGER not null primary key, company_name TEXT default NULL ); CREATE TABLE production_country ( movie_id INTEGER default NULL, country_id INTEGER default NULL, foreign key (country_id) references country(country_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_cast ( movie_id INTEGER default NULL, person_id INTEGER default NULL, character_name TEXT default NULL, gender_id INTEGER default NULL, cast_order INTEGER default NULL, foreign key (gender_id) references gender(gender_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE IF NOT EXISTS "movie_keywords" ( movie_id INTEGER default NULL references movie, keyword_id INTEGER default NULL references keyword ); CREATE TABLE IF NOT EXISTS "movie_company" ( movie_id INTEGER default NULL references movie, company_id INTEGER default NULL references production_company );
movie_3
Mention the language of Untouchables Sunrise film and calculate its rental cost per day.
"UNTOUCHABLES SUNRISE" is the title of film; language refers to name; rental cost per day = Divide (rental_cost, rental_duration)
SELECT T2.name, T1.replacement_cost / T1.rental_duration AS cost FROM film AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'UNTOUCHABLES SUNRISE'
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
soccer_2016
What is the city of M Chinnaswamy Stadium?
city refers to City_Name; M Chinnaswamy Stadium refers to Venue_Name = 'M Chinnaswamy Stadium'
SELECT T1.City_Name FROM City AS T1 INNER JOIN Venue AS T2 ON T2.City_Id = T1.City_Id WHERE T2.Venue_Name = 'M Chinnaswamy Stadium'
CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT ); CREATE TABLE Bowling_Style ( Bowling_Id INTEGER primary key, Bowling_skill TEXT ); CREATE TABLE City ( City_Id INTEGER primary key, City_Name TEXT, Country_id INTEGER ); CREATE TABLE Country ( Country_Id INTEGER primary key, Country_Name TEXT, foreign key (Country_Id) references Country(Country_Id) ); CREATE TABLE Extra_Type ( Extra_Id INTEGER primary key, Extra_Name TEXT ); CREATE TABLE Extra_Runs ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Extra_Type_Id INTEGER, Extra_Runs INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Extra_Type_Id) references Extra_Type(Extra_Id) ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT ); CREATE TABLE Outcome ( Outcome_Id INTEGER primary key, Outcome_Type TEXT ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, DOB DATE, Batting_hand INTEGER, Bowling_skill INTEGER, Country_Name INTEGER, foreign key (Batting_hand) references Batting_Style(Batting_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), foreign key (Country_Name) references Country(Country_Id) ); CREATE TABLE Rolee ( Role_Id INTEGER primary key, Role_Desc TEXT ); CREATE TABLE Season ( Season_Id INTEGER primary key, Man_of_the_Series INTEGER, Orange_Cap INTEGER, Purple_Cap INTEGER, Season_Year INTEGER ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT ); CREATE TABLE Umpire ( Umpire_Id INTEGER primary key, Umpire_Name TEXT, Umpire_Country INTEGER, foreign key (Umpire_Country) references Country(Country_Id) ); CREATE TABLE Venue ( Venue_Id INTEGER primary key, Venue_Name TEXT, City_Id INTEGER, foreign key (City_Id) references City(City_Id) ); CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT ); CREATE TABLE Match ( Match_Id INTEGER primary key, Team_1 INTEGER, Team_2 INTEGER, Match_Date DATE, Season_Id INTEGER, Venue_Id INTEGER, Toss_Winner INTEGER, Toss_Decide INTEGER, Win_Type INTEGER, Win_Margin INTEGER, Outcome_type INTEGER, Match_Winner INTEGER, Man_of_the_Match INTEGER, foreign key (Team_1) references Team(Team_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Season_Id) references Season(Season_Id), foreign key (Venue_Id) references Venue(Venue_Id), foreign key (Toss_Winner) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Match_Winner) references Team(Team_Id), foreign key (Man_of_the_Match) references Player(Player_Id) ); CREATE TABLE Ball_by_Ball ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Innings_No INTEGER, Team_Batting INTEGER, Team_Bowling INTEGER, Striker_Batting_Position INTEGER, Striker INTEGER, Non_Striker INTEGER, Bowler INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id) ); CREATE TABLE Batsman_Scored ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Runs_Scored INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id) ); CREATE TABLE Player_Match ( Match_Id INTEGER, Player_Id INTEGER, Role_Id INTEGER, Team_Id INTEGER, primary key (Match_Id, Player_Id, Role_Id), foreign key (Match_Id) references Match(Match_Id), foreign key (Player_Id) references Player(Player_Id), foreign key (Team_Id) references Team(Team_Id), foreign key (Role_Id) references Rolee(Role_Id) ); CREATE TABLE Wicket_Taken ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Player_Out INTEGER, Kind_Out INTEGER, Fielders INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id), foreign key (Player_Out) references Player(Player_Id), foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id) );
airline
What is the code of Mississippi Valley Airlines?
Mississippi Valley Airlines refers to Description like 'Mississippi Valley Airlines%';
SELECT Code FROM `Air Carriers` WHERE Description LIKE 'Mississippi Valley Airlines%'
CREATE TABLE IF NOT EXISTS "Air Carriers" ( Code INTEGER primary key, Description TEXT ); CREATE TABLE Airports ( Code TEXT primary key, Description TEXT ); CREATE TABLE Airlines ( FL_DATE TEXT, OP_CARRIER_AIRLINE_ID INTEGER, TAIL_NUM TEXT, OP_CARRIER_FL_NUM INTEGER, ORIGIN_AIRPORT_ID INTEGER, ORIGIN_AIRPORT_SEQ_ID INTEGER, ORIGIN_CITY_MARKET_ID INTEGER, ORIGIN TEXT, DEST_AIRPORT_ID INTEGER, DEST_AIRPORT_SEQ_ID INTEGER, DEST_CITY_MARKET_ID INTEGER, DEST TEXT, CRS_DEP_TIME INTEGER, DEP_TIME INTEGER, DEP_DELAY INTEGER, DEP_DELAY_NEW INTEGER, ARR_TIME INTEGER, ARR_DELAY INTEGER, ARR_DELAY_NEW INTEGER, CANCELLED INTEGER, CANCELLATION_CODE TEXT, CRS_ELAPSED_TIME INTEGER, ACTUAL_ELAPSED_TIME INTEGER, CARRIER_DELAY INTEGER, WEATHER_DELAY INTEGER, NAS_DELAY INTEGER, SECURITY_DELAY INTEGER, LATE_AIRCRAFT_DELAY INTEGER, FOREIGN KEY (ORIGIN) REFERENCES Airports(Code), FOREIGN KEY (DEST) REFERENCES Airports(Code), FOREIGN KEY (OP_CARRIER_AIRLINE_ID) REFERENCES "Air Carriers"(Code) );
cars
How many cars with horsepower greater than 200 were produced in 1975?
horsepower greater than 200 refers to horsepower > 200; in 1975 refers to model_year = 1975
SELECT COUNT(T2.model_year) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.horsepower > 200 AND T2.model_year = 1975
CREATE TABLE country ( origin INTEGER primary key, country TEXT ); CREATE TABLE price ( ID INTEGER primary key, price REAL ); CREATE TABLE data ( ID INTEGER primary key, mpg REAL, cylinders INTEGER, displacement REAL, horsepower INTEGER, weight INTEGER, acceleration REAL, model INTEGER, car_name TEXT, foreign key (ID) references price(ID) ); CREATE TABLE production ( ID INTEGER, model_year INTEGER, country INTEGER, primary key (ID, model_year), foreign key (country) references country(origin), foreign key (ID) references data(ID), foreign key (ID) references price(ID) );
works_cycles
Among the employees who are married, how many of them have a western name style?
married refers to MaritalStatus = 'M'; western name style refers to NameStyle = '0';
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.MaritalStatus = 'M'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ( CultureID TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Currency ( CurrencyCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE CountryRegionCurrency ( CountryRegionCode TEXT not null, CurrencyCode TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (CountryRegionCode, CurrencyCode), foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode), foreign key (CurrencyCode) references Currency(CurrencyCode) ); CREATE TABLE Person ( BusinessEntityID INTEGER not null primary key, PersonType TEXT not null, NameStyle INTEGER default 0 not null, Title TEXT, FirstName TEXT not null, MiddleName TEXT, LastName TEXT not null, Suffix TEXT, EmailPromotion INTEGER default 0 not null, AdditionalContactInfo TEXT, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE BusinessEntityContact ( BusinessEntityID INTEGER not null, PersonID INTEGER not null, ContactTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, PersonID, ContactTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (ContactTypeID) references ContactType(ContactTypeID), foreign key (PersonID) references Person(BusinessEntityID) ); CREATE TABLE EmailAddress ( BusinessEntityID INTEGER not null, EmailAddressID INTEGER, EmailAddress TEXT, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (EmailAddressID, BusinessEntityID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Employee ( BusinessEntityID INTEGER not null primary key, NationalIDNumber TEXT not null unique, LoginID TEXT not null unique, OrganizationNode TEXT, OrganizationLevel INTEGER, JobTitle TEXT not null, BirthDate DATE not null, MaritalStatus TEXT not null, Gender TEXT not null, HireDate DATE not null, SalariedFlag INTEGER default 1 not null, VacationHours INTEGER default 0 not null, SickLeaveHours INTEGER default 0 not null, CurrentFlag INTEGER default 1 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Password ( BusinessEntityID INTEGER not null primary key, PasswordHash TEXT not null, PasswordSalt TEXT not null, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE PersonCreditCard ( BusinessEntityID INTEGER not null, CreditCardID INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, CreditCardID), foreign key (CreditCardID) references CreditCard(CreditCardID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE ProductCategory ( ProductCategoryID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductDescription ( ProductDescriptionID INTEGER primary key autoincrement, Description TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModel ( ProductModelID INTEGER primary key autoincrement, Name TEXT not null unique, CatalogDescription TEXT, Instructions TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModelProductDescriptionCulture ( ProductModelID INTEGER not null, ProductDescriptionID INTEGER not null, CultureID TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductModelID, ProductDescriptionID, CultureID), foreign key (ProductModelID) references ProductModel(ProductModelID), foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID), foreign key (CultureID) references Culture(CultureID) ); CREATE TABLE ProductPhoto ( ProductPhotoID INTEGER primary key autoincrement, ThumbNailPhoto BLOB, ThumbnailPhotoFileName TEXT, LargePhoto BLOB, LargePhotoFileName TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductSubcategory ( ProductSubcategoryID INTEGER primary key autoincrement, ProductCategoryID INTEGER not null, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID) ); CREATE TABLE SalesReason ( SalesReasonID INTEGER primary key autoincrement, Name TEXT not null, ReasonType TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SalesTerritory ( TerritoryID INTEGER primary key autoincrement, Name TEXT not null unique, CountryRegionCode TEXT not null, "Group" TEXT not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, CostYTD REAL default 0.0000 not null, CostLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode) ); CREATE TABLE SalesPerson ( BusinessEntityID INTEGER not null primary key, TerritoryID INTEGER, SalesQuota REAL, Bonus REAL default 0.0000 not null, CommissionPct REAL default 0.0000 not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references Employee(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE SalesPersonQuotaHistory ( BusinessEntityID INTEGER not null, QuotaDate DATETIME not null, SalesQuota REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, QuotaDate), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesTerritoryHistory ( BusinessEntityID INTEGER not null, TerritoryID INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, StartDate, TerritoryID), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE ScrapReason ( ScrapReasonID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE Shift ( ShiftID INTEGER primary key autoincrement, Name TEXT not null unique, StartTime TEXT not null, EndTime TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StartTime, EndTime) ); CREATE TABLE ShipMethod ( ShipMethodID INTEGER primary key autoincrement, Name TEXT not null unique, ShipBase REAL default 0.0000 not null, ShipRate REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SpecialOffer ( SpecialOfferID INTEGER primary key autoincrement, Description TEXT not null, DiscountPct REAL default 0.0000 not null, Type TEXT not null, Category TEXT not null, StartDate DATETIME not null, EndDate DATETIME not null, MinQty INTEGER default 0 not null, MaxQty INTEGER, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE BusinessEntityAddress ( BusinessEntityID INTEGER not null, AddressID INTEGER not null, AddressTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, AddressID, AddressTypeID), foreign key (AddressID) references Address(AddressID), foreign key (AddressTypeID) references AddressType(AddressTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE SalesTaxRate ( SalesTaxRateID INTEGER primary key autoincrement, StateProvinceID INTEGER not null, TaxType INTEGER not null, TaxRate REAL default 0.0000 not null, Name TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceID, TaxType), foreign key (StateProvinceID) references StateProvince(StateProvinceID) ); CREATE TABLE Store ( BusinessEntityID INTEGER not null primary key, Name TEXT not null, SalesPersonID INTEGER, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (SalesPersonID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesOrderHeaderSalesReason ( SalesOrderID INTEGER not null, SalesReasonID INTEGER not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SalesOrderID, SalesReasonID), foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SalesReasonID) references SalesReason(SalesReasonID) ); CREATE TABLE TransactionHistoryArchive ( TransactionID INTEGER not null primary key, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE UnitMeasure ( UnitMeasureCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductCostHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, StandardCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ProductDocument ( ProductID INTEGER not null, DocumentNode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, DocumentNode), foreign key (ProductID) references Product(ProductID), foreign key (DocumentNode) references Document(DocumentNode) ); CREATE TABLE ProductInventory ( ProductID INTEGER not null, LocationID INTEGER not null, Shelf TEXT not null, Bin INTEGER not null, Quantity INTEGER default 0 not null, rowguid TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, LocationID), foreign key (ProductID) references Product(ProductID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE ProductProductPhoto ( ProductID INTEGER not null, ProductPhotoID INTEGER not null, "Primary" INTEGER default 0 not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, ProductPhotoID), foreign key (ProductID) references Product(ProductID), foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID) ); CREATE TABLE ProductReview ( ProductReviewID INTEGER primary key autoincrement, ProductID INTEGER not null, ReviewerName TEXT not null, ReviewDate DATETIME default CURRENT_TIMESTAMP not null, EmailAddress TEXT not null, Rating INTEGER not null, Comments TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ShoppingCartItem ( ShoppingCartItemID INTEGER primary key autoincrement, ShoppingCartID TEXT not null, Quantity INTEGER default 1 not null, ProductID INTEGER not null, DateCreated DATETIME default CURRENT_TIMESTAMP not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SpecialOfferProduct ( SpecialOfferID INTEGER not null, ProductID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SpecialOfferID, ProductID), foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SalesOrderDetail ( SalesOrderID INTEGER not null, SalesOrderDetailID INTEGER primary key autoincrement, CarrierTrackingNumber TEXT, OrderQty INTEGER not null, ProductID INTEGER not null, SpecialOfferID INTEGER not null, UnitPrice REAL not null, UnitPriceDiscount REAL default 0.0000 not null, LineTotal REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID) ); CREATE TABLE TransactionHistory ( TransactionID INTEGER primary key autoincrement, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE Vendor ( BusinessEntityID INTEGER not null primary key, AccountNumber TEXT not null unique, Name TEXT not null, CreditRating INTEGER not null, PreferredVendorStatus INTEGER default 1 not null, ActiveFlag INTEGER default 1 not null, PurchasingWebServiceURL TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE ProductVendor ( ProductID INTEGER not null, BusinessEntityID INTEGER not null, AverageLeadTime INTEGER not null, StandardPrice REAL not null, LastReceiptCost REAL, LastReceiptDate DATETIME, MinOrderQty INTEGER not null, MaxOrderQty INTEGER not null, OnOrderQty INTEGER, UnitMeasureCode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, BusinessEntityID), foreign key (ProductID) references Product(ProductID), foreign key (BusinessEntityID) references Vendor(BusinessEntityID), foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode) ); CREATE TABLE PurchaseOrderHeader ( PurchaseOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, Status INTEGER default 1 not null, EmployeeID INTEGER not null, VendorID INTEGER not null, ShipMethodID INTEGER not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, ShipDate DATETIME, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (EmployeeID) references Employee(BusinessEntityID), foreign key (VendorID) references Vendor(BusinessEntityID), foreign key (ShipMethodID) references ShipMethod(ShipMethodID) ); CREATE TABLE PurchaseOrderDetail ( PurchaseOrderID INTEGER not null, PurchaseOrderDetailID INTEGER primary key autoincrement, DueDate DATETIME not null, OrderQty INTEGER not null, ProductID INTEGER not null, UnitPrice REAL not null, LineTotal REAL not null, ReceivedQty REAL not null, RejectedQty REAL not null, StockedQty REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE WorkOrder ( WorkOrderID INTEGER primary key autoincrement, ProductID INTEGER not null, OrderQty INTEGER not null, StockedQty INTEGER not null, ScrappedQty INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, DueDate DATETIME not null, ScrapReasonID INTEGER, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID), foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID) ); CREATE TABLE WorkOrderRouting ( WorkOrderID INTEGER not null, ProductID INTEGER not null, OperationSequence INTEGER not null, LocationID INTEGER not null, ScheduledStartDate DATETIME not null, ScheduledEndDate DATETIME not null, ActualStartDate DATETIME, ActualEndDate DATETIME, ActualResourceHrs REAL, PlannedCost REAL not null, ActualCost REAL, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (WorkOrderID, ProductID, OperationSequence), foreign key (WorkOrderID) references WorkOrder(WorkOrderID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE Customer ( CustomerID INTEGER primary key, PersonID INTEGER, StoreID INTEGER, TerritoryID INTEGER, AccountNumber TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (PersonID) references Person(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID), foreign key (StoreID) references Store(BusinessEntityID) ); CREATE TABLE ProductListPriceHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, ListPrice REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE IF NOT EXISTS "Address" ( AddressID INTEGER primary key autoincrement, AddressLine1 TEXT not null, AddressLine2 TEXT, City TEXT not null, StateProvinceID INTEGER not null references StateProvince, PostalCode TEXT not null, SpatialLocation TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode) ); CREATE TABLE IF NOT EXISTS "AddressType" ( AddressTypeID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "BillOfMaterials" ( BillOfMaterialsID INTEGER primary key autoincrement, ProductAssemblyID INTEGER references Product, ComponentID INTEGER not null references Product, StartDate DATETIME default current_timestamp not null, EndDate DATETIME, UnitMeasureCode TEXT not null references UnitMeasure, BOMLevel INTEGER not null, PerAssemblyQty REAL default 1.00 not null, ModifiedDate DATETIME default current_timestamp not null, unique (ProductAssemblyID, ComponentID, StartDate) ); CREATE TABLE IF NOT EXISTS "BusinessEntity" ( BusinessEntityID INTEGER primary key autoincrement, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "ContactType" ( ContactTypeID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "CurrencyRate" ( CurrencyRateID INTEGER primary key autoincrement, CurrencyRateDate DATETIME not null, FromCurrencyCode TEXT not null references Currency, ToCurrencyCode TEXT not null references Currency, AverageRate REAL not null, EndOfDayRate REAL not null, ModifiedDate DATETIME default current_timestamp not null, unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode) ); CREATE TABLE IF NOT EXISTS "Department" ( DepartmentID INTEGER primary key autoincrement, Name TEXT not null unique, GroupName TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory" ( BusinessEntityID INTEGER not null references Employee, DepartmentID INTEGER not null references Department, ShiftID INTEGER not null references Shift, StartDate DATE not null, EndDate DATE, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID) ); CREATE TABLE IF NOT EXISTS "EmployeePayHistory" ( BusinessEntityID INTEGER not null references Employee, RateChangeDate DATETIME not null, Rate REAL not null, PayFrequency INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, RateChangeDate) ); CREATE TABLE IF NOT EXISTS "JobCandidate" ( JobCandidateID INTEGER primary key autoincrement, BusinessEntityID INTEGER references Employee, Resume TEXT, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Location" ( LocationID INTEGER primary key autoincrement, Name TEXT not null unique, CostRate REAL default 0.0000 not null, Availability REAL default 0.00 not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "PhoneNumberType" ( PhoneNumberTypeID INTEGER primary key autoincrement, Name TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Product" ( ProductID INTEGER primary key autoincrement, Name TEXT not null unique, ProductNumber TEXT not null unique, MakeFlag INTEGER default 1 not null, FinishedGoodsFlag INTEGER default 1 not null, Color TEXT, SafetyStockLevel INTEGER not null, ReorderPoint INTEGER not null, StandardCost REAL not null, ListPrice REAL not null, Size TEXT, SizeUnitMeasureCode TEXT references UnitMeasure, WeightUnitMeasureCode TEXT references UnitMeasure, Weight REAL, DaysToManufacture INTEGER not null, ProductLine TEXT, Class TEXT, Style TEXT, ProductSubcategoryID INTEGER references ProductSubcategory, ProductModelID INTEGER references ProductModel, SellStartDate DATETIME not null, SellEndDate DATETIME, DiscontinuedDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Document" ( DocumentNode TEXT not null primary key, DocumentLevel INTEGER, Title TEXT not null, Owner INTEGER not null references Employee, FolderFlag INTEGER default 0 not null, FileName TEXT not null, FileExtension TEXT not null, Revision TEXT not null, ChangeNumber INTEGER default 0 not null, Status INTEGER not null, DocumentSummary TEXT, Document BLOB, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (DocumentLevel, DocumentNode) ); CREATE TABLE IF NOT EXISTS "StateProvince" ( StateProvinceID INTEGER primary key autoincrement, StateProvinceCode TEXT not null, CountryRegionCode TEXT not null references CountryRegion, IsOnlyStateProvinceFlag INTEGER default 1 not null, Name TEXT not null unique, TerritoryID INTEGER not null references SalesTerritory, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceCode, CountryRegionCode) ); CREATE TABLE IF NOT EXISTS "CreditCard" ( CreditCardID INTEGER primary key autoincrement, CardType TEXT not null, CardNumber TEXT not null unique, ExpMonth INTEGER not null, ExpYear INTEGER not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "SalesOrderHeader" ( SalesOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, DueDate DATETIME not null, ShipDate DATETIME, Status INTEGER default 1 not null, OnlineOrderFlag INTEGER default 1 not null, SalesOrderNumber TEXT not null unique, PurchaseOrderNumber TEXT, AccountNumber TEXT, CustomerID INTEGER not null references Customer, SalesPersonID INTEGER references SalesPerson, TerritoryID INTEGER references SalesTerritory, BillToAddressID INTEGER not null references Address, ShipToAddressID INTEGER not null references Address, ShipMethodID INTEGER not null references Address, CreditCardID INTEGER references CreditCard, CreditCardApprovalCode TEXT, CurrencyRateID INTEGER references CurrencyRate, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, Comment TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null );
regional_sales
Between 2018 to 2020, what is the average amount of shipped orders per year under Carl Nguyen?
shipped refers to ShipDate; between 2018 and 2020 refers to SUBSTR(ShipDate, -2) IN ('18', '19', '20'); 'Carl Nguyen' is the name of Sales Team; average shipped orders per year = Divide (Count(OrderNumber), 3)
SELECT CAST(COUNT(T1.OrderNumber) AS REAL) / 3 FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/18') OR (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/19') OR (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/20')
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT constraint Regions_pk primary key, State TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Sales Team" ( SalesTeamID INTEGER constraint "Sales Team_pk" primary key, "Sales Team" TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Store Locations" ( StoreID INTEGER constraint "Store Locations_pk" primary key, "City Name" TEXT, County TEXT, StateCode TEXT constraint "Store Locations_Regions_StateCode_fk" references Regions(StateCode), State TEXT, Type TEXT, Latitude REAL, Longitude REAL, AreaCode INTEGER, Population INTEGER, "Household Income" INTEGER, "Median Income" INTEGER, "Land Area" INTEGER, "Water Area" INTEGER, "Time Zone" TEXT ); CREATE TABLE IF NOT EXISTS "Sales Orders" ( OrderNumber TEXT constraint "Sales Orders_pk" primary key, "Sales Channel" TEXT, WarehouseCode TEXT, ProcuredDate TEXT, OrderDate TEXT, ShipDate TEXT, DeliveryDate TEXT, CurrencyCode TEXT, _SalesTeamID INTEGER constraint "Sales Orders_Sales Team_SalesTeamID_fk" references "Sales Team"(SalesTeamID), _CustomerID INTEGER constraint "Sales Orders_Customers_CustomerID_fk" references Customers(CustomerID), _StoreID INTEGER constraint "Sales Orders_Store Locations_StoreID_fk" references "Store Locations"(StoreID), _ProductID INTEGER constraint "Sales Orders_Products_ProductID_fk" references Products(ProductID), "Order Quantity" INTEGER, "Discount Applied" REAL, "Unit Price" TEXT, "Unit Cost" TEXT );
simpson_episodes
Please list the three episodes with the highest number of votes for the worst star rating.
highest number of votes refers to MAX(COUNT(votes)); worst star rating refers to stars = 1
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars = ( SELECT MIN(stars) FROM Vote ) ORDER BY T2.votes DESC LIMIT 3;
CREATE TABLE IF NOT EXISTS "Episode" ( episode_id TEXT constraint Episode_pk primary key, season INTEGER, episode INTEGER, number_in_series INTEGER, title TEXT, summary TEXT, air_date TEXT, episode_image TEXT, rating REAL, votes INTEGER ); CREATE TABLE Person ( name TEXT constraint Person_pk primary key, birthdate TEXT, birth_name TEXT, birth_place TEXT, birth_region TEXT, birth_country TEXT, height_meters REAL, nickname TEXT ); CREATE TABLE Award ( award_id INTEGER primary key, organization TEXT, year INTEGER, award_category TEXT, award TEXT, person TEXT, role TEXT, episode_id TEXT, season TEXT, song TEXT, result TEXT, foreign key (person) references Person(name), foreign key (episode_id) references Episode(episode_id) ); CREATE TABLE Character_Award ( award_id INTEGER, character TEXT, foreign key (award_id) references Award(award_id) ); CREATE TABLE Credit ( episode_id TEXT, category TEXT, person TEXT, role TEXT, credited TEXT, foreign key (episode_id) references Episode(episode_id), foreign key (person) references Person(name) ); CREATE TABLE Keyword ( episode_id TEXT, keyword TEXT, primary key (episode_id, keyword), foreign key (episode_id) references Episode(episode_id) ); CREATE TABLE Vote ( episode_id TEXT, stars INTEGER, votes INTEGER, percent REAL, foreign key (episode_id) references Episode(episode_id) );
authors
Write the titles of papers published by Adam Jones and the journal name in which it was published from 2005 to 2010.
published from 2005 to 2010 refers to Year BETWEEN 2005 AND 2010; published by Adam Jones refers to Name = 'Adam Jones'
SELECT T1.Title FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId INNER JOIN Journal AS T3 ON T1.JournalId = T3.Id WHERE T2.Name = 'Adam Jones' AND T1.Year BETWEEN 2005 AND 2010
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE IF NOT EXISTS "Journal" ( Id INTEGER constraint Journal_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE Paper ( Id INTEGER primary key, Title TEXT, Year INTEGER, ConferenceId INTEGER, JournalId INTEGER, Keyword TEXT, foreign key (ConferenceId) references Conference(Id), foreign key (JournalId) references Journal(Id) ); CREATE TABLE PaperAuthor ( PaperId INTEGER, AuthorId INTEGER, Name TEXT, Affiliation TEXT, foreign key (PaperId) references Paper(Id), foreign key (AuthorId) references Author(Id) );
books
What is the email of the customers who place their orders with priority method?
priority method refers to method_name = 'Priority'
SELECT T1.email FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T3.method_name = 'Priority'
CREATE TABLE address_status ( status_id INTEGER primary key, address_status TEXT ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT ); CREATE TABLE book_language ( language_id INTEGER primary key, language_code TEXT, language_name TEXT ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT ); CREATE TABLE address ( address_id INTEGER primary key, street_number TEXT, street_name TEXT, city TEXT, country_id INTEGER, foreign key (country_id) references country(country_id) ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, last_name TEXT, email TEXT ); CREATE TABLE customer_address ( customer_id INTEGER, address_id INTEGER, status_id INTEGER, primary key (customer_id, address_id), foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id) ); CREATE TABLE order_status ( status_id INTEGER primary key, status_value TEXT ); CREATE TABLE publisher ( publisher_id INTEGER primary key, publisher_name TEXT ); CREATE TABLE book ( book_id INTEGER primary key, title TEXT, isbn13 TEXT, language_id INTEGER, num_pages INTEGER, publication_date DATE, publisher_id INTEGER, foreign key (language_id) references book_language(language_id), foreign key (publisher_id) references publisher(publisher_id) ); CREATE TABLE book_author ( book_id INTEGER, author_id INTEGER, primary key (book_id, author_id), foreign key (author_id) references author(author_id), foreign key (book_id) references book(book_id) ); CREATE TABLE shipping_method ( method_id INTEGER primary key, method_name TEXT, cost REAL ); CREATE TABLE IF NOT EXISTS "cust_order" ( order_id INTEGER primary key autoincrement, order_date DATETIME, customer_id INTEGER references customer, shipping_method_id INTEGER references shipping_method, dest_address_id INTEGER references address ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "order_history" ( history_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, status_id INTEGER references order_status, status_date DATETIME ); CREATE TABLE IF NOT EXISTS "order_line" ( line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, book_id INTEGER references book, price REAL );
synthea
For how long did Elly Koss's cystitis last?
SUM(MULTIPLY(365, SUBTRACT(strftime('%Y', STOP), strftime('%Y', START))), MULTIPLY(30, SUBTRACT(strftime('%m', STOP), strftime('%m', START))), SUBTRACT(strftime('%d', STOP), strftime('%d', START))) where DESCRIPTION = 'Cystitis';
SELECT strftime('%J', T2.STOP) - strftime('%J', T2.START) AS days FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Cystitis'
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ); CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ); CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ); CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE IF NOT EXISTS "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER );
ice_hockey_draft
Among the players whose total NHL games played in their first 7 years of NHL career is no less than 500, what is the name of the player who committed the most rule violations?
total NHL games played in their first 7 years of NHL career is no less than 500 refers to sum_7yr_GP > 500; name of the player refers to PlayerName; committed the most rule violations refers to MAX(PIM);
SELECT T1.PlayerName FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.sum_7yr_GP > 500 ORDER BY T2.PIM DESC LIMIT 1
CREATE TABLE height_info ( height_id INTEGER primary key, height_in_cm INTEGER, height_in_inch TEXT ); CREATE TABLE weight_info ( weight_id INTEGER primary key, weight_in_kg INTEGER, weight_in_lbs INTEGER ); CREATE TABLE PlayerInfo ( ELITEID INTEGER primary key, PlayerName TEXT, birthdate TEXT, birthyear DATE, birthmonth INTEGER, birthday INTEGER, birthplace TEXT, nation TEXT, height INTEGER, weight INTEGER, position_info TEXT, shoots TEXT, draftyear INTEGER, draftround INTEGER, overall INTEGER, overallby TEXT, CSS_rank INTEGER, sum_7yr_GP INTEGER, sum_7yr_TOI INTEGER, GP_greater_than_0 TEXT, foreign key (height) references height_info(height_id), foreign key (weight) references weight_info(weight_id) ); CREATE TABLE SeasonStatus ( ELITEID INTEGER, SEASON TEXT, TEAM TEXT, LEAGUE TEXT, GAMETYPE TEXT, GP INTEGER, G INTEGER, A INTEGER, P INTEGER, PIM INTEGER, PLUSMINUS INTEGER, foreign key (ELITEID) references PlayerInfo(ELITEID) );
authors
Write down the name of authors for paper with id from 101 to 105.
paper with ID from 101 to 105 refers to Id BETWEEN 100 AND 106
SELECT T2.Name FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Id > 100 AND T1.Id < 106
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE IF NOT EXISTS "Journal" ( Id INTEGER constraint Journal_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE Paper ( Id INTEGER primary key, Title TEXT, Year INTEGER, ConferenceId INTEGER, JournalId INTEGER, Keyword TEXT, foreign key (ConferenceId) references Conference(Id), foreign key (JournalId) references Journal(Id) ); CREATE TABLE PaperAuthor ( PaperId INTEGER, AuthorId INTEGER, Name TEXT, Affiliation TEXT, foreign key (PaperId) references Paper(Id), foreign key (AuthorId) references Author(Id) );
university
How many universities have no less than 20,000 female students in 2016? Identify how many of the said universities are located in the United States of America.
have no less than 20,000 female students refers to DIVIDE(MULTIPLY(pct_female_students, num_students), 100) > 20000; in 2016 refers to year = 2016; located in the United States of America refers to country_name = 'United States of America'
SELECT COUNT(*) , SUM(CASE WHEN T3.country_name = 'United States of America' THEN 1 ELSE 0 END) AS nums_in_usa FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T2.year = 2016 AND T2.num_students * T2.pct_female_students / 100 > 20000
CREATE TABLE country ( id INTEGER not null primary key, country_name TEXT default NULL ); CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, criteria_name TEXT default NULL, foreign key (ranking_system_id) references ranking_system(id) ); CREATE TABLE university ( id INTEGER not null primary key, country_id INTEGER default NULL, university_name TEXT default NULL, foreign key (country_id) references country(id) ); CREATE TABLE university_ranking_year ( university_id INTEGER default NULL, ranking_criteria_id INTEGER default NULL, year INTEGER default NULL, score INTEGER default NULL, foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id) ); CREATE TABLE university_year ( university_id INTEGER default NULL, year INTEGER default NULL, num_students INTEGER default NULL, student_staff_ratio REAL default NULL, pct_international_students INTEGER default NULL, pct_female_students INTEGER default NULL, foreign key (university_id) references university(id) );
works_cycles
Please list any 3 vendors that are not recommended by Adventure Works.
not recommended refers to PreferredVendorStatus = 0;
SELECT Name FROM Vendor WHERE PreferredVendorStatus = 0 LIMIT 3
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ( CultureID TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Currency ( CurrencyCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE CountryRegionCurrency ( CountryRegionCode TEXT not null, CurrencyCode TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (CountryRegionCode, CurrencyCode), foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode), foreign key (CurrencyCode) references Currency(CurrencyCode) ); CREATE TABLE Person ( BusinessEntityID INTEGER not null primary key, PersonType TEXT not null, NameStyle INTEGER default 0 not null, Title TEXT, FirstName TEXT not null, MiddleName TEXT, LastName TEXT not null, Suffix TEXT, EmailPromotion INTEGER default 0 not null, AdditionalContactInfo TEXT, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE BusinessEntityContact ( BusinessEntityID INTEGER not null, PersonID INTEGER not null, ContactTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, PersonID, ContactTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (ContactTypeID) references ContactType(ContactTypeID), foreign key (PersonID) references Person(BusinessEntityID) ); CREATE TABLE EmailAddress ( BusinessEntityID INTEGER not null, EmailAddressID INTEGER, EmailAddress TEXT, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (EmailAddressID, BusinessEntityID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Employee ( BusinessEntityID INTEGER not null primary key, NationalIDNumber TEXT not null unique, LoginID TEXT not null unique, OrganizationNode TEXT, OrganizationLevel INTEGER, JobTitle TEXT not null, BirthDate DATE not null, MaritalStatus TEXT not null, Gender TEXT not null, HireDate DATE not null, SalariedFlag INTEGER default 1 not null, VacationHours INTEGER default 0 not null, SickLeaveHours INTEGER default 0 not null, CurrentFlag INTEGER default 1 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Password ( BusinessEntityID INTEGER not null primary key, PasswordHash TEXT not null, PasswordSalt TEXT not null, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE PersonCreditCard ( BusinessEntityID INTEGER not null, CreditCardID INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, CreditCardID), foreign key (CreditCardID) references CreditCard(CreditCardID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE ProductCategory ( ProductCategoryID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductDescription ( ProductDescriptionID INTEGER primary key autoincrement, Description TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModel ( ProductModelID INTEGER primary key autoincrement, Name TEXT not null unique, CatalogDescription TEXT, Instructions TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModelProductDescriptionCulture ( ProductModelID INTEGER not null, ProductDescriptionID INTEGER not null, CultureID TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductModelID, ProductDescriptionID, CultureID), foreign key (ProductModelID) references ProductModel(ProductModelID), foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID), foreign key (CultureID) references Culture(CultureID) ); CREATE TABLE ProductPhoto ( ProductPhotoID INTEGER primary key autoincrement, ThumbNailPhoto BLOB, ThumbnailPhotoFileName TEXT, LargePhoto BLOB, LargePhotoFileName TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductSubcategory ( ProductSubcategoryID INTEGER primary key autoincrement, ProductCategoryID INTEGER not null, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID) ); CREATE TABLE SalesReason ( SalesReasonID INTEGER primary key autoincrement, Name TEXT not null, ReasonType TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SalesTerritory ( TerritoryID INTEGER primary key autoincrement, Name TEXT not null unique, CountryRegionCode TEXT not null, "Group" TEXT not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, CostYTD REAL default 0.0000 not null, CostLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode) ); CREATE TABLE SalesPerson ( BusinessEntityID INTEGER not null primary key, TerritoryID INTEGER, SalesQuota REAL, Bonus REAL default 0.0000 not null, CommissionPct REAL default 0.0000 not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references Employee(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE SalesPersonQuotaHistory ( BusinessEntityID INTEGER not null, QuotaDate DATETIME not null, SalesQuota REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, QuotaDate), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesTerritoryHistory ( BusinessEntityID INTEGER not null, TerritoryID INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, StartDate, TerritoryID), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE ScrapReason ( ScrapReasonID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE Shift ( ShiftID INTEGER primary key autoincrement, Name TEXT not null unique, StartTime TEXT not null, EndTime TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StartTime, EndTime) ); CREATE TABLE ShipMethod ( ShipMethodID INTEGER primary key autoincrement, Name TEXT not null unique, ShipBase REAL default 0.0000 not null, ShipRate REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SpecialOffer ( SpecialOfferID INTEGER primary key autoincrement, Description TEXT not null, DiscountPct REAL default 0.0000 not null, Type TEXT not null, Category TEXT not null, StartDate DATETIME not null, EndDate DATETIME not null, MinQty INTEGER default 0 not null, MaxQty INTEGER, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE BusinessEntityAddress ( BusinessEntityID INTEGER not null, AddressID INTEGER not null, AddressTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, AddressID, AddressTypeID), foreign key (AddressID) references Address(AddressID), foreign key (AddressTypeID) references AddressType(AddressTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE SalesTaxRate ( SalesTaxRateID INTEGER primary key autoincrement, StateProvinceID INTEGER not null, TaxType INTEGER not null, TaxRate REAL default 0.0000 not null, Name TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceID, TaxType), foreign key (StateProvinceID) references StateProvince(StateProvinceID) ); CREATE TABLE Store ( BusinessEntityID INTEGER not null primary key, Name TEXT not null, SalesPersonID INTEGER, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (SalesPersonID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesOrderHeaderSalesReason ( SalesOrderID INTEGER not null, SalesReasonID INTEGER not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SalesOrderID, SalesReasonID), foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SalesReasonID) references SalesReason(SalesReasonID) ); CREATE TABLE TransactionHistoryArchive ( TransactionID INTEGER not null primary key, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE UnitMeasure ( UnitMeasureCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductCostHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, StandardCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ProductDocument ( ProductID INTEGER not null, DocumentNode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, DocumentNode), foreign key (ProductID) references Product(ProductID), foreign key (DocumentNode) references Document(DocumentNode) ); CREATE TABLE ProductInventory ( ProductID INTEGER not null, LocationID INTEGER not null, Shelf TEXT not null, Bin INTEGER not null, Quantity INTEGER default 0 not null, rowguid TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, LocationID), foreign key (ProductID) references Product(ProductID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE ProductProductPhoto ( ProductID INTEGER not null, ProductPhotoID INTEGER not null, "Primary" INTEGER default 0 not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, ProductPhotoID), foreign key (ProductID) references Product(ProductID), foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID) ); CREATE TABLE ProductReview ( ProductReviewID INTEGER primary key autoincrement, ProductID INTEGER not null, ReviewerName TEXT not null, ReviewDate DATETIME default CURRENT_TIMESTAMP not null, EmailAddress TEXT not null, Rating INTEGER not null, Comments TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ShoppingCartItem ( ShoppingCartItemID INTEGER primary key autoincrement, ShoppingCartID TEXT not null, Quantity INTEGER default 1 not null, ProductID INTEGER not null, DateCreated DATETIME default CURRENT_TIMESTAMP not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SpecialOfferProduct ( SpecialOfferID INTEGER not null, ProductID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SpecialOfferID, ProductID), foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SalesOrderDetail ( SalesOrderID INTEGER not null, SalesOrderDetailID INTEGER primary key autoincrement, CarrierTrackingNumber TEXT, OrderQty INTEGER not null, ProductID INTEGER not null, SpecialOfferID INTEGER not null, UnitPrice REAL not null, UnitPriceDiscount REAL default 0.0000 not null, LineTotal REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID) ); CREATE TABLE TransactionHistory ( TransactionID INTEGER primary key autoincrement, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE Vendor ( BusinessEntityID INTEGER not null primary key, AccountNumber TEXT not null unique, Name TEXT not null, CreditRating INTEGER not null, PreferredVendorStatus INTEGER default 1 not null, ActiveFlag INTEGER default 1 not null, PurchasingWebServiceURL TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE ProductVendor ( ProductID INTEGER not null, BusinessEntityID INTEGER not null, AverageLeadTime INTEGER not null, StandardPrice REAL not null, LastReceiptCost REAL, LastReceiptDate DATETIME, MinOrderQty INTEGER not null, MaxOrderQty INTEGER not null, OnOrderQty INTEGER, UnitMeasureCode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, BusinessEntityID), foreign key (ProductID) references Product(ProductID), foreign key (BusinessEntityID) references Vendor(BusinessEntityID), foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode) ); CREATE TABLE PurchaseOrderHeader ( PurchaseOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, Status INTEGER default 1 not null, EmployeeID INTEGER not null, VendorID INTEGER not null, ShipMethodID INTEGER not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, ShipDate DATETIME, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (EmployeeID) references Employee(BusinessEntityID), foreign key (VendorID) references Vendor(BusinessEntityID), foreign key (ShipMethodID) references ShipMethod(ShipMethodID) ); CREATE TABLE PurchaseOrderDetail ( PurchaseOrderID INTEGER not null, PurchaseOrderDetailID INTEGER primary key autoincrement, DueDate DATETIME not null, OrderQty INTEGER not null, ProductID INTEGER not null, UnitPrice REAL not null, LineTotal REAL not null, ReceivedQty REAL not null, RejectedQty REAL not null, StockedQty REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE WorkOrder ( WorkOrderID INTEGER primary key autoincrement, ProductID INTEGER not null, OrderQty INTEGER not null, StockedQty INTEGER not null, ScrappedQty INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, DueDate DATETIME not null, ScrapReasonID INTEGER, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID), foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID) ); CREATE TABLE WorkOrderRouting ( WorkOrderID INTEGER not null, ProductID INTEGER not null, OperationSequence INTEGER not null, LocationID INTEGER not null, ScheduledStartDate DATETIME not null, ScheduledEndDate DATETIME not null, ActualStartDate DATETIME, ActualEndDate DATETIME, ActualResourceHrs REAL, PlannedCost REAL not null, ActualCost REAL, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (WorkOrderID, ProductID, OperationSequence), foreign key (WorkOrderID) references WorkOrder(WorkOrderID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE Customer ( CustomerID INTEGER primary key, PersonID INTEGER, StoreID INTEGER, TerritoryID INTEGER, AccountNumber TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (PersonID) references Person(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID), foreign key (StoreID) references Store(BusinessEntityID) ); CREATE TABLE ProductListPriceHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, ListPrice REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE IF NOT EXISTS "Address" ( AddressID INTEGER primary key autoincrement, AddressLine1 TEXT not null, AddressLine2 TEXT, City TEXT not null, StateProvinceID INTEGER not null references StateProvince, PostalCode TEXT not null, SpatialLocation TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode) ); CREATE TABLE IF NOT EXISTS "AddressType" ( AddressTypeID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "BillOfMaterials" ( BillOfMaterialsID INTEGER primary key autoincrement, ProductAssemblyID INTEGER references Product, ComponentID INTEGER not null references Product, StartDate DATETIME default current_timestamp not null, EndDate DATETIME, UnitMeasureCode TEXT not null references UnitMeasure, BOMLevel INTEGER not null, PerAssemblyQty REAL default 1.00 not null, ModifiedDate DATETIME default current_timestamp not null, unique (ProductAssemblyID, ComponentID, StartDate) ); CREATE TABLE IF NOT EXISTS "BusinessEntity" ( BusinessEntityID INTEGER primary key autoincrement, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "ContactType" ( ContactTypeID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "CurrencyRate" ( CurrencyRateID INTEGER primary key autoincrement, CurrencyRateDate DATETIME not null, FromCurrencyCode TEXT not null references Currency, ToCurrencyCode TEXT not null references Currency, AverageRate REAL not null, EndOfDayRate REAL not null, ModifiedDate DATETIME default current_timestamp not null, unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode) ); CREATE TABLE IF NOT EXISTS "Department" ( DepartmentID INTEGER primary key autoincrement, Name TEXT not null unique, GroupName TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory" ( BusinessEntityID INTEGER not null references Employee, DepartmentID INTEGER not null references Department, ShiftID INTEGER not null references Shift, StartDate DATE not null, EndDate DATE, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID) ); CREATE TABLE IF NOT EXISTS "EmployeePayHistory" ( BusinessEntityID INTEGER not null references Employee, RateChangeDate DATETIME not null, Rate REAL not null, PayFrequency INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, RateChangeDate) ); CREATE TABLE IF NOT EXISTS "JobCandidate" ( JobCandidateID INTEGER primary key autoincrement, BusinessEntityID INTEGER references Employee, Resume TEXT, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Location" ( LocationID INTEGER primary key autoincrement, Name TEXT not null unique, CostRate REAL default 0.0000 not null, Availability REAL default 0.00 not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "PhoneNumberType" ( PhoneNumberTypeID INTEGER primary key autoincrement, Name TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Product" ( ProductID INTEGER primary key autoincrement, Name TEXT not null unique, ProductNumber TEXT not null unique, MakeFlag INTEGER default 1 not null, FinishedGoodsFlag INTEGER default 1 not null, Color TEXT, SafetyStockLevel INTEGER not null, ReorderPoint INTEGER not null, StandardCost REAL not null, ListPrice REAL not null, Size TEXT, SizeUnitMeasureCode TEXT references UnitMeasure, WeightUnitMeasureCode TEXT references UnitMeasure, Weight REAL, DaysToManufacture INTEGER not null, ProductLine TEXT, Class TEXT, Style TEXT, ProductSubcategoryID INTEGER references ProductSubcategory, ProductModelID INTEGER references ProductModel, SellStartDate DATETIME not null, SellEndDate DATETIME, DiscontinuedDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Document" ( DocumentNode TEXT not null primary key, DocumentLevel INTEGER, Title TEXT not null, Owner INTEGER not null references Employee, FolderFlag INTEGER default 0 not null, FileName TEXT not null, FileExtension TEXT not null, Revision TEXT not null, ChangeNumber INTEGER default 0 not null, Status INTEGER not null, DocumentSummary TEXT, Document BLOB, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (DocumentLevel, DocumentNode) ); CREATE TABLE IF NOT EXISTS "StateProvince" ( StateProvinceID INTEGER primary key autoincrement, StateProvinceCode TEXT not null, CountryRegionCode TEXT not null references CountryRegion, IsOnlyStateProvinceFlag INTEGER default 1 not null, Name TEXT not null unique, TerritoryID INTEGER not null references SalesTerritory, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceCode, CountryRegionCode) ); CREATE TABLE IF NOT EXISTS "CreditCard" ( CreditCardID INTEGER primary key autoincrement, CardType TEXT not null, CardNumber TEXT not null unique, ExpMonth INTEGER not null, ExpYear INTEGER not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "SalesOrderHeader" ( SalesOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, DueDate DATETIME not null, ShipDate DATETIME, Status INTEGER default 1 not null, OnlineOrderFlag INTEGER default 1 not null, SalesOrderNumber TEXT not null unique, PurchaseOrderNumber TEXT, AccountNumber TEXT, CustomerID INTEGER not null references Customer, SalesPersonID INTEGER references SalesPerson, TerritoryID INTEGER references SalesTerritory, BillToAddressID INTEGER not null references Address, ShipToAddressID INTEGER not null references Address, ShipMethodID INTEGER not null references Address, CreditCardID INTEGER references CreditCard, CreditCardApprovalCode TEXT, CurrencyRateID INTEGER references CurrencyRate, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, Comment TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null );
legislator
Current legislator Roger F. Wicker has not been a representative for how many terms?
Roger F. Wicker is an official_full_name; not a representative refers to district IS NULL OR district = ''
SELECT SUM(CASE WHEN T1.official_full_name = 'Roger F. Wicker' THEN 1 ELSE 0 END) AS count FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T2.district IS NULL OR T2.district = ''
CREATE TABLE current ( ballotpedia_id TEXT, bioguide_id TEXT, birthday_bio DATE, cspan_id REAL, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id REAL, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id INTEGER, votesmart_id REAL, wikidata_id TEXT, wikipedia_id TEXT, primary key (bioguide_id, cspan_id) ); CREATE TABLE IF NOT EXISTS "current-terms" ( address TEXT, bioguide TEXT, caucus TEXT, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, primary key (bioguide, end), foreign key (bioguide) references current(bioguide_id) ); CREATE TABLE historical ( ballotpedia_id TEXT, bioguide_id TEXT primary key, bioguide_previous_id TEXT, birthday_bio TEXT, cspan_id TEXT, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_alternate_id TEXT, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id TEXT, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id TEXT, votesmart_id TEXT, wikidata_id TEXT, wikipedia_id TEXT ); CREATE TABLE IF NOT EXISTS "historical-terms" ( address TEXT, bioguide TEXT primary key, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, middle TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, foreign key (bioguide) references historical(bioguide_id) ); CREATE TABLE IF NOT EXISTS "social-media" ( bioguide TEXT primary key, facebook TEXT, facebook_id REAL, govtrack REAL, instagram TEXT, instagram_id REAL, thomas INTEGER, twitter TEXT, twitter_id REAL, youtube TEXT, youtube_id TEXT, foreign key (bioguide) references current(bioguide_id) );
mondial_geo
What other country does the most populated nation in the world share a border with and how long is the border between the two nations?
Nation and country are synonyms
SELECT T2.Country2, T2.Length FROM country AS T1 INNER JOIN borders AS T2 ON T1.Code = T2.Country1 INNER JOIN country AS T3 ON T3.Code = T2.Country2 WHERE T1.Name = ( SELECT Name FROM country ORDER BY Population DESC LIMIT 1 )
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
retail_world
What are the products by the company "Bigfoot Breweries"?
Bigfoot Breweries is the name of the company; products refer to ProductName;
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Bigfoot Breweries'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
car_retails
What profit can the seller Carousel DieCast Legends make from the sale of the product described as "The perfect holiday or anniversary gift for executives"?
seller and product vendor are synonyms; Carousel DieCast Legends is a product vendor; profit = SUM(SUBTRACT(msrp, buyPrice));
SELECT SUM(T2.MSRP - T2.buyPrice) FROM productlines AS T1 INNER JOIN products AS T2 ON T1.productLine = T2.productLine WHERE T2.productVendor = 'Carousel DieCast Legends' AND T1.textDescription LIKE '%perfect holiday or anniversary gift for executives%'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ); CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ); CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ); CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ); CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ); CREATE TABLE IF NOT EXISTS "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) );
movie_platform
Give the url of movie which was rated 5 on 2013/5/3 5:11:17.
rated 5 refers to rating_score = 5; on 2013/5/3 5:11:17 refers to rating_timestamp_utc = '2013-05-03 05:11:17'
SELECT T2.movie_url FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE rating_score = 5 AND rating_timestamp_utc LIKE '2013-05-03 05:11:17'
CREATE TABLE IF NOT EXISTS "lists" ( user_id INTEGER references lists_users (user_id), list_id INTEGER not null primary key, list_title TEXT, list_movie_number INTEGER, list_update_timestamp_utc TEXT, list_creation_timestamp_utc TEXT, list_followers INTEGER, list_url TEXT, list_comments INTEGER, list_description TEXT, list_cover_image_url TEXT, list_first_image_url TEXT, list_second_image_url TEXT, list_third_image_url TEXT ); CREATE TABLE IF NOT EXISTS "movies" ( movie_id INTEGER not null primary key, movie_title TEXT, movie_release_year INTEGER, movie_url TEXT, movie_title_language TEXT, movie_popularity INTEGER, movie_image_url TEXT, director_id TEXT, director_name TEXT, director_url TEXT ); CREATE TABLE IF NOT EXISTS "ratings_users" ( user_id INTEGER references lists_users (user_id), rating_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER ); CREATE TABLE lists_users ( user_id INTEGER not null , list_id INTEGER not null , list_update_date_utc TEXT, list_creation_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial TEXT, user_has_payment_method TEXT, primary key (user_id, list_id), foreign key (list_id) references lists(list_id), foreign key (user_id) references lists(user_id) ); CREATE TABLE ratings ( movie_id INTEGER, rating_id INTEGER, rating_url TEXT, rating_score INTEGER, rating_timestamp_utc TEXT, critic TEXT, critic_likes INTEGER, critic_comments INTEGER, user_id INTEGER, user_trialist INTEGER, user_subscriber INTEGER, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER, foreign key (movie_id) references movies(movie_id), foreign key (user_id) references lists_users(user_id), foreign key (rating_id) references ratings(rating_id), foreign key (user_id) references ratings_users(user_id) );
retail_world
Which employee is in charge of the sales in Hollis? Please give the employee's full name.
Hollis refers to TerritoryDescription = 'Hollis'; full name = FirstName, LastName;
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T3.TerritoryDescription = 'Hollis'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
computer_student
What is the ratio of professors and students?
professors refers to professor = 1; students refers to student = 1; ratio = divide(count(person.p_id) when professor = 1, count(person.p_id) when student = 1)
SELECT CAST(SUM(CASE WHEN professor = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN student = 1 THEN 1 ELSE 0 END) AS per FROM person
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT ); CREATE TABLE person ( p_id INTEGER constraint person_pk primary key, professor INTEGER, student INTEGER, hasPosition TEXT, inPhase TEXT, yearsInProgram TEXT ); CREATE TABLE IF NOT EXISTS "advisedBy" ( p_id INTEGER, p_id_dummy INTEGER, constraint advisedBy_pk primary key (p_id, p_id_dummy), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id) ); CREATE TABLE taughtBy ( course_id INTEGER, p_id INTEGER, primary key (course_id, p_id), foreign key (p_id) references person(p_id), foreign key (course_id) references course(course_id) );
authors
From year 1991 to 2000, calculate the difference betweeen the total number of papers published under the conference "International Conference on Supercomputing " and "Informatik & Schule"?
From year 1991 to 2000 refers to Year BETWEEN 1991 AND 2000; papers refers to Paper.Id; 'International Conference on Supercomputing' AND 'Informatik & Schule' are the FullName of conference; calculate the difference between the total number of papers of these two conferences refers to SUBTRACT(SUM(Paper.Id where FullName = 'International Conference on Supercomputing'), SUM(Paper.Id where FullName = 'Informatik & Schule'))
SELECT SUM(CASE WHEN T2.FullName = 'Informatik & Schule' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.FullName = 'International Conference on Supercomputing' THEN 1 ELSE 0 END) AS DIFF FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Year > 1990 AND T1.Year < 2001
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE IF NOT EXISTS "Journal" ( Id INTEGER constraint Journal_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE Paper ( Id INTEGER primary key, Title TEXT, Year INTEGER, ConferenceId INTEGER, JournalId INTEGER, Keyword TEXT, foreign key (ConferenceId) references Conference(Id), foreign key (JournalId) references Journal(Id) ); CREATE TABLE PaperAuthor ( PaperId INTEGER, AuthorId INTEGER, Name TEXT, Affiliation TEXT, foreign key (PaperId) references Paper(Id), foreign key (AuthorId) references Author(Id) );
donor
For the donation of the project 'Awesome Audiobooks Make Avid Readers', what was the percentage of the tip in the total amount?
Awesome Audiobooks Make Avid Readers' is the title; percentage = Divie(donation_optional_support, donation_total)*100;
SELECT CAST(SUM(T2.donation_optional_support) AS REAL) * 100 / SUM(T2.donation_total) FROM essays AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.title LIKE 'Awesome Audiobooks Make Avid Readers'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "essays" ( projectid TEXT, teacher_acctid TEXT, title TEXT, short_description TEXT, need_statement TEXT, essay TEXT ); CREATE TABLE IF NOT EXISTS "projects" ( projectid TEXT not null primary key, teacher_acctid TEXT, schoolid TEXT, school_ncesid TEXT, school_latitude REAL, school_longitude REAL, school_city TEXT, school_state TEXT, school_zip INTEGER, school_metro TEXT, school_district TEXT, school_county TEXT, school_charter TEXT, school_magnet TEXT, school_year_round TEXT, school_nlns TEXT, school_kipp TEXT, school_charter_ready_promise TEXT, teacher_prefix TEXT, teacher_teach_for_america TEXT, teacher_ny_teaching_fellow TEXT, primary_focus_subject TEXT, primary_focus_area TEXT, secondary_focus_subject TEXT, secondary_focus_area TEXT, resource_type TEXT, poverty_level TEXT, grade_level TEXT, fulfillment_labor_materials REAL, total_price_excluding_optional_support REAL, total_price_including_optional_support REAL, students_reached INTEGER, eligible_double_your_impact_match TEXT, eligible_almost_home_match TEXT, date_posted DATE ); CREATE TABLE donations ( donationid TEXT not null primary key, projectid TEXT, donor_acctid TEXT, donor_city TEXT, donor_state TEXT, donor_zip TEXT, is_teacher_acct TEXT, donation_timestamp DATETIME, donation_to_project REAL, donation_optional_support REAL, donation_total REAL, dollar_amount TEXT, donation_included_optional_support TEXT, payment_method TEXT, payment_included_acct_credit TEXT, payment_included_campaign_gift_card TEXT, payment_included_web_purchased_gift_card TEXT, payment_was_promo_matched TEXT, via_giving_page TEXT, for_honoree TEXT, donation_message TEXT, foreign key (projectid) references projects(projectid) ); CREATE TABLE resources ( resourceid TEXT not null primary key, projectid TEXT, vendorid INTEGER, vendor_name TEXT, project_resource_type TEXT, item_name TEXT, item_number TEXT, item_unit_price REAL, item_quantity INTEGER, foreign key (projectid) references projects(projectid) );
synthea
What is the id of the patient who has the longest allergy period?
id of the patient refers to PATIENT from allergies where STOP is not null; the longest allergy period refers to MAX(SUBTRACT((SUBSTR(STOP, - 2, 1)! = '9' then substr(STOP, length(STOP) - 1) + 2000 end), (SUBSTR(START, - 2, 1) = '9' then substr(START, length(START) - 1) + 1900 else substr(START, length(START) - 1) + 2000 end)));
SELECT PATIENT FROM allergies WHERE STOP IS NOT NULL GROUP BY PATIENT ORDER BY CASE WHEN SUBSTR(STOP, -2, 1) != '9' THEN SUBSTR(STOP, LENGTH(STOP) - 1) + 2000 END - CASE WHEN SUBSTR(START, -2, 1) = '9' THEN SUBSTR(START, LENGTH(START) - 1) + 1900 ELSE SUBSTR(START, LENGTH(START) - 1) + 2000 END LIMIT 1
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ); CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ); CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ); CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE IF NOT EXISTS "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER );
talkingdata
How many device users are male?
male refers to gender = 'M';
SELECT COUNT(device_id) FROM gender_age WHERE gender = 'M'
CREATE TABLE `app_all` ( `app_id` INTEGER NOT NULL, PRIMARY KEY (`app_id`) ); CREATE TABLE `app_events` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_events_relevant` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER DEFAULT NULL, `is_active` INTEGER DEFAULT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_labels` ( `app_id` INTEGER NOT NULL, `label_id` INTEGER NOT NULL, FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `events` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME DEFAULT NULL, `longitude` REAL DEFAULT NULL, `latitude` REAL DEFAULT NULL, PRIMARY KEY (`event_id`) ); CREATE TABLE `events_relevant` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME NOT NULL, `longitude` REAL NOT NULL, `latitude` REAL NOT NULL, PRIMARY KEY (`event_id`), FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`), FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age_test` ( `device_id` INTEGER NOT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `gender_age_train` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `label_categories` ( `label_id` INTEGER NOT NULL, `category` TEXT DEFAULT NULL, PRIMARY KEY (`label_id`) ); CREATE TABLE `phone_brand_device_model2` ( `device_id` INTEGER NOT NULL, `phone_brand` TEXT NOT NULL, `device_model` TEXT NOT NULL, PRIMARY KEY (`device_id`,`phone_brand`,`device_model`) ); CREATE TABLE `sample_submission` ( `device_id` INTEGER NOT NULL, `F23-` REAL DEFAULT NULL, `F24-26` REAL DEFAULT NULL, `F27-28` REAL DEFAULT NULL, `F29-32` REAL DEFAULT NULL, `F33-42` REAL DEFAULT NULL, `F43+` REAL DEFAULT NULL, `M22-` REAL DEFAULT NULL, `M23-26` REAL DEFAULT NULL, `M27-28` REAL DEFAULT NULL, `M29-31` REAL DEFAULT NULL, `M32-38` REAL DEFAULT NULL, `M39+` REAL DEFAULT NULL, PRIMARY KEY (`device_id`) );
synthea
How many times did Keven Kuhn receive DTaP immunization?
DTaP immunization refers to immunizations where DESCRIPTION = 'DTaP';
SELECT COUNT(T2.CODE) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Keven' AND T1.last = 'Kuhn' AND T2.DESCRIPTION = 'DTaP'
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ); CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ); CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ); CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE IF NOT EXISTS "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER );
movie_3
Where does the staff Jon Stephens live?
location refers to address, address2, district
SELECT T1.address, T1.address2 FROM address AS T1 INNER JOIN staff AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = 'Jon' AND T2.last_name = 'Stephens'
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
regional_sales
How many orders were shipped by the sales team with the highest amount of shipped orders in 2020? Give the name of the said sales team.
shipped refers to ShipDate; in 2020 refers to SUBSTR(ShipDate, -2) = '20'; highest amount of shipped orders refers to Max(Count(OrderNumber))
SELECT COUNT(T1.OrderNumber), T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.ShipDate LIKE '%/%/20' GROUP BY T2.`Sales Team` ORDER BY COUNT(T1.OrderNumber) DESC LIMIT 1
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT constraint Regions_pk primary key, State TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Sales Team" ( SalesTeamID INTEGER constraint "Sales Team_pk" primary key, "Sales Team" TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Store Locations" ( StoreID INTEGER constraint "Store Locations_pk" primary key, "City Name" TEXT, County TEXT, StateCode TEXT constraint "Store Locations_Regions_StateCode_fk" references Regions(StateCode), State TEXT, Type TEXT, Latitude REAL, Longitude REAL, AreaCode INTEGER, Population INTEGER, "Household Income" INTEGER, "Median Income" INTEGER, "Land Area" INTEGER, "Water Area" INTEGER, "Time Zone" TEXT ); CREATE TABLE IF NOT EXISTS "Sales Orders" ( OrderNumber TEXT constraint "Sales Orders_pk" primary key, "Sales Channel" TEXT, WarehouseCode TEXT, ProcuredDate TEXT, OrderDate TEXT, ShipDate TEXT, DeliveryDate TEXT, CurrencyCode TEXT, _SalesTeamID INTEGER constraint "Sales Orders_Sales Team_SalesTeamID_fk" references "Sales Team"(SalesTeamID), _CustomerID INTEGER constraint "Sales Orders_Customers_CustomerID_fk" references Customers(CustomerID), _StoreID INTEGER constraint "Sales Orders_Store Locations_StoreID_fk" references "Store Locations"(StoreID), _ProductID INTEGER constraint "Sales Orders_Products_ProductID_fk" references Products(ProductID), "Order Quantity" INTEGER, "Discount Applied" REAL, "Unit Price" TEXT, "Unit Cost" TEXT );
app_store
Which apps have been reviewed more than 75 000 000 times and the content is suitable for teenagers?
Reviews>75000000; suitable for teenagers refers to Content Rating = 'Teen';
SELECT DISTINCT App FROM playstore WHERE Reviews > 75000000 AND `Content Rating` = 'Teen'
CREATE TABLE IF NOT EXISTS "playstore" ( App TEXT, Category TEXT, Rating REAL, Reviews INTEGER, Size TEXT, Installs TEXT, Type TEXT, Price TEXT, "Content Rating" TEXT, Genres TEXT ); CREATE TABLE IF NOT EXISTS "user_reviews" ( App TEXT references "playstore" (App), Translated_Review TEXT, Sentiment TEXT, Sentiment_Polarity TEXT, Sentiment_Subjectivity TEXT );