db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
retail_world
Among the employees working as Sales Representatives, how many of them are located in the UK?
Sales Representatives refers to Title = 'Sales Representative'; UK refers to Country = 'UK';
SELECT COUNT(Country) FROM Employees WHERE Title = 'Sales Representative' AND Country = 'UK'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
shakespeare
How many acts are there in Sonnets?
Sonnets refers to Title = 'Sonnets'
SELECT SUM(DISTINCT T2.Act) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.Title = 'Sonnets'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- ParagraphNum INTEGER not null, -- PlainText TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE works ( GenreType TEXT not null, -- Example Values: `Comedy`, `Tragedy`, `History`, `Poem`, `Sonnet` | Value Statics: Total count 43 - Distinct count 5 - Null count 0 Title TEXT not null, -- Date INTEGER not null, -- id INTEGER primary key autoincrement, LongTitle TEXT not null, -- ); CREATE TABLE chapters ( work_id INTEGER not null references works, -- Act INTEGER not null, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 945 - Distinct count 6 - Null count 0 Description TEXT not null, -- id INTEGER primary key autoincrement, Scene INTEGER not null, -- );
soccer_2016
How many times did Yuvraj Singh receive the Man of the Match award?
Yuvraj Singh refers to Player_Name = 'Yuvraj Singh'; receive the Man of the Match award refers to Player_Id = Man_of_the_Match
SELECT SUM(CASE WHEN T2.Player_Name = 'Yuvraj Singh' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_Match
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
What is the total units of products sold on the day with the highest max temperature in store no.3 in 2012?
highest max temperature refers to Max(tmax); store no.3 refers to store_nbr = 3; in 2012 refers to substring (date, 1, 4) = '2012'; total units refers to sum(units)
SELECT SUM(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 T1.`date` LIKE '%2012%' GROUP BY T3.tmax ORDER BY T3.tmax DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
retail_world
Which phone number should I call if I want to reach Nancy Davolio's home?
phone number of Nancy Davolio's home refers to HomePhone WHERE FirstName = 'Nancy' AND LastName = 'Davolio';
SELECT HomePhone FROM Employees WHERE LastName = 'Davolio' AND FirstName = 'Nancy'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
video_games
What is the ratio of game sales between North America and Japan?
ratio = DIVIDE(SUM(num_sales WHERE region_name = 'North America'), SUM(num_sales WHERE region_name = 'Japan')); North America refers to region_name = 'North America'; Japan refers to region_name = 'Japan';
SELECT SUM(CASE WHEN T2.region_name = 'North America' THEN T1.num_sales ELSE 0 END) / SUM(CASE WHEN T2.region_name = 'Japan' THEN T1.num_sales ELSE 0 END) FROM region_sales AS T1 INNER JOIN region AS T2 ON T1.region_id = T2.id
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 65320 - Distinct count 4 - Null count 0 num_sales REAL default NULL, -- game_platform_id INTEGER default NULL, -- ); CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL, -- Example Values: `Action`, `Adventure`, `Fighting`, `Misc`, `Platform` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL, -- Example Values: `North America`, `Europe`, `Japan`, `Other` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE game ( foreign key (genre_id) references genre(id), game_name TEXT default NULL, -- id INTEGER not null primary key, genre_id INTEGER default NULL, -- Example Values: `4`, `5`, `11`, `2`, `9` | Value Statics: Total count 11317 - Distinct count 12 - Null count 0 ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL, -- ); CREATE TABLE game_platform ( platform_id INTEGER default NULL, -- game_publisher_id INTEGER default NULL, -- foreign key (platform_id) references platform(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), id INTEGER not null primary key, release_year INTEGER default NULL, -- ); CREATE TABLE game_publisher ( publisher_id INTEGER default NULL, -- game_id INTEGER default NULL, -- id INTEGER not null primary key, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id), ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL, -- );
shakespeare
List the chapter ID of the works with a year greater than the 89% of average year of all listed works of Shakespeare.
a year greater than the 89% of average year refers to DATE > multiply(divide(SUM(DATE) , COUNT(DATE)), 0.89)
SELECT T2.id FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.DATE > ( SELECT AVG(DATE) FROM works ) * 0.89
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- ParagraphNum INTEGER not null, -- PlainText TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE works ( GenreType TEXT not null, -- Example Values: `Comedy`, `Tragedy`, `History`, `Poem`, `Sonnet` | Value Statics: Total count 43 - Distinct count 5 - Null count 0 Title TEXT not null, -- Date INTEGER not null, -- id INTEGER primary key autoincrement, LongTitle TEXT not null, -- ); CREATE TABLE chapters ( work_id INTEGER not null references works, -- Act INTEGER not null, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 945 - Distinct count 6 - Null count 0 Description TEXT not null, -- id INTEGER primary key autoincrement, Scene INTEGER not null, -- );
soccer_2016
From 2011 to 2012, how many Australian players became the "Man of the Match"?
From 2011 to 2012 refers to Match_Date between '2011%' and '2012%'; Australian players refers to Country_Name = 'Australia'
SELECT SUM(CASE WHEN T1.Match_Date BETWEEN '2011%' AND '2012%' THEN 1 ELSE 0 END) FROM `Match` AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_Match INNER JOIN Country AS T3 ON T3.Country_Id = T2.Country_Name WHERE T3.Country_Name = 'Australia'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
Please list the dates on which the sale of item no.5 in store no.3 exceeded 100 and the average wind speed exceeded 10.
item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; exceed 100 refers to units > 100; average wind speed exceeded 10 refers to avgspeed > 10
SELECT T1.`date` 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 T1.item_nbr = 5 AND T1.units > 100 AND T3.avgspeed > 10
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
retail_world
How much higher is the salary of Andrew Fuller than that of Nancy Davolio?
how much higher = SUBTRACT(SUM(Salary WHERE LastName = 'Fuller' and FirstName = 'Andrew'), SUM(Salary WHERE LastName = 'Davolio' and FirstName = 'Nancy'));
SELECT ( SELECT Salary FROM Employees WHERE LastName = 'Fuller' AND FirstName = 'Andrew' ) - ( SELECT Salary FROM Employees WHERE LastName = 'Davolio' AND FirstName = 'Nancy' ) AS RESULT
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
video_games
List down the name of strategy games.
strategy games refers to game_name WHERE genre_name = 'Strategy';
SELECT T1.game_name FROM game AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.id WHERE T2.genre_name = 'Strategy'
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 65320 - Distinct count 4 - Null count 0 num_sales REAL default NULL, -- game_platform_id INTEGER default NULL, -- ); CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL, -- Example Values: `Action`, `Adventure`, `Fighting`, `Misc`, `Platform` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL, -- Example Values: `North America`, `Europe`, `Japan`, `Other` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE game ( foreign key (genre_id) references genre(id), game_name TEXT default NULL, -- id INTEGER not null primary key, genre_id INTEGER default NULL, -- Example Values: `4`, `5`, `11`, `2`, `9` | Value Statics: Total count 11317 - Distinct count 12 - Null count 0 ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL, -- ); CREATE TABLE game_platform ( platform_id INTEGER default NULL, -- game_publisher_id INTEGER default NULL, -- foreign key (platform_id) references platform(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), id INTEGER not null primary key, release_year INTEGER default NULL, -- ); CREATE TABLE game_publisher ( publisher_id INTEGER default NULL, -- game_id INTEGER default NULL, -- id INTEGER not null primary key, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id), ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL, -- );
shakespeare
What is the description of the chapter where the character whose abrreviated name is 1Play appeared first?
abbreviated name is 1Play; appeared first refers to Abbrev = '1Play' and min(chapter_id)
SELECT T2.Description FROM paragraphs AS T1 INNER JOIN chapters AS T2 ON T1.chapter_id = T2.id INNER JOIN characters AS T3 ON T1.character_id = T3.id WHERE T3.Abbrev = '1Play' ORDER BY T1.chapter_id LIMIT 1
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- ParagraphNum INTEGER not null, -- PlainText TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE works ( GenreType TEXT not null, -- Example Values: `Comedy`, `Tragedy`, `History`, `Poem`, `Sonnet` | Value Statics: Total count 43 - Distinct count 5 - Null count 0 Title TEXT not null, -- Date INTEGER not null, -- id INTEGER primary key autoincrement, LongTitle TEXT not null, -- ); CREATE TABLE chapters ( work_id INTEGER not null references works, -- Act INTEGER not null, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 945 - Distinct count 6 - Null count 0 Description TEXT not null, -- id INTEGER primary key autoincrement, Scene INTEGER not null, -- );
soccer_2016
Among the South African players, how many were born before 4/11/1980?
South African players refers to Country_Name = 'South Africa'; born before 4/11/1980 refers to DOB < '1980-4-11'
SELECT SUM(CASE WHEN T1.DOB < '1980-4-11' THEN 1 ELSE 0 END) FROM Player AS T1 INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_Id WHERE T2.Country_Name = 'South Africa'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
How many units of item no.5 were sold in store no.3 in total on days with a total precipitation of over 0.05?
item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; with a total precipitation of over 0.05 refers to preciptotal > 0.05
SELECT SUM(CASE WHEN T3.preciptotal > 0.05 THEN units ELSE 0 END) AS sum 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 T1.item_nbr = 5
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
food_inspection_2
How much salary does Jessica Anthony receive?
null
SELECT salary FROM employee WHERE first_name = 'Jessica' AND last_name = 'Anthony'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER primary key, results TEXT, -- Example Values: `Pass`, `Pass w/ Conditions`, `Fail`, `Out of Business`, `Business Not Located` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 inspection_date DATE, -- inspection_type TEXT, -- ); CREATE TABLE violation ( inspector_comment TEXT, -- inspection_id INTEGER, -- foreign key (inspection_id) references inspection(inspection_id), point_id INTEGER, -- primary key (inspection_id, point_id), foreign key (point_id) references inspection_point(point_id), foreign key (point_id) references inspection_point(point_id), fine INTEGER, -- Example Values: `100`, `0`, `500`, `250` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE establishment ( facility_type TEXT, -- address TEXT, -- risk_level INTEGER, -- Example Values: `2`, `1`, `3` | Value Statics: Total count 31621 - Distinct count 3 - Null count 21 aka_name TEXT, -- state TEXT, -- Example Values: `IL` | Value Statics: Total count 31640 - Distinct count 1 - Null count 2 zip INTEGER, -- license_no INTEGER primary key, city TEXT, -- Example Values: `CHICAGO`, `Chicago`, `chicago`, `CHicago`, `MAYWOOD` | Value Statics: Total count 31593 - Distinct count 16 - Null count 49 ward INTEGER, -- longitude REAL, -- latitude REAL, -- dba_name TEXT, -- ); CREATE TABLE employee ( zip INTEGER, -- city TEXT, -- Example Values: `Chicago`, `Park Forest`, `Hoffman Estates` | Value Statics: Total count 75 - Distinct count 3 - Null count 0 phone TEXT, -- employee_id INTEGER primary key, title TEXT, -- Example Values: `Sanitarian`, `Supervisor`, `Division Manager` | Value Statics: Total count 75 - Distinct count 3 - Null count 0 first_name TEXT, -- salary INTEGER, -- address TEXT, -- supervisor INTEGER, -- Example Values: `177316`, `186742`, `179582`, `182205`, `192462` | Value Statics: Total count 75 - Distinct count 8 - Null count 0 state TEXT, -- Example Values: `IL` | Value Statics: Total count 75 - Distinct count 1 - Null count 0 last_name TEXT, -- foreign key (supervisor) references employee(employee_id), ); CREATE TABLE inspection_point ( point_id INTEGER primary key, category TEXT, -- Example Values: `Food Protection`, `Food Equipment and Utensil Sanitation`, `Wash and Waste Water Disposal`, `Toilet and Hand Washing Facilities for Staff`, `Compliance Insect and Rodent Control` | Value Statics: Total count 46 - Distinct count 14 - Null count 0 Description TEXT, -- fine INTEGER, -- Example Values: `500`, `250`, `100` | Value Statics: Total count 46 - Distinct count 3 - Null count 0 point_level TEXT, -- Example Values: `Critical`, `Serious `, `Minor ` | Value Statics: Total count 46 - Distinct count 3 - Null count 0 code TEXT, -- Example Values: `7-38-005 (B) (B-2)`, `7-38-005 (A)`, `7-38-010 (A) (B)`, `7-38-030`, `7-38-031` | Value Statics: Total count 46 - Distinct count 17 - Null count 0 );
soccer_2016
Tally the match IDs in which V Kohli is the "Man of the Match".
null
SELECT T1.Match_Id FROM `Match` AS T1 INNER JOIN Player AS T2 ON T1.Man_of_the_Match = T2.Player_Id WHERE T2.Player_Name = 'V Kohli'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
Among the days on which over 100 units of item no.5 were sold in store no.3, on which date was the temperature range the biggest?
over 100 units refers to units > 100; item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; the temperature range was the biggest refers to Max(Subtract(tmax, tmin))
SELECT T2.`date` FROM relation AS T1 INNER JOIN sales_in_weather AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T1.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T2.item_nbr = 5 AND T2.units > 100 ORDER BY tmax - tmin DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
retail_world
The sales of how many territories is Nancy Davolio in charge of?
null
SELECT COUNT(T2.TerritoryID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Nancy' AND T1.LastName = 'Davolio'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
video_games
What is the genre of the game ID 119?
genre of the game refers to genre_name; game ID 119 refers to game.id = 119;
SELECT T2.genre_name FROM game AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.id WHERE T1.id = 119
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 65320 - Distinct count 4 - Null count 0 num_sales REAL default NULL, -- game_platform_id INTEGER default NULL, -- ); CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL, -- Example Values: `Action`, `Adventure`, `Fighting`, `Misc`, `Platform` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL, -- Example Values: `North America`, `Europe`, `Japan`, `Other` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE game ( foreign key (genre_id) references genre(id), game_name TEXT default NULL, -- id INTEGER not null primary key, genre_id INTEGER default NULL, -- Example Values: `4`, `5`, `11`, `2`, `9` | Value Statics: Total count 11317 - Distinct count 12 - Null count 0 ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL, -- ); CREATE TABLE game_platform ( platform_id INTEGER default NULL, -- game_publisher_id INTEGER default NULL, -- foreign key (platform_id) references platform(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), id INTEGER not null primary key, release_year INTEGER default NULL, -- ); CREATE TABLE game_publisher ( publisher_id INTEGER default NULL, -- game_id INTEGER default NULL, -- id INTEGER not null primary key, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id), ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL, -- );
soccer_2016
When did the Sunrisers Hyderabad win their first match?
Sunrisers Hyderabad refers to Team_Name = 'Sunrisers Hyderabad'; win their first match refers to Match_Winner and min(Match_Date)
SELECT T1.Match_Date FROM `Match` AS T1 INNER JOIN Team AS T2 ON T1.Match_Winner = T2.Team_Id WHERE T2.Team_Name = 'Sunrisers Hyderabad'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
How many units of item no.5 were sold in store no.3 on the day the temperature range was the biggest?
item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; when the temperature range was the biggest refers to Max(Subtract(tmax, tmin))
SELECT t2.units FROM relation AS T1 INNER JOIN sales_in_weather AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T1.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T2.item_nbr = 5 ORDER BY t3.tmax - t3.tmin DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
retail_world
Which employee has the highest salary? Please give his or her full name.
highest salary refers to MAX(Salary); full name = FirstName, LastName;
SELECT FirstName, LastName FROM Employees WHERE Salary = ( SELECT MAX(Salary) FROM Employees )
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
olympics
What is Vijay Singh Chauhan's region name?
null
SELECT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Vijay Singh Chauhan'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE games_city ( city_id INTEGER default NULL, -- foreign key (games_id) references games(id), games_id INTEGER default NULL, -- foreign key (city_id) references city(id), ); CREATE TABLE competitor_event ( foreign key (event_id) references event(id), foreign key (competitor_id) references games_competitor(id), foreign key (competitor_id) references games_competitor(id), foreign key (medal_id) references medal(id), medal_id INTEGER default NULL, -- Example Values: `4`, `1`, `3`, `2` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 event_id INTEGER default NULL, -- competitor_id INTEGER default NULL, -- ); CREATE TABLE person ( weight INTEGER default NULL, -- height INTEGER default NULL, -- id INTEGER not null primary key, full_name TEXT default NULL, -- gender TEXT default NULL, -- Example Values: `M`, `F` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE noc_region ( region_name TEXT default NULL, -- id INTEGER not null primary key, noc TEXT default NULL, -- ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL, -- Example Values: `Gold`, `Silver`, `Bronze`, `NA` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE person_region ( foreign key (region_id) references noc_region(id), region_id INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- ); CREATE TABLE games ( season TEXT default NULL, -- Example Values: `Summer`, `Winter` | Value Statics: Total count 51 - Distinct count 2 - Null count 0 id INTEGER not null primary key, games_name TEXT default NULL, -- games_year INTEGER default NULL, -- ); CREATE TABLE games_competitor ( id INTEGER not null primary key, foreign key (games_id) references games(id), games_id INTEGER default NULL, -- age INTEGER default NULL, -- foreign key (person_id) references person(id), person_id INTEGER default NULL, -- );
shakespeare
In Shakespeare's works before 1600, list down the title of the tragic story he had written that involved a character named "Tybalt".
works before 1600 refers to DATE < 1600; tragic story refers to GenreType = 'Tragedy'; character named "Tybalt" refers to CharName = 'Tybalt'
SELECT DISTINCT T1.title FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.DATE < 1600 AND T1.GenreType = 'Tragedy' AND T4.CharName = 'Tybalt'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- ParagraphNum INTEGER not null, -- PlainText TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE works ( GenreType TEXT not null, -- Example Values: `Comedy`, `Tragedy`, `History`, `Poem`, `Sonnet` | Value Statics: Total count 43 - Distinct count 5 - Null count 0 Title TEXT not null, -- Date INTEGER not null, -- id INTEGER primary key autoincrement, LongTitle TEXT not null, -- ); CREATE TABLE chapters ( work_id INTEGER not null references works, -- Act INTEGER not null, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 945 - Distinct count 6 - Null count 0 Description TEXT not null, -- id INTEGER primary key autoincrement, Scene INTEGER not null, -- );
soccer_2016
When and for what role did the youngest player appear in his first match?
When refers to Match_Date; youngest player refers to max(DOB); first match refers to min(Match_Date)
SELECT T1.Match_Date, T4.Role_Desc FROM `Match` AS T1 INNER JOIN Player_Match AS T2 ON T1.Match_Id = T2.Match_Id INNER JOIN Player AS T3 ON T2.Player_Id = T3.Player_Id INNER JOIN Rolee AS T4 ON T2.Role_Id = T4.Role_Id ORDER BY T3.DOB DESC LIMIT 1
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
On how many days with the max temperature over 90 did the sale of item no.5 in store no.3 exceed 100?
max temperature over 90 refers to tmax > 90; item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; sale exceed 100 refers to units > 100; number of days refers to count (date)
SELECT SUM(CASE WHEN units > 100 THEN 1 ELSE 0 END) AS count 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 AND tmax > 90
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
retail_world
The sales of how many territories in total do the employees in London take charge of?
London refers to city = 'London';
SELECT COUNT(T2.TerritoryID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.City = 'London'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
video_games
Give the genre of the following game titled 'Airlock' , 'Airline Tycoon' , and 'Airblade', respectively.
genre refers to genre_name; 'Airlock', 'Airline Tycoon' , and 'Airblade' refers to game_name IN ('Airlock', 'Airline Tycoon', 'Airblade');
SELECT T2.genre_name FROM game AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.id WHERE T1.game_name IN ('Airlock', 'Airline Tycoon', 'Airblade')
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 65320 - Distinct count 4 - Null count 0 num_sales REAL default NULL, -- game_platform_id INTEGER default NULL, -- ); CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL, -- Example Values: `Action`, `Adventure`, `Fighting`, `Misc`, `Platform` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL, -- Example Values: `North America`, `Europe`, `Japan`, `Other` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE game ( foreign key (genre_id) references genre(id), game_name TEXT default NULL, -- id INTEGER not null primary key, genre_id INTEGER default NULL, -- Example Values: `4`, `5`, `11`, `2`, `9` | Value Statics: Total count 11317 - Distinct count 12 - Null count 0 ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL, -- ); CREATE TABLE game_platform ( platform_id INTEGER default NULL, -- game_publisher_id INTEGER default NULL, -- foreign key (platform_id) references platform(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), id INTEGER not null primary key, release_year INTEGER default NULL, -- ); CREATE TABLE game_publisher ( publisher_id INTEGER default NULL, -- game_id INTEGER default NULL, -- id INTEGER not null primary key, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id), ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL, -- );
soccer_2016
Who among the players won both "Man of the Series" and "Orange Cap" in the same season?
Who refers to Player_Name;
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Season AS T2 ON T1.Player_Id = T2.Man_of_the_Series = T2.Orange_Cap
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
What was the dew point on the day the most units of item no.5 were sold in store no.3 in 2012?
item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; in 2012 refers to SUBSTR(date, 1, 4) = '2012': most units sold refers to Max(units)
SELECT dewpoint 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 units DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
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 Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
shakespeare
How many paragraphs are there in "Ay, surely, mere the truth: I know his lady."?
"Ay, surely, mere the truth: I know his lady." refers to PlainText = 'Ay, surely, mere the truth: I know his lady.'
SELECT ParagraphNum FROM paragraphs WHERE PlainText = 'Ay, surely, mere the truth: I know his lady.'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- ParagraphNum INTEGER not null, -- PlainText TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE works ( GenreType TEXT not null, -- Example Values: `Comedy`, `Tragedy`, `History`, `Poem`, `Sonnet` | Value Statics: Total count 43 - Distinct count 5 - Null count 0 Title TEXT not null, -- Date INTEGER not null, -- id INTEGER primary key autoincrement, LongTitle TEXT not null, -- ); CREATE TABLE chapters ( work_id INTEGER not null references works, -- Act INTEGER not null, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 945 - Distinct count 6 - Null count 0 Description TEXT not null, -- id INTEGER primary key autoincrement, Scene INTEGER not null, -- );
soccer_2016
Write down the player names and IDs of the English umpires.
English umpires refers to Country_Name = 'England'
SELECT T1.Umpire_Name, T1.Umpire_Id FROM Umpire AS T1 INNER JOIN Country AS T2 ON T1.Umpire_Country = T2.Country_Id WHERE T2.Country_Name = 'England'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
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 ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
retail_world
Please list the names of all the territories whose sales are taken in charge by Nancy Davolio.
names of all territories refers to TerritoryDescription;
SELECT T3.TerritoryDescription 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 T1.FirstName = 'Nancy' AND T1.LastName = 'Davolio'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
video_games
In which region where a game had the lowest number of sales?
which region refers to region_name; lowest number of sales refers to MIN(num_sales);
SELECT DISTINCT T1.region_name FROM region AS T1 INNER JOIN region_sales AS T2 ON T1.id = T2.region_id ORDER BY T2.num_sales LIMIT 1
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 65320 - Distinct count 4 - Null count 0 num_sales REAL default NULL, -- game_platform_id INTEGER default NULL, -- ); CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL, -- Example Values: `Action`, `Adventure`, `Fighting`, `Misc`, `Platform` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL, -- Example Values: `North America`, `Europe`, `Japan`, `Other` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE game ( foreign key (genre_id) references genre(id), game_name TEXT default NULL, -- id INTEGER not null primary key, genre_id INTEGER default NULL, -- Example Values: `4`, `5`, `11`, `2`, `9` | Value Statics: Total count 11317 - Distinct count 12 - Null count 0 ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL, -- ); CREATE TABLE game_platform ( platform_id INTEGER default NULL, -- game_publisher_id INTEGER default NULL, -- foreign key (platform_id) references platform(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), id INTEGER not null primary key, release_year INTEGER default NULL, -- ); CREATE TABLE game_publisher ( publisher_id INTEGER default NULL, -- game_id INTEGER default NULL, -- id INTEGER not null primary key, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id), ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL, -- );
soccer_2016
List the players' names who were born in 1971.
players' name refers to Player_name; born in 1971 refers to DOB LIKE '1971%'
SELECT Player_name FROM Player WHERE DOB LIKE '1971%'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 Player_Out INTEGER, -- foreign key (Player_Out) references Player(Player_Id), Over_Id INTEGER, -- primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Fielders INTEGER, -- foreign key (Match_Id) references Match(Match_Id), Ball_Id INTEGER, -- Example Values: `1`, `2`, `5`, `8`, `6` | Value Statics: Total count 6727 - Distinct count 9 - Null count 0 foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id), Innings_No INTEGER, -- Example Values: `2`, `1`, `3`, `4` | Value Statics: Total count 6727 - Distinct count 4 - Null count 0 Match_Id INTEGER, -- ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT, -- Example Values: `field`, `bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Player_Match ( foreign key (Role_Id) references Rolee(Role_Id), Player_Id INTEGER, -- foreign key (Team_Id) references Team(Team_Id), foreign key (Match_Id) references Match(Match_Id), Role_Id INTEGER, -- Example Values: `1`, `3`, `2`, `4` | Value Statics: Total count 12694 - Distinct count 4 - Null count 0 Team_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 12694 - Distinct count 13 - Null count 0 Match_Id INTEGER, -- foreign key (Player_Id) references Player(Player_Id), primary key (Match_Id, Player_Id, Role_Id), ); CREATE TABLE Season ( Orange_Cap INTEGER, -- Example Values: `100`, `18`, `133`, `162`, `19` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Man_of_the_Series INTEGER, -- Example Values: `32`, `53`, `133`, `162`, `315` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 Season_Id INTEGER primary key, Season_Year INTEGER, -- Example Values: `2008`, `2009`, `2010`, `2011`, `2012` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 Purple_Cap INTEGER, -- Example Values: `102`, `61`, `131`, `194`, `190` | Value Statics: Total count 9 - Distinct count 8 - Null count 0 ); CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT, -- Example Values: `Left-hand bat`, `Right-hand bat` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 ); CREATE TABLE Ball_by_Ball ( Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Bowler INTEGER, -- Match_Id INTEGER, -- Striker INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Non_Striker INTEGER, -- Team_Bowling INTEGER, -- Example Values: `2`, `1`, `4`, `3`, `6` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Striker_Batting_Position INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 Team_Batting INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 11 - Null count 0 foreign key (Match_Id) references Match(Match_Id), Over_Id INTEGER, -- ); CREATE TABLE Rolee ( Role_Desc TEXT, -- Example Values: `Captain`, `Keeper`, `Player`, `CaptainKeeper` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 Role_Id INTEGER primary key, ); CREATE TABLE Umpire ( Umpire_Name TEXT, -- Umpire_Country INTEGER, -- Example Values: `6`, `10`, `4`, `2`, `5` | Value Statics: Total count 52 - Distinct count 9 - Null count 0 Umpire_Id INTEGER primary key, foreign key (Umpire_Country) references Country(Country_Id), foreign key (Umpire_Country) references Country(Country_Id), ); CREATE TABLE Country ( Country_Id INTEGER primary key, foreign key (Country_Id) references Country(Country_Id), Country_Name TEXT, -- Example Values: `India`, `South Africa`, `U.A.E`, `New Zealand`, `Australia` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE Batsman_Scored ( Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 100000 - Distinct count 9 - Null count 0 Match_Id INTEGER, -- Runs_Scored INTEGER, -- Example Values: `0`, `1`, `4`, `6`, `2` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 foreign key (Match_Id) references Match(Match_Id), primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Over_Id INTEGER, -- Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT, -- Example Values: `Kolkata Knight Riders`, `Royal Challengers Bangalore`, `Chennai Super Kings`, `Kings XI Punjab`, `Rajasthan Royals` | Value Statics: Total count 13 - Distinct count 13 - Null count 0 ); CREATE TABLE City ( Country_id INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 29 - Distinct count 3 - Null count 0 City_Name TEXT, -- City_Id INTEGER primary key, ); CREATE TABLE Outcome ( Outcome_Type TEXT, -- Example Values: `Result`, `No Result`, `Superover` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Outcome_Id INTEGER primary key, ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, -- foreign key (Country_Name) references Country(Country_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), Batting_hand INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 469 - Distinct count 2 - Null count 0 Country_Name INTEGER, -- Example Values: `1`, `4`, `5`, `6`, `2` | Value Statics: Total count 469 - Distinct count 11 - Null count 0 Bowling_skill INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 426 - Distinct count 14 - Null count 43 foreign key (Batting_hand) references Batting_Style(Batting_Id), DOB DATE, -- ); CREATE TABLE Venue ( Venue_Name TEXT, -- Venue_Id INTEGER primary key, foreign key (City_Id) references City(City_Id), City_Id INTEGER, -- ); CREATE TABLE Extra_Type ( Extra_Name TEXT, -- Example Values: `legbyes`, `wides`, `byes`, `noballs`, `penalty` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 Extra_Id INTEGER primary key, ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT, -- Example Values: `caught`, `bowled`, `run out`, `lbw`, `retired hurt` | Value Statics: Total count 9 - Distinct count 9 - Null count 0 ); CREATE TABLE Match ( Win_Margin INTEGER, -- foreign key (Toss_Winner) references Team(Team_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Team_1) references Team(Team_Id), Venue_Id INTEGER, -- foreign key (Venue_Id) references Venue(Venue_Id), Match_Id INTEGER primary key, Match_Winner INTEGER, -- Example Values: `1`, `3`, `6`, `2`, `5` | Value Statics: Total count 574 - Distinct count 13 - Null count 3 Team_1 INTEGER, -- Example Values: `2`, `4`, `6`, `7`, `1` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 Match_Date DATE, -- Toss_Decide INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 577 - Distinct count 2 - Null count 0 foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Man_of_the_Match) references Player(Player_Id), foreign key (Man_of_the_Match) references Player(Player_Id), Season_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 577 - Distinct count 9 - Null count 0 Outcome_type INTEGER, -- Example Values: `1`, `3`, `2` | Value Statics: Total count 577 - Distinct count 3 - Null count 0 Team_2 INTEGER, -- Example Values: `1`, `3`, `5`, `2`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Match_Winner) references Team(Team_Id), foreign key (Match_Winner) references Team(Team_Id), Win_Type INTEGER, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 577 - Distinct count 4 - Null count 0 Man_of_the_Match INTEGER, -- Toss_Winner INTEGER, -- Example Values: `2`, `3`, `5`, `7`, `8` | Value Statics: Total count 577 - Distinct count 13 - Null count 0 foreign key (Season_Id) references Season(Season_Id), ); CREATE TABLE Extra_Runs ( Extra_Runs INTEGER, -- Example Values: `1`, `4`, `5`, `2`, `3` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 Match_Id INTEGER, -- Ball_Id INTEGER, -- Example Values: `1`, `2`, `3`, `7`, `5` | Value Statics: Total count 7469 - Distinct count 9 - Null count 0 primary key (Match_Id, Over_Id, Ball_Id, Innings_No), Extra_Type_Id INTEGER, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 7469 - Distinct count 5 - Null count 0 foreign key (Extra_Type_Id) references Extra_Type(Extra_Id), Innings_No INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 7469 - Distinct count 4 - Null count 0 Over_Id INTEGER, -- ); CREATE TABLE Bowling_Style ( Bowling_skill TEXT, -- Example Values: `Right-arm medium`, `Right-arm offbreak`, `Right-arm fast-medium`, `Legbreak googly`, `Right-arm medium-fast` | Value Statics: Total count 14 - Distinct count 14 - Null count 0 Bowling_Id INTEGER primary key, );
sales_in_weather
What is the total number of units of item no.5 sold in store no.3 in 2012 on days when the temperature was below the 30-year normal?
item no.5 refers to item_nbr = 5; store no. 3 refers to store_nbr = 3; when the temperature was below the 30-year normal refers to depart < 0; in 2012 refers to SUBSTR(date, 1, 4) = '2012'; total number of units refers to Sum(units)
SELECT SUM(CASE WHEN T3.depart < 0 THEN units ELSE 0 END) AS sum 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
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (store_nbr) references sales_in_weather(store_nbr), foreign key (station_nbr) references weather(station_nbr), ); CREATE TABLE weather ( resultdir INTEGER, -- date DATE, -- codesum TEXT, -- dewpoint INTEGER, -- primary key (station_nbr, date), avgspeed REAL, -- heat INTEGER, -- depart INTEGER, -- resultspeed REAL, -- tmin INTEGER, -- tmax INTEGER, -- sunset TEXT, -- wetbulb INTEGER, -- station_nbr INTEGER, -- tavg INTEGER, -- stnpressure REAL, -- sunrise TEXT, -- cool INTEGER, -- sealevel REAL, -- preciptotal REAL, -- snowfall REAL, -- );
food_inspection_2
What is the facility type of the establishment named "Kinetic Playground"?
the establishment named "Kinetic Playground" refers to dba_name = 'Kinetic Playground'
SELECT facility_type FROM establishment WHERE dba_name = 'Kinetic Playground'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER primary key, results TEXT, -- Example Values: `Pass`, `Pass w/ Conditions`, `Fail`, `Out of Business`, `Business Not Located` | Value Statics: Total count 100000 - Distinct count 7 - Null count 0 inspection_date DATE, -- inspection_type TEXT, -- ); CREATE TABLE violation ( inspector_comment TEXT, -- inspection_id INTEGER, -- foreign key (inspection_id) references inspection(inspection_id), point_id INTEGER, -- primary key (inspection_id, point_id), foreign key (point_id) references inspection_point(point_id), foreign key (point_id) references inspection_point(point_id), fine INTEGER, -- Example Values: `100`, `0`, `500`, `250` | Value Statics: Total count 100000 - Distinct count 4 - Null count 0 ); CREATE TABLE establishment ( facility_type TEXT, -- address TEXT, -- risk_level INTEGER, -- Example Values: `2`, `1`, `3` | Value Statics: Total count 31621 - Distinct count 3 - Null count 21 aka_name TEXT, -- state TEXT, -- Example Values: `IL` | Value Statics: Total count 31640 - Distinct count 1 - Null count 2 zip INTEGER, -- license_no INTEGER primary key, city TEXT, -- Example Values: `CHICAGO`, `Chicago`, `chicago`, `CHicago`, `MAYWOOD` | Value Statics: Total count 31593 - Distinct count 16 - Null count 49 ward INTEGER, -- longitude REAL, -- latitude REAL, -- dba_name TEXT, -- ); CREATE TABLE employee ( zip INTEGER, -- city TEXT, -- Example Values: `Chicago`, `Park Forest`, `Hoffman Estates` | Value Statics: Total count 75 - Distinct count 3 - Null count 0 phone TEXT, -- employee_id INTEGER primary key, title TEXT, -- Example Values: `Sanitarian`, `Supervisor`, `Division Manager` | Value Statics: Total count 75 - Distinct count 3 - Null count 0 first_name TEXT, -- salary INTEGER, -- address TEXT, -- supervisor INTEGER, -- Example Values: `177316`, `186742`, `179582`, `182205`, `192462` | Value Statics: Total count 75 - Distinct count 8 - Null count 0 state TEXT, -- Example Values: `IL` | Value Statics: Total count 75 - Distinct count 1 - Null count 0 last_name TEXT, -- foreign key (supervisor) references employee(employee_id), ); CREATE TABLE inspection_point ( point_id INTEGER primary key, category TEXT, -- Example Values: `Food Protection`, `Food Equipment and Utensil Sanitation`, `Wash and Waste Water Disposal`, `Toilet and Hand Washing Facilities for Staff`, `Compliance Insect and Rodent Control` | Value Statics: Total count 46 - Distinct count 14 - Null count 0 Description TEXT, -- fine INTEGER, -- Example Values: `500`, `250`, `100` | Value Statics: Total count 46 - Distinct count 3 - Null count 0 point_level TEXT, -- Example Values: `Critical`, `Serious `, `Minor ` | Value Statics: Total count 46 - Distinct count 3 - Null count 0 code TEXT, -- Example Values: `7-38-005 (B) (B-2)`, `7-38-005 (A)`, `7-38-010 (A) (B)`, `7-38-030`, `7-38-031` | Value Statics: Total count 46 - Distinct count 17 - Null count 0 );
video_games
In what platform does the game ID 178 available?
platform refers to platform_name;
SELECT T3.platform_name FROM game_publisher AS T1 INNER JOIN game_platform AS T2 ON T1.id = T2.game_publisher_id INNER JOIN platform AS T3 ON T2.platform_id = T3.id WHERE T1.game_id = 178
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 65320 - Distinct count 4 - Null count 0 num_sales REAL default NULL, -- game_platform_id INTEGER default NULL, -- ); CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL, -- Example Values: `Action`, `Adventure`, `Fighting`, `Misc`, `Platform` | Value Statics: Total count 12 - Distinct count 12 - Null count 0 ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL, -- Example Values: `North America`, `Europe`, `Japan`, `Other` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE game ( foreign key (genre_id) references genre(id), game_name TEXT default NULL, -- id INTEGER not null primary key, genre_id INTEGER default NULL, -- Example Values: `4`, `5`, `11`, `2`, `9` | Value Statics: Total count 11317 - Distinct count 12 - Null count 0 ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL, -- ); CREATE TABLE game_platform ( platform_id INTEGER default NULL, -- game_publisher_id INTEGER default NULL, -- foreign key (platform_id) references platform(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), foreign key (game_publisher_id) references game_publisher(id), id INTEGER not null primary key, release_year INTEGER default NULL, -- ); CREATE TABLE game_publisher ( publisher_id INTEGER default NULL, -- game_id INTEGER default NULL, -- id INTEGER not null primary key, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id), ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL, -- );
shakespeare
What are the titles and genres of the one-act works of Shakespeare?
one-act works refers to count(Act) = 1; genre refers to GenreType
SELECT DISTINCT T1.Title, T1.GenreType FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T2.Act = 1
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- ParagraphNum INTEGER not null, -- PlainText TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE works ( GenreType TEXT not null, -- Example Values: `Comedy`, `Tragedy`, `History`, `Poem`, `Sonnet` | Value Statics: Total count 43 - Distinct count 5 - Null count 0 Title TEXT not null, -- Date INTEGER not null, -- id INTEGER primary key autoincrement, LongTitle TEXT not null, -- ); CREATE TABLE chapters ( work_id INTEGER not null references works, -- Act INTEGER not null, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 945 - Distinct count 6 - Null count 0 Description TEXT not null, -- id INTEGER primary key autoincrement, Scene INTEGER not null, -- );
computer_student
How many students that are undergoing the pre-phase of qualification have advisors?
students refers to student = 1 and ; undergoing the phase of pre-qualification refers to inPhase = 'Pre-Quals'; have advisors refers to advisedBy.p_id
SELECT COUNT(T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.inPhase = 'Pre_Quals' AND T2.student = 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
Between the faculty employee professors, how many teaches high-level or harder undergraduate courses? Indicate each of the professors unique identifying number.
faculty employee professors refers to hasPosition = 'Faculty_eme' and professor = 1; high-level or harder undergraduate courses refers to courseLevel = 'Level_400'; professors unique identifying number refers to person.p_id
SELECT COUNT(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T1.hasPosition = 'Faculty_eme' AND T1.professor = 1 AND T3.courseLevel = 'Level_400'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
How many courses were taught by more than 4 people?
courses refers to taughtBy.course_id; more than 4 people refers to count(taughtBy.p_id) > 4
SELECT COUNT(*) FROM ( SELECT COUNT(course_id) FROM taughtBy GROUP BY course_id HAVING COUNT(course_id) > 4 )
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
Among the students being advised by advisors, which students' year in the program do the advisors advise the majority of?
students refers to student = 1; students' year in the program do the advisors advise the majority of refers to max(count(yearsInProgram))
SELECT T2.yearsInProgram FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.student = 1 GROUP BY T2.yearsInProgram ORDER BY COUNT(T1.p_id_dummy) DESC LIMIT 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
What is the average number of professional or master/undergraduate courses being taught by each professor?
professional or master/undergraduate courses refers to courseLevel = 'Level_500'; average number = divide(count(taughtBy.course_id), count(taughtBy.p_id))
SELECT CAST(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
What is the sum of year 1 and year 2 students?
year 1 and year 2 students refers to yearsInProgram = 'Year_1' and yearsInProgram = 'Year_2' and student = 1
SELECT COUNT(*) FROM person WHERE yearsInProgram = 'Year_1' OR yearsInProgram = 'Year_2'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
What year in the program do the students with more than 2 advisors are in?
students refers to student = 1; more than 2 advisors refers to count(p_id_dummy) > 2
SELECT T2.yearsInProgram FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.student = 1 GROUP BY T2.p_id HAVING COUNT(T2.p_id) > 2
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
Which professor taught the most courses and what is the position of this person in the university?
professor refers to taughtBy.p_id; most courses refers to max(taughtBy.p_id); position refers to hasPosition
SELECT T1.p_id, T1.hasPosition FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
What is the total of professional courses available at the university? List out all the course id.
professional courses refers to courseLevel = 'Level_500'; course id refers to course.course_id
SELECT COUNT(course_id) FROM course WHERE courseLevel = 'Level_500'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
How many courses were taught by a professor who is currently the member of faculty?
professor refers to professor = 1;  member of faculty refers to hasPosition <> 0
SELECT COUNT(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition <> 0
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
computer_student
Which member of the faculty are teaching the most courses and what is his/her general course level?
member of the faculty refers to hasPosition <> 0, most courses refers to max(count(course.course_id))
SELECT T1.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
How many events were held at coordinate 97,40?
coordinate 97,40 refers to longitude = 97 AND latitude = 40;
SELECT COUNT(event_id) FROM `events` WHERE latitude = 40 AND longitude = 97
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
Which courses were taught by a professor who is not a faculty member?
courses refers to taughtBy.course_id; professor refers to professor = 1; is not a faculty member refers to hasPosition = 0
SELECT DISTINCT T2.course_id FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition = 0
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
What is the device id of the oldest user?
oldest user refers to MAX(age);
SELECT device_id FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age )
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many female users over the age of 50 are there?
female refers to gender = 'F'; over the age of 50 refers to age > 50;
SELECT COUNT(gender) FROM gender_age WHERE age > 50 AND gender = 'F'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
List the advisor IDs for students with eighth year of program and position status in faculty of those professors.
advisor IDs refers to p_id_dummy and person.p_id where professor = 1; eighth year of program refers to yearsInprogram = 'Year_8'; position status in faculty of those professors refers to hasPosition
SELECT T1.p_id_dummy, T2.hasPosition FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_8'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
What is the gender of the youngest user?
youngest user refers to MIN(age);
SELECT gender FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age )
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many male users are in the age group of M32-38?
male refers to gender = 'M'; age group refers to group; `group` = 'M32-38';
SELECT COUNT(gender) FROM gender_age WHERE gender = 'M' AND `group` = 'M32-38'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many active users were there in the event id 2?
active users refers to is_active = 1;
SELECT COUNT(is_active) FROM app_events WHERE event_id = 2 AND is_active = 1
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What is the model of the oldest user's device?
model of the device refers to device_model; oldest user refers to MAX(age);
SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id ORDER BY T2.age DESC LIMIT 1
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
What is the position in the faculty of the professor who teaches the highest number of courses?
position in the faculty refers to hasPosition; professor refers to professor = 1; teaches the highest number of courses refers to max(count(taughtBy.course_id))
SELECT T1.hasPosition FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
How many male users are active in the events held on 5/1/2016?
male refers to gender = 'M'; active refers to is_active = 1; on 5/1/2016 refers to timestamp LIKE '2016-05-01%';
SELECT COUNT(T3.gender) FROM app_events AS T1 INNER JOIN events_relevant AS T2 ON T2.event_id = T1.event_id INNER JOIN gender_age AS T3 ON T3.device_id = T2.device_id WHERE T1.is_active = 1 AND T3.gender = 'M' AND T2.timestamp LIKE '2016-05-01%'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What is the name of the category which most users belong to?
most users belong to refers to MAX(COUNT(app_id)); name of category refers to category;
SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many users are there in the Home Decoration category?
null
SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id WHERE T2.category = 'Home Decoration'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What is the age of the oldest active user that participated in the event held on 5/6/2016 at coordinates 121, 31?
oldest user refers to MAX(age); active user refers to is_active = 1; on 5/6/2016 refers to timestamp LIKE '2016-05-06%'; coordinates 121, 31 refers to longitude = 121 AND latitude = 31;
SELECT T3.age FROM app_events AS T1 INNER JOIN events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN gender_age AS T3 ON T2.device_id = T3.device_id WHERE T1.is_active = 1 AND T2.longitude = 121 AND T2.latitude = 31 AND SUBSTR(T2.timestamp, 1, 10) = '2016-05-06' ORDER BY T3.age DESC LIMIT 1
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
How many advisors are in charge of advising all the students in 1st year?
advisors refers to p_id_dummy; students in 1st year refers to student = 1 and yearsInProgram = 'Year_1'
SELECT COUNT(T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_1' AND T2.student = 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
What are the categories of the top 2 oldest events?
oldest event refers to MIN(timestamp);
SELECT T4.category FROM events_relevant AS T1 INNER JOIN app_events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN app_labels AS T3 ON T3.app_id = T2.app_id INNER JOIN label_categories AS T4 ON T3.label_id = T4.label_id ORDER BY T1.timestamp LIMIT 2
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many female users use ZenFone 5 devices?
female refers to gender = 'F'; ZenFone 5 refers to device_model = 'ZenFone 5';
SELECT COUNT(T1.gender) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.gender = 'F' AND T2.device_model = 'ZenFone 5'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What is the most common device model among female users between the ages 27 to 28?
most common device model refers to MAX(COUNT(device_id)); female refers to gender = 'F'; between the ages 27 to 28 refers to group = 'F27-28';
SELECT T2.device_model FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.`group` = 'F27-28' AND T1.gender = 'F' ORDER BY T2.device_id DESC LIMIT 1
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
Which category has the highest number of users?
highest number of users refers to MAX(COUNT(app_id));
SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
Among the faculty affiliated professor, how many professors teaches professional or master/undergraduate courses?
faculty affiliated professor refers to professor = 1 and hasPosition = 'Faculty_aff'; professional or master/undergraduate courses refers to courseLevel = 'Level_500'
SELECT COUNT(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T1.hasPosition = 'Faculty_aff' AND T1.professor = 1 AND T3.courseLevel = 'Level_500'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
What is the percentage of female OPPO users against the male OPPO users?
percentage = DIVIDE(MULTIPLY(CONCAT(COUNT(device_id WHERE phone_brand = 'OPPO' AND gender = 'F'), 100), COUNT(device_id)), '%') AS 'the percentage of female OPPO users'; DIVIDE(MULTIPLY(CONCAT(COUNT(device_id WHERE phone_brand = 'OPPO' AND gender = 'M'), 100), COUNT(device_id)), '%') AS 'the percentage of male OPPO users';
SELECT SUM(IIF(T2.gender = 'F', 1, 0)) * 100 / COUNT(T2.device_id) AS perFemale , SUM(IIF(T2.gender = 'M', 1, 0)) * 100 / COUNT(T2.device_id) AS perMale FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'OPPO'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What is the gender of the majority of Vivo phone users?
majority of Vivo phone users refers to MAX(COUNT(phone_brand = 'vivo'));
SELECT T.gender FROM ( SELECT T2.gender, COUNT(T2.gender) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'vivo' GROUP BY T2.gender ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many users belong to the MOBA category?
null
SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'MOBA'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
List the app users IDs and installed status for the event ID of 844.
app user IDs refers to app_id; is_installed = 1 means the app status is installed; is_installed = 0 means the app status is not installed;
SELECT app_id , IIF(is_installed = 1, 'YES', 'NO') AS status FROM app_events WHERE event_id = 844
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
How many professors teaches no more than two high-level or harder undergraduate courses?
professors refers to taughtBy.p_id; high-level or harder undergraduate courses  refers to courseLevel = 'Level_400' ; no more than two refers to count(taughtBy.course_id) < = 2
SELECT COUNT(*) FROM ( SELECT COUNT(T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400' GROUP BY T2.p_id HAVING COUNT(DISTINCT T1.course_id) <= 2 )
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
How many users used Vivo Xplay3S model?
Vivo Xplay3S model refers to phone_brand = 'vivo' AND device_model = 'Xplay3S';
SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE device_model = 'Xplay3S' AND phone_brand = 'vivo'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What were the locations of the events on 8th May, 2016?
location = longitude, latitude; on 8th May, 2016 refers to `timestamp` LIKE '2016-05-08%';
SELECT longitude, latitude FROM `events` WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-08'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many events were there on 30th April, 2016?
on 30th April, 2016 refers to `timestamp` LIKE '2016-04-30%';
SELECT COUNT(event_id) FROM events WHERE SUBSTR(`timestamp`, 1, 10) = '2016-04-30'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What are the labels' IDs of online shopping and online malls categories?
null
SELECT label_id FROM label_categories WHERE category IN ('online shopping', 'online malls')
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
How many professors teaches basic or medium undergraduate courses?
professors refers to taughtBy.p_id; basic or medium undergraduate courses refers to couresLevel = 'Level_300'
SELECT COUNT(*) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_300'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
Provide the app users IDs and time for the event ID of 82.
app user IDs refers to app_id; time refers to timestamp;
SELECT T1.app_id, T2.timestamp FROM app_events AS T1 INNER JOIN events AS T2 ON T2.event_id = T1.event_id WHERE T2.event_id = 82
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What is the ratio of male and female users in 27-28 age group?
ratio = DIVIDE(COUNT(device_id WHERE gender = 'M' AND `group` = 'M27-28'), COUNT(device_id WHERE gender = 'F' AND `group` = 'F27-28')); 27-28 age group refers to `group` = 'F27-28';
SELECT SUM(IIF(gender = 'M' AND `group` = 'M27-28', 1, 0)) / SUM(IIF(gender = 'F' AND `group` = 'F27-28', 1, 0)) AS r FROM gender_age
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
Describe the phone brands and models of the users who participated in events on 5th May, 2016 at the coordinates of (112,44).
models refers to device_model; on 5th May, 2016 refers to timestamp LIKE '2016-05-05%'; coordinates of (112,44) refers to longitude = 112 AND latitude = 44;
SELECT DISTINCT T2.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.timestamp LIKE '2016-05-05%' AND T1.longitude = 112 AND T1.latitude = 44
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many events did the 88-years-old male users participate on 4th May,2016?
88-years-old refers to age = 88; male refers to gender = 'M'; on 4th May, 2016 refers to timestamp LIKE '2016-05-04%';
SELECT COUNT(T2.event_id) FROM gender_age AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T1.gender = 'M' AND SUBSTR(`timestamp`, 1, 10) = '2016-05-04' AND T1.age = 88
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
computer_student
Who are the top 5 professors who teaches the highest number of professional or master/undergraduate courses?
professors refers to course.p_id; highest number of professional or master/undergraduate courses refers to max(count(course.course_id)) where courseLevel = 'Level_500'
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500' GROUP BY T2.p_id ORDER BY COUNT(T2.p_id) DESC LIMIT 5
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
talkingdata
Provide the phone brands and models of the users who were at the coordinates of (80,44).
models refers to device_model; coordinates of (80,44) refers to longitude = 80 AND latitude = 44;
SELECT DISTINCT T1.phone_brand, T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.longitude = 80 AND T2.latitude = 44
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
Describe the device user gender and age of the event ID of 15251.
null
SELECT T1.gender, T1.age FROM gender_age AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.event_id = 15251
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
Describe the ages, genders and numbers of events participated by the users at coordinates of (-102,38).
coordinates of (-102,38) refers to longitude = -102, latitude = 38;
SELECT DISTINCT T1.age, T1.gender, COUNT(T2.event_id) FROM gender_age AS T1 INNER JOIN `events` AS T2 ON T2.device_id = T1.device_id WHERE T2.longitude = -102 AND T2.latitude = 38 GROUP BY T1.age, T1.gender, T2.longitude, T2.latitude
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
Among HTC Butterfly phone users, list any five devices' IDs used by females.
HTC Butterfly refers to phone_brand = 'HTC' AND device_model = 'Butterfly'; females refers to gender = 'F';
SELECT T2.device_id FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.device_model = 'Butterfly' AND T2.gender = 'F' AND T1.phone_brand = 'HTC' LIMIT 5
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
What are the ages and genders of the LG L70 users?
LG L70 refers to phone_brand = 'LG' AND device_model = 'L70';
SELECT T2.age, T2.gender FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG' AND T1.device_model = 'L70'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
List the included categories in the event ID of 155.
null
SELECT DISTINCT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id INNER JOIN app_events AS T3 ON T3.app_id = T2.app_id WHERE T3.event_id = 155
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
talkingdata
How many app IDs were included under science fiction category?
null
SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'science fiction'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
mondial_geo
What's the number of infant mortality in Switzerland in a year?
Number can be calculated = Infant_Mortality * Population * Population_Growth
SELECT T2.Infant_Mortality * T1.Population * T2.Population_Growth FROM country AS T1 INNER JOIN population AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Switzerland'
CREATE TABLE politics ( Government TEXT, -- 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, -- Example Values: `Depe`, `USA`, `NL`, `GB`, `AUS` | Value Statics: Total count 39 - Distinct count 10 - Null count 200 ); CREATE TABLE river ( River TEXT, -- Mountains TEXT, -- SourceAltitude REAL, -- Length REAL, -- EstuaryLatitude REAL, -- SourceLongitude REAL, -- Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, -- EstuaryLongitude REAL, -- Sea TEXT, -- Name TEXT default '' not null primary key, SourceLatitude REAL, -- ); CREATE TABLE mountainOnIsland ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, -- primary key (Mountain, Island), Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, -- ); CREATE TABLE organization ( City TEXT, -- constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, -- constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, Abbreviation TEXT not null primary key, Province TEXT, -- Name TEXT not null constraint ix_organization_OrgNameUnique unique, -- Established DATE, -- ); CREATE TABLE geo_desert ( Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, -- Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, -- constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Desert), ); CREATE TABLE geo_source ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province 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), ); CREATE TABLE geo_sea ( Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, -- Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, -- constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Sea), Province TEXT default '' not null, -- ); CREATE TABLE geo_estuary ( primary key (Province, Country, River), River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, -- ); CREATE TABLE located ( River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, -- constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT constraint located_ibfk_1 references country 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_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, City TEXT, -- Province TEXT, -- ); CREATE TABLE lake ( Depth REAL, -- Altitude REAL, -- Name TEXT default '' not null primary key, Longitude REAL, -- Latitude REAL, -- Type TEXT, -- Example Values: `artificial`, `salt`, `caldera`, `impact`, `acid` | Value Statics: Total count 56 - Distinct count 6 - Null count 74 River TEXT, -- Area REAL, -- ); CREATE TABLE desert ( Longitude REAL, -- Area REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- ); CREATE TABLE geo_mountain ( Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, -- primary key (Province, Country, Mountain), Province TEXT default '' not null, -- constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, -- ); CREATE TABLE ethnicGroup ( primary key (Name, Country), Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, -- Name TEXT default '' not null, -- Percentage REAL, -- ); CREATE TABLE economy ( Industry REAL, -- GDP REAL, -- Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, Inflation REAL, -- Service REAL, -- Agriculture REAL, -- ); CREATE TABLE borders ( primary key (Country1, Country2), Country2 TEXT default '' not null constraint borders_ibfk_2 references country, -- Length REAL, -- Country1 TEXT default '' not null constraint borders_ibfk_1 references country, -- ); CREATE TABLE language ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE islandIn ( Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, -- River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade, -- Example Values: `River` | Value Statics: Total count 1 - Distinct count 1 - Null count 349 Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, -- Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, -- Example Values: `Lake`, `Ozero Baikal`, `Lake Toba`, `Lake Manicouagan`, `Lake Huron` | Value Statics: Total count 6 - Distinct count 6 - Null count 344 ); CREATE TABLE country ( Area REAL, -- Capital TEXT, -- Population INTEGER, -- Name TEXT not null constraint ix_county_Name unique, -- Province TEXT, -- Code TEXT default '' not null primary key, ); CREATE TABLE city ( Longitude REAL, -- constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Population INTEGER, -- Province TEXT default '' not null, -- primary key (Name, Province), Name TEXT default '' not null, -- Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, -- Latitude REAL, -- ); CREATE TABLE island ( Name TEXT default '' not null primary key, Islands TEXT, -- Area REAL, -- Type TEXT, -- Example Values: `volcanic`, `lime`, `coral`, `atoll` | Value Statics: Total count 91 - Distinct count 4 - Null count 185 Longitude REAL, -- Height REAL, -- Latitude REAL, -- ); CREATE TABLE geo_lake ( constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, -- Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, -- primary key (Province, Country, Lake), Province TEXT default '' not null, -- ); CREATE TABLE mountain ( Longitude REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- Type TEXT, -- Height REAL, -- Mountains TEXT, -- ); CREATE TABLE province ( Capital TEXT, -- Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, -- primary key (Name, Country), Population INTEGER, -- Area REAL, -- Name TEXT not null, -- CapProv TEXT, -- ); CREATE TABLE population ( Infant_Mortality REAL, -- Population_Growth REAL, -- Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, ); CREATE TABLE isMember ( primary key (Country, Organization), 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', -- ); CREATE TABLE locatedOn ( Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, -- Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, -- Province TEXT default '' not null, -- 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_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, 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, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, City TEXT default '' not null, -- ); CREATE TABLE mergesWith ( Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, -- Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, -- primary key (Sea1, Sea2), ); CREATE TABLE encompasses ( Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, -- Example Values: `Europe`, `Asia`, `America`, `Australia/Oceania`, `Africa` | Value Statics: Total count 242 - Distinct count 5 - Null count 0 Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- Example Values: `100.0`, `90.0`, `10.0`, `80.0`, `20.0` | Value Statics: Total count 242 - Distinct count 7 - Null count 0 primary key (Country, Continent), ); CREATE TABLE continent ( Name TEXT default '' not null primary key, Area REAL, -- Example Values: `30254700.0`, `39872000.0`, `45095300.0`, `8503470.0`, `9562490.0` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 ); CREATE TABLE religion ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE geo_river ( constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, River), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, -- River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, -- ); CREATE TABLE sea ( Depth REAL, -- Name TEXT default '' not null primary key, ); CREATE TABLE target ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT, -- Example Values: `Target`, `Christian`, `non-Christian` | Value Statics: Total count 205 - Distinct count 3 - Null count 0 ); CREATE TABLE geo_island ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, -- primary key (Province, Country, Island), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, -- constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, );
talkingdata
Among the LG brand users, calculate the percentage of the Nexus 5 model user. What is the ratio of male and female users of it?
LG brand refers to phone_brand = 'LG'; percentage = DIVIDE(MULTIPLY(CONCAT(COUNT(device_id WHERE device_model = 'Nexus 5'), 100), COUNT(device_id)),'%'); ratio = DIVIDE(COUNT(device_id WHERE device_model = 'Nexus 5' AND gender = 'M'), COUNT(device_id WHERE device_model = 'Nexus 5' AND gender = 'F')); Nexus 5 model refers to device_model = 'Nexus 5';
SELECT SUM(IIF(T1.device_model = 'Nexus 5', 1, 0)) * 100 / COUNT(T1.device_id) AS per , SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'M', 1, 0)) / SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'F', 1, 0)) AS r FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG'
CREATE TABLE app_events ( `is_active` INTEGER NOT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `is_installed` INTEGER NOT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `event_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`,`app_id`), ); CREATE TABLE events ( PRIMARY KEY (`event_id`), `event_id` INTEGER NOT NULL, -- `device_id` INTEGER DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `timestamp` DATETIME DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- ); CREATE TABLE label_categories ( PRIMARY KEY (`label_id`), `label_id` INTEGER NOT NULL, -- `category` TEXT DEFAULT NULL, -- ); CREATE TABLE gender_age_test ( `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), ); CREATE TABLE gender_age_train ( `group` TEXT DEFAULT NULL, -- Example Values: `M23-26`, `M32-38`, `M29-31`, `F43+`, `F27-28` | Value Statics: Total count 74645 - Distinct count 12 - Null count 0 `age` INTEGER DEFAULT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 74645 - Distinct count 2 - Null count 0 PRIMARY KEY (`device_id`), `device_id` INTEGER NOT NULL, -- ); CREATE TABLE app_all ( `app_id` INTEGER NOT NULL, -- PRIMARY KEY (`app_id`), ); CREATE TABLE phone_brand_device_model2 ( `device_id` INTEGER NOT NULL, -- `phone_brand` TEXT NOT NULL, -- PRIMARY KEY (`device_id`,`phone_brand`,`device_model`), `device_model` TEXT NOT NULL, -- ); CREATE TABLE gender_age ( FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `group` TEXT DEFAULT NULL, -- Example Values: `M29-31`, `M32-38`, `F29-32`, `M22-`, `M39+` | Value Statics: Total count 39923 - Distinct count 12 - Null count 60077 `device_id` INTEGER NOT NULL, -- `gender` TEXT DEFAULT NULL, -- Example Values: `M`, `F` | Value Statics: Total count 39923 - Distinct count 2 - Null count 60077 PRIMARY KEY (`device_id`), `age` INTEGER DEFAULT NULL, -- ); CREATE TABLE events_relevant ( `device_id` INTEGER DEFAULT NULL, -- `timestamp` DATETIME NOT NULL, -- FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE, `latitude` REAL NOT NULL, -- Example Values: `0.0`, `1.0` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 `event_id` INTEGER NOT NULL, -- PRIMARY KEY (`event_id`), `longitude` REAL NOT NULL, -- Example Values: `1.0` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 ); CREATE TABLE app_labels ( FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, `label_id` INTEGER NOT NULL, -- FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, `app_id` INTEGER NOT NULL, -- ); CREATE TABLE app_events_relevant ( FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE, PRIMARY KEY (`event_id`,`app_id`), `is_installed` INTEGER DEFAULT NULL, -- Example Values: `1` | Value Statics: Total count 100000 - Distinct count 1 - Null count 0 `app_id` INTEGER NOT NULL, -- FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, `event_id` INTEGER NOT NULL, -- `is_active` INTEGER DEFAULT NULL, -- Example Values: `0`, `1` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 ); CREATE TABLE sample_submission ( `F27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F29-32` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F23-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M32-38` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F43+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M27-28` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M39+` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F33-42` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M23-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `F24-26` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `M22-` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 `device_id` INTEGER NOT NULL, -- PRIMARY KEY (`device_id`), `M29-31` REAL DEFAULT NULL, -- Example Values: `0.0833` | Value Statics: Total count 13700 - Distinct count 1 - Null count 0 );
mondial_geo
How many people are there in Fareham's mother country?
Mother country refers to home country
SELECT T1.Population FROM country AS T1 INNER JOIN province AS T2 ON T1.Code = T2.Country INNER JOIN city AS T3 ON T3.Province = T2.Name WHERE T3.Name = 'Fareham'
CREATE TABLE politics ( Government TEXT, -- 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, -- Example Values: `Depe`, `USA`, `NL`, `GB`, `AUS` | Value Statics: Total count 39 - Distinct count 10 - Null count 200 ); CREATE TABLE river ( River TEXT, -- Mountains TEXT, -- SourceAltitude REAL, -- Length REAL, -- EstuaryLatitude REAL, -- SourceLongitude REAL, -- Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, -- EstuaryLongitude REAL, -- Sea TEXT, -- Name TEXT default '' not null primary key, SourceLatitude REAL, -- ); CREATE TABLE mountainOnIsland ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, -- primary key (Mountain, Island), Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, -- ); CREATE TABLE organization ( City TEXT, -- constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, -- constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, Abbreviation TEXT not null primary key, Province TEXT, -- Name TEXT not null constraint ix_organization_OrgNameUnique unique, -- Established DATE, -- ); CREATE TABLE geo_desert ( Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, -- Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, -- constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Desert), ); CREATE TABLE geo_source ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province 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), ); CREATE TABLE geo_sea ( Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, -- Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, -- constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Sea), Province TEXT default '' not null, -- ); CREATE TABLE geo_estuary ( primary key (Province, Country, River), River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, -- ); CREATE TABLE located ( River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, -- constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT constraint located_ibfk_1 references country 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_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, City TEXT, -- Province TEXT, -- ); CREATE TABLE lake ( Depth REAL, -- Altitude REAL, -- Name TEXT default '' not null primary key, Longitude REAL, -- Latitude REAL, -- Type TEXT, -- Example Values: `artificial`, `salt`, `caldera`, `impact`, `acid` | Value Statics: Total count 56 - Distinct count 6 - Null count 74 River TEXT, -- Area REAL, -- ); CREATE TABLE desert ( Longitude REAL, -- Area REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- ); CREATE TABLE geo_mountain ( Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, -- primary key (Province, Country, Mountain), Province TEXT default '' not null, -- constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, -- ); CREATE TABLE ethnicGroup ( primary key (Name, Country), Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, -- Name TEXT default '' not null, -- Percentage REAL, -- ); CREATE TABLE economy ( Industry REAL, -- GDP REAL, -- Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, Inflation REAL, -- Service REAL, -- Agriculture REAL, -- ); CREATE TABLE borders ( primary key (Country1, Country2), Country2 TEXT default '' not null constraint borders_ibfk_2 references country, -- Length REAL, -- Country1 TEXT default '' not null constraint borders_ibfk_1 references country, -- ); CREATE TABLE language ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE islandIn ( Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, -- River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade, -- Example Values: `River` | Value Statics: Total count 1 - Distinct count 1 - Null count 349 Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, -- Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, -- Example Values: `Lake`, `Ozero Baikal`, `Lake Toba`, `Lake Manicouagan`, `Lake Huron` | Value Statics: Total count 6 - Distinct count 6 - Null count 344 ); CREATE TABLE country ( Area REAL, -- Capital TEXT, -- Population INTEGER, -- Name TEXT not null constraint ix_county_Name unique, -- Province TEXT, -- Code TEXT default '' not null primary key, ); CREATE TABLE city ( Longitude REAL, -- constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Population INTEGER, -- Province TEXT default '' not null, -- primary key (Name, Province), Name TEXT default '' not null, -- Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, -- Latitude REAL, -- ); CREATE TABLE island ( Name TEXT default '' not null primary key, Islands TEXT, -- Area REAL, -- Type TEXT, -- Example Values: `volcanic`, `lime`, `coral`, `atoll` | Value Statics: Total count 91 - Distinct count 4 - Null count 185 Longitude REAL, -- Height REAL, -- Latitude REAL, -- ); CREATE TABLE geo_lake ( constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, -- Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, -- primary key (Province, Country, Lake), Province TEXT default '' not null, -- ); CREATE TABLE mountain ( Longitude REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- Type TEXT, -- Height REAL, -- Mountains TEXT, -- ); CREATE TABLE province ( Capital TEXT, -- Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, -- primary key (Name, Country), Population INTEGER, -- Area REAL, -- Name TEXT not null, -- CapProv TEXT, -- ); CREATE TABLE population ( Infant_Mortality REAL, -- Population_Growth REAL, -- Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, ); CREATE TABLE isMember ( primary key (Country, Organization), 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', -- ); CREATE TABLE locatedOn ( Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, -- Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, -- Province TEXT default '' not null, -- 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_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, 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, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, City TEXT default '' not null, -- ); CREATE TABLE mergesWith ( Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, -- Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, -- primary key (Sea1, Sea2), ); CREATE TABLE encompasses ( Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, -- Example Values: `Europe`, `Asia`, `America`, `Australia/Oceania`, `Africa` | Value Statics: Total count 242 - Distinct count 5 - Null count 0 Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- Example Values: `100.0`, `90.0`, `10.0`, `80.0`, `20.0` | Value Statics: Total count 242 - Distinct count 7 - Null count 0 primary key (Country, Continent), ); CREATE TABLE continent ( Name TEXT default '' not null primary key, Area REAL, -- Example Values: `30254700.0`, `39872000.0`, `45095300.0`, `8503470.0`, `9562490.0` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 ); CREATE TABLE religion ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE geo_river ( constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, River), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, -- River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, -- ); CREATE TABLE sea ( Depth REAL, -- Name TEXT default '' not null primary key, ); CREATE TABLE target ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT, -- Example Values: `Target`, `Christian`, `non-Christian` | Value Statics: Total count 205 - Distinct count 3 - Null count 0 ); CREATE TABLE geo_island ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, -- primary key (Province, Country, Island), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, -- constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, );
computer_student
Which professor taught the least amount of courses?
professor refers to taughtBy.p_id; least amount of courses refers to min(count(course_id))
SELECT p_id FROM taughtBy GROUP BY p_id ORDER BY COUNT(course_id) ASC LIMIT 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_dummy), p_id_dummy INTEGER, -- constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id), ); CREATE TABLE person ( student INTEGER, -- Example Values: `1`, `0` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 p_id INTEGER constraint person_pk primary key, hasPosition TEXT, -- Example Values: `0`, `Faculty`, `Faculty_adj`, `Faculty_eme`, `Faculty_aff` | Value Statics: Total count 278 - Distinct count 5 - Null count 0 professor INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 278 - Distinct count 2 - Null count 0 yearsInProgram TEXT, -- Example Values: `0`, `Year_2`, `Year_5`, `Year_7`, `Year_10` | Value Statics: Total count 278 - Distinct count 12 - Null count 0 inPhase TEXT, -- Example Values: `0`, `Post_Quals`, `Post_Generals`, `Pre_Quals` | Value Statics: Total count 278 - Distinct count 4 - Null count 0 ); CREATE TABLE taughtBy ( foreign key (p_id) references person(p_id), p_id INTEGER, -- primary key (course_id, p_id), foreign key (course_id) references course(course_id), course_id INTEGER, -- );
mondial_geo
Give the full names of the countries that are located in more than one continent.
null
SELECT T3.Name FROM continent AS T1 INNER JOIN encompasses AS T2 ON T1.Name = T2.Continent INNER JOIN country AS T3 ON T3.Code = T2.Country GROUP BY T3.Name HAVING COUNT(T3.Name) > 1
CREATE TABLE politics ( Government TEXT, -- 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, -- Example Values: `Depe`, `USA`, `NL`, `GB`, `AUS` | Value Statics: Total count 39 - Distinct count 10 - Null count 200 ); CREATE TABLE river ( River TEXT, -- Mountains TEXT, -- SourceAltitude REAL, -- Length REAL, -- EstuaryLatitude REAL, -- SourceLongitude REAL, -- Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, -- EstuaryLongitude REAL, -- Sea TEXT, -- Name TEXT default '' not null primary key, SourceLatitude REAL, -- ); CREATE TABLE mountainOnIsland ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, -- primary key (Mountain, Island), Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, -- ); CREATE TABLE organization ( City TEXT, -- constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, -- constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, Abbreviation TEXT not null primary key, Province TEXT, -- Name TEXT not null constraint ix_organization_OrgNameUnique unique, -- Established DATE, -- ); CREATE TABLE geo_desert ( Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, -- Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, -- constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Desert), ); CREATE TABLE geo_source ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province 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), ); CREATE TABLE geo_sea ( Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, -- Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, -- constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Sea), Province TEXT default '' not null, -- ); CREATE TABLE geo_estuary ( primary key (Province, Country, River), River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, -- ); CREATE TABLE located ( River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, -- constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT constraint located_ibfk_1 references country 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_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, City TEXT, -- Province TEXT, -- ); CREATE TABLE lake ( Depth REAL, -- Altitude REAL, -- Name TEXT default '' not null primary key, Longitude REAL, -- Latitude REAL, -- Type TEXT, -- Example Values: `artificial`, `salt`, `caldera`, `impact`, `acid` | Value Statics: Total count 56 - Distinct count 6 - Null count 74 River TEXT, -- Area REAL, -- ); CREATE TABLE desert ( Longitude REAL, -- Area REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- ); CREATE TABLE geo_mountain ( Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, -- primary key (Province, Country, Mountain), Province TEXT default '' not null, -- constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, -- ); CREATE TABLE ethnicGroup ( primary key (Name, Country), Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, -- Name TEXT default '' not null, -- Percentage REAL, -- ); CREATE TABLE economy ( Industry REAL, -- GDP REAL, -- Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, Inflation REAL, -- Service REAL, -- Agriculture REAL, -- ); CREATE TABLE borders ( primary key (Country1, Country2), Country2 TEXT default '' not null constraint borders_ibfk_2 references country, -- Length REAL, -- Country1 TEXT default '' not null constraint borders_ibfk_1 references country, -- ); CREATE TABLE language ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE islandIn ( Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, -- River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade, -- Example Values: `River` | Value Statics: Total count 1 - Distinct count 1 - Null count 349 Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, -- Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, -- Example Values: `Lake`, `Ozero Baikal`, `Lake Toba`, `Lake Manicouagan`, `Lake Huron` | Value Statics: Total count 6 - Distinct count 6 - Null count 344 ); CREATE TABLE country ( Area REAL, -- Capital TEXT, -- Population INTEGER, -- Name TEXT not null constraint ix_county_Name unique, -- Province TEXT, -- Code TEXT default '' not null primary key, ); CREATE TABLE city ( Longitude REAL, -- constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Population INTEGER, -- Province TEXT default '' not null, -- primary key (Name, Province), Name TEXT default '' not null, -- Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, -- Latitude REAL, -- ); CREATE TABLE island ( Name TEXT default '' not null primary key, Islands TEXT, -- Area REAL, -- Type TEXT, -- Example Values: `volcanic`, `lime`, `coral`, `atoll` | Value Statics: Total count 91 - Distinct count 4 - Null count 185 Longitude REAL, -- Height REAL, -- Latitude REAL, -- ); CREATE TABLE geo_lake ( constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, -- Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, -- primary key (Province, Country, Lake), Province TEXT default '' not null, -- ); CREATE TABLE mountain ( Longitude REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- Type TEXT, -- Height REAL, -- Mountains TEXT, -- ); CREATE TABLE province ( Capital TEXT, -- Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, -- primary key (Name, Country), Population INTEGER, -- Area REAL, -- Name TEXT not null, -- CapProv TEXT, -- ); CREATE TABLE population ( Infant_Mortality REAL, -- Population_Growth REAL, -- Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, ); CREATE TABLE isMember ( primary key (Country, Organization), 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', -- ); CREATE TABLE locatedOn ( Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, -- Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, -- Province TEXT default '' not null, -- 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_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, 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, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, City TEXT default '' not null, -- ); CREATE TABLE mergesWith ( Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, -- Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, -- primary key (Sea1, Sea2), ); CREATE TABLE encompasses ( Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, -- Example Values: `Europe`, `Asia`, `America`, `Australia/Oceania`, `Africa` | Value Statics: Total count 242 - Distinct count 5 - Null count 0 Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- Example Values: `100.0`, `90.0`, `10.0`, `80.0`, `20.0` | Value Statics: Total count 242 - Distinct count 7 - Null count 0 primary key (Country, Continent), ); CREATE TABLE continent ( Name TEXT default '' not null primary key, Area REAL, -- Example Values: `30254700.0`, `39872000.0`, `45095300.0`, `8503470.0`, `9562490.0` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 ); CREATE TABLE religion ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE geo_river ( constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, River), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, -- River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, -- ); CREATE TABLE sea ( Depth REAL, -- Name TEXT default '' not null primary key, ); CREATE TABLE target ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT, -- Example Values: `Target`, `Christian`, `non-Christian` | Value Statics: Total count 205 - Distinct count 3 - Null count 0 ); CREATE TABLE geo_island ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, -- primary key (Province, Country, Island), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, -- constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, );
mondial_geo
How many percent of the total area of Russia is in Europe?
null
SELECT T2.Percentage FROM continent AS T1 INNER JOIN encompasses AS T2 ON T1.Name = T2.Continent INNER JOIN country AS T3 ON T3.Code = T2.Country WHERE T3.Name = 'Russia' AND T1.Name = 'Europe'
CREATE TABLE politics ( Government TEXT, -- 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, -- Example Values: `Depe`, `USA`, `NL`, `GB`, `AUS` | Value Statics: Total count 39 - Distinct count 10 - Null count 200 ); CREATE TABLE river ( River TEXT, -- Mountains TEXT, -- SourceAltitude REAL, -- Length REAL, -- EstuaryLatitude REAL, -- SourceLongitude REAL, -- Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, -- EstuaryLongitude REAL, -- Sea TEXT, -- Name TEXT default '' not null primary key, SourceLatitude REAL, -- ); CREATE TABLE mountainOnIsland ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, -- primary key (Mountain, Island), Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, -- ); CREATE TABLE organization ( City TEXT, -- constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, -- constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade, Abbreviation TEXT not null primary key, Province TEXT, -- Name TEXT not null constraint ix_organization_OrgNameUnique unique, -- Established DATE, -- ); CREATE TABLE geo_desert ( Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, -- Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, -- constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Desert), ); CREATE TABLE geo_source ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_source_ibfk_2 foreign key (Province, Country) references province 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), ); CREATE TABLE geo_sea ( Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, -- Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, -- constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, Sea), Province TEXT default '' not null, -- ); CREATE TABLE geo_estuary ( primary key (Province, Country, River), River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, -- constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, -- ); CREATE TABLE located ( River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, -- constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT constraint located_ibfk_1 references country 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_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, City TEXT, -- Province TEXT, -- ); CREATE TABLE lake ( Depth REAL, -- Altitude REAL, -- Name TEXT default '' not null primary key, Longitude REAL, -- Latitude REAL, -- Type TEXT, -- Example Values: `artificial`, `salt`, `caldera`, `impact`, `acid` | Value Statics: Total count 56 - Distinct count 6 - Null count 74 River TEXT, -- Area REAL, -- ); CREATE TABLE desert ( Longitude REAL, -- Area REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- ); CREATE TABLE geo_mountain ( Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, -- primary key (Province, Country, Mountain), Province TEXT default '' not null, -- constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, -- ); CREATE TABLE ethnicGroup ( primary key (Name, Country), Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, -- Name TEXT default '' not null, -- Percentage REAL, -- ); CREATE TABLE economy ( Industry REAL, -- GDP REAL, -- Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, Inflation REAL, -- Service REAL, -- Agriculture REAL, -- ); CREATE TABLE borders ( primary key (Country1, Country2), Country2 TEXT default '' not null constraint borders_ibfk_2 references country, -- Length REAL, -- Country1 TEXT default '' not null constraint borders_ibfk_1 references country, -- ); CREATE TABLE language ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE islandIn ( Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, -- River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade, -- Example Values: `River` | Value Statics: Total count 1 - Distinct count 1 - Null count 349 Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, -- Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, -- Example Values: `Lake`, `Ozero Baikal`, `Lake Toba`, `Lake Manicouagan`, `Lake Huron` | Value Statics: Total count 6 - Distinct count 6 - Null count 344 ); CREATE TABLE country ( Area REAL, -- Capital TEXT, -- Population INTEGER, -- Name TEXT not null constraint ix_county_Name unique, -- Province TEXT, -- Code TEXT default '' not null primary key, ); CREATE TABLE city ( Longitude REAL, -- constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Population INTEGER, -- Province TEXT default '' not null, -- primary key (Name, Province), Name TEXT default '' not null, -- Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, -- Latitude REAL, -- ); CREATE TABLE island ( Name TEXT default '' not null primary key, Islands TEXT, -- Area REAL, -- Type TEXT, -- Example Values: `volcanic`, `lime`, `coral`, `atoll` | Value Statics: Total count 91 - Distinct count 4 - Null count 185 Longitude REAL, -- Height REAL, -- Latitude REAL, -- ); CREATE TABLE geo_lake ( constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, -- Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, -- primary key (Province, Country, Lake), Province TEXT default '' not null, -- ); CREATE TABLE mountain ( Longitude REAL, -- Name TEXT default '' not null primary key, Latitude REAL, -- Type TEXT, -- Height REAL, -- Mountains TEXT, -- ); CREATE TABLE province ( Capital TEXT, -- Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, -- primary key (Name, Country), Population INTEGER, -- Area REAL, -- Name TEXT not null, -- CapProv TEXT, -- ); CREATE TABLE population ( Infant_Mortality REAL, -- Population_Growth REAL, -- Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, ); CREATE TABLE isMember ( primary key (Country, Organization), 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', -- ); CREATE TABLE locatedOn ( Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, -- Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, -- Province TEXT default '' not null, -- 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_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, 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, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade, City TEXT default '' not null, -- ); CREATE TABLE mergesWith ( Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, -- Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, -- primary key (Sea1, Sea2), ); CREATE TABLE encompasses ( Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, -- Example Values: `Europe`, `Asia`, `America`, `Australia/Oceania`, `Africa` | Value Statics: Total count 242 - Distinct count 5 - Null count 0 Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- Example Values: `100.0`, `90.0`, `10.0`, `80.0`, `20.0` | Value Statics: Total count 242 - Distinct count 7 - Null count 0 primary key (Country, Continent), ); CREATE TABLE continent ( Name TEXT default '' not null primary key, Area REAL, -- Example Values: `30254700.0`, `39872000.0`, `45095300.0`, `8503470.0`, `9562490.0` | Value Statics: Total count 5 - Distinct count 5 - Null count 0 ); CREATE TABLE religion ( primary key (Name, Country), Name TEXT default '' not null, -- Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, -- Percentage REAL, -- ); CREATE TABLE geo_river ( constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, primary key (Province, Country, River), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, -- River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, -- ); CREATE TABLE sea ( Depth REAL, -- Name TEXT default '' not null primary key, ); CREATE TABLE target ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT, -- Example Values: `Target`, `Christian`, `non-Christian` | Value Statics: Total count 205 - Distinct count 3 - Null count 0 ); CREATE TABLE geo_island ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, -- primary key (Province, Country, Island), Province TEXT default '' not null, -- Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, -- constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade, );