db_id
stringlengths
4
28
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
schema
stringlengths
352
37.3k
retail_world
Among the employees who handled orders to Brazil, who has the highest salary and calculate the average salary of them.
orders to Brazil refers to ShipCountry = 'Brazil'; highest salary refers to max(salary); average salary = AVG(Salary)
SELECT T1.FirstName, T1.LastName, AVG(T1.Salary) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.ShipCountry = 'Brazil' GROUP BY T1.FirstName, T1.LastName ORDER BY SUM(T1.Salary) DESC LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
mondial_geo
What is the average inflation rate of the biggest continent?
SELECT AVG(T4.Inflation) FROM continent AS T1 INNER JOIN encompasses AS T2 ON T1.Name = T2.Continent INNER JOIN country AS T3 ON T3.Code = T2.Country INNER JOIN economy AS T4 ON T4.Country = T3.Code WHERE T1.Name = ( SELECT Name FROM continent ORDER BY Area DESC LIMIT 1 )
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
shipping
Among all shipments placed by Sunguard Window Tinting & Truck Accessories in 2017, identify the percentage of shipments whose weight exceeded 10,000 pounds.
"Sunguard Window Tinting & Truck Accessories" is the cust_name; weight exceed 10,000 pounds refers to weight > = 10000; in 2017 refers to Cast(ship_date AS DATE) = 2017; percentage = Divide (Sum(weight > = 10000), Sum(weight)) * 100
SELECT CAST(SUM(CASE WHEN T1.weight >= 10000 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM shipment AS T1 INNER JOIN customer AS T2 ON T1.cust_id = T2.cust_id WHERE T2.cust_name = 'Sunguard Window Tinting & Truck Accessories' AND STRFTIME('%Y', T1.ship_date) = '2017'
CREATE TABLE city ( city_id INTEGER primary key, city_name TEXT, state TEXT, population INTEGER, area REAL ); CREATE TABLE customer ( cust_id INTEGER primary key, cust_name TEXT, annual_revenue INTEGER, cust_type TEXT, address TEXT, city TEXT, state TEXT, zip REAL, phone TEXT ); CREATE TABLE driver ( driver_id INTEGER primary key, first_name TEXT, last_name TEXT, address TEXT, city TEXT, state TEXT, zip_code INTEGER, phone TEXT ); CREATE TABLE truck ( truck_id INTEGER primary key, make TEXT, model_year INTEGER ); CREATE TABLE shipment ( ship_id INTEGER primary key, cust_id INTEGER, weight REAL, truck_id INTEGER, driver_id INTEGER, city_id INTEGER, ship_date TEXT, foreign key (cust_id) references customer(cust_id), foreign key (city_id) references city(city_id), foreign key (driver_id) references driver(driver_id), foreign key (truck_id) references truck(truck_id) );
movie_3
What is the full name of the actor who has acted the most times in comedy films?
full name refers to first_name, last_name; 'comedy' is a name of a category;
SELECT T.first_name, T.last_name FROM ( SELECT T4.first_name, T4.last_name, COUNT(T2.actor_id) AS num FROM film_category AS T1 INNER JOIN film_actor AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T1.category_id = T3.category_id INNER JOIN actor AS T4 ON T2.actor_id = T4.actor_id WHERE T3.name = 'Comedy' GROUP BY T4.first_name, T4.last_name ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
car_retails
Among the German customers, how many of the them has credit limit of zero?
German is a nationality of country = 'Germany'; CREDITLIMIT = 0
SELECT COUNT(customerNumber) FROM customers WHERE creditLimit = 0 AND country = 'Germany'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ); CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ); CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ); CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ); CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ); CREATE TABLE IF NOT EXISTS "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) );
retails
How many order keys are not applied for the discount?
order key refers to l_orderkey; not applied for the discount refers to l_discount = 0
SELECT COUNT(l_orderkey) FROM lineitem WHERE l_discount = 0
CREATE TABLE `customer` ( `c_custkey` INTEGER NOT NULL, `c_mktsegment` TEXT DEFAULT NULL, `c_nationkey` INTEGER DEFAULT NULL, `c_name` TEXT DEFAULT NULL, `c_address` TEXT DEFAULT NULL, `c_phone` TEXT DEFAULT NULL, `c_acctbal` REAL DEFAULT NULL, `c_comment` TEXT DEFAULT NULL, PRIMARY KEY (`c_custkey`), FOREIGN KEY (`c_nationkey`) REFERENCES `nation` (`n_nationkey`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE lineitem ( l_shipdate DATE null, l_orderkey INTEGER not null, l_discount REAL not null, l_extendedprice REAL not null, l_suppkey INTEGER not null, l_quantity INTEGER not null, l_returnflag TEXT null, l_partkey INTEGER not null, l_linestatus TEXT null, l_tax REAL not null, l_commitdate DATE null, l_receiptdate DATE null, l_shipmode TEXT null, l_linenumber INTEGER not null, l_shipinstruct TEXT null, l_comment TEXT null, primary key (l_orderkey, l_linenumber), foreign key (l_orderkey) references orders (o_orderkey) on update cascade on delete cascade, foreign key (l_partkey, l_suppkey) references partsupp (ps_partkey, ps_suppkey) on update cascade on delete cascade ); CREATE TABLE nation ( n_nationkey INTEGER not null primary key, n_name TEXT null, n_regionkey INTEGER null, n_comment TEXT null, foreign key (n_regionkey) references region (r_regionkey) on update cascade on delete cascade ); CREATE TABLE orders ( o_orderdate DATE null, o_orderkey INTEGER not null primary key, o_custkey INTEGER not null, o_orderpriority TEXT null, o_shippriority INTEGER null, o_clerk TEXT null, o_orderstatus TEXT null, o_totalprice REAL null, o_comment TEXT null, foreign key (o_custkey) references customer (c_custkey) on update cascade on delete cascade ); CREATE TABLE part ( p_partkey INTEGER not null primary key, p_type TEXT null, p_size INTEGER null, p_brand TEXT null, p_name TEXT null, p_container TEXT null, p_mfgr TEXT null, p_retailprice REAL null, p_comment TEXT null ); CREATE TABLE partsupp ( ps_partkey INTEGER not null, ps_suppkey INTEGER not null, ps_supplycost REAL not null, ps_availqty INTEGER null, ps_comment TEXT null, primary key (ps_partkey, ps_suppkey), foreign key (ps_partkey) references part (p_partkey) on update cascade on delete cascade, foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade ); CREATE TABLE region ( r_regionkey INTEGER not null primary key, r_name TEXT null, r_comment TEXT null ); CREATE TABLE supplier ( s_suppkey INTEGER not null primary key, s_nationkey INTEGER null, s_comment TEXT null, s_name TEXT null, s_address TEXT null, s_phone TEXT null, s_acctbal REAL null, foreign key (s_nationkey) references nation (n_nationkey) );
student_loan
List the names of disabled students enlisted in the navy.
navy refers to organ = 'navy';
SELECT T1.name FROM enlist AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.organ = 'navy'
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE enlist ( "name" TEXT not null, organ TEXT not null, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE filed_for_bankrupcy ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, "month" INTEGER default 0 null, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE male ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE no_payment_due ( "name" TEXT default '' not null primary key, bool TEXT null, foreign key ("name") references person ("name") on update cascade on delete cascade, foreign key (bool) references bool ("name") on update cascade on delete cascade ); CREATE TABLE unemployed ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE `enrolled` ( `name` TEXT NOT NULL, `school` TEXT NOT NULL, `month` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (`name`,`school`), FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE );
movie_platform
Was the user who created the list "250 Favourite Films" a trialist when he or she created the list?
the user was a trialist when he created the list refers to user_trailist = 1; 250 Favourite Films is list_title;
SELECT T2.user_trialist FROM lists AS T1 INNER JOIN lists_users AS T2 ON T1.list_id = T2.list_id AND T1.user_id = T2.user_id WHERE T1.list_title = '250 Favourite Films'
CREATE TABLE IF NOT EXISTS "lists" ( user_id INTEGER references lists_users (user_id), list_id INTEGER not null primary key, list_title TEXT, list_movie_number INTEGER, list_update_timestamp_utc TEXT, list_creation_timestamp_utc TEXT, list_followers INTEGER, list_url TEXT, list_comments INTEGER, list_description TEXT, list_cover_image_url TEXT, list_first_image_url TEXT, list_second_image_url TEXT, list_third_image_url TEXT ); CREATE TABLE IF NOT EXISTS "movies" ( movie_id INTEGER not null primary key, movie_title TEXT, movie_release_year INTEGER, movie_url TEXT, movie_title_language TEXT, movie_popularity INTEGER, movie_image_url TEXT, director_id TEXT, director_name TEXT, director_url TEXT ); CREATE TABLE IF NOT EXISTS "ratings_users" ( user_id INTEGER references lists_users (user_id), rating_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER ); CREATE TABLE lists_users ( user_id INTEGER not null , list_id INTEGER not null , list_update_date_utc TEXT, list_creation_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial TEXT, user_has_payment_method TEXT, primary key (user_id, list_id), foreign key (list_id) references lists(list_id), foreign key (user_id) references lists(user_id) ); CREATE TABLE ratings ( movie_id INTEGER, rating_id INTEGER, rating_url TEXT, rating_score INTEGER, rating_timestamp_utc TEXT, critic TEXT, critic_likes INTEGER, critic_comments INTEGER, user_id INTEGER, user_trialist INTEGER, user_subscriber INTEGER, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER, foreign key (movie_id) references movies(movie_id), foreign key (user_id) references lists_users(user_id), foreign key (rating_id) references ratings(rating_id), foreign key (user_id) references ratings_users(user_id) );
app_store
What is the rating and the total Sentiment subjectivity score of "Onefootball - Soccer Scores"?
Onefootball - Soccer Scores refers to App = 'Onefootball - Soccer Scores';
SELECT T1.Rating, SUM(T2.Sentiment_Subjectivity) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Onefootball - Soccer Scores'
CREATE TABLE IF NOT EXISTS "playstore" ( App TEXT, Category TEXT, Rating REAL, Reviews INTEGER, Size TEXT, Installs TEXT, Type TEXT, Price TEXT, "Content Rating" TEXT, Genres TEXT ); CREATE TABLE IF NOT EXISTS "user_reviews" ( App TEXT references "playstore" (App), Translated_Review TEXT, Sentiment TEXT, Sentiment_Polarity TEXT, Sentiment_Subjectivity TEXT );
cookbook
How many ingredients are needed to prepare Idaho Potato Supreme?
Idaho Potato Supreme refers to title
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Idaho Potato Supreme'
CREATE TABLE Ingredient ( ingredient_id INTEGER primary key, category TEXT, name TEXT, plural TEXT ); CREATE TABLE Recipe ( recipe_id INTEGER primary key, title TEXT, subtitle TEXT, servings INTEGER, yield_unit TEXT, prep_min INTEGER, cook_min INTEGER, stnd_min INTEGER, source TEXT, intro TEXT, directions TEXT ); CREATE TABLE Nutrition ( recipe_id INTEGER primary key, protein REAL, carbo REAL, alcohol REAL, total_fat REAL, sat_fat REAL, cholestrl REAL, sodium REAL, iron REAL, vitamin_c REAL, vitamin_a REAL, fiber REAL, pcnt_cal_carb REAL, pcnt_cal_fat REAL, pcnt_cal_prot REAL, calories REAL, foreign key (recipe_id) references Recipe(recipe_id) ); CREATE TABLE Quantity ( quantity_id INTEGER primary key, recipe_id INTEGER, ingredient_id INTEGER, max_qty REAL, min_qty REAL, unit TEXT, preparation TEXT, optional TEXT, foreign key (recipe_id) references Recipe(recipe_id), foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id) );
image_and_language
What are the width and height of the bounding box of the object with "keyboard" as their object class and (5, 647) as their coordinate?
The bounding box's W and H abbreviations stand for the object's width and height respectively; "keyboard" as object class refers to OBJ_CLASS = 'keyboard'; (5, 647) as coordinate refers to X and Y coordinates of the bounding box where X = 5 and Y = 647;
SELECT T1.W, T1.H FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T2.OBJ_CLASS = 'keyboard' AND T1.X = 5 AND T1.Y = 647
CREATE TABLE ATT_CLASSES ( ATT_CLASS_ID INTEGER default 0 not null primary key, ATT_CLASS TEXT not null ); CREATE TABLE OBJ_CLASSES ( OBJ_CLASS_ID INTEGER default 0 not null primary key, OBJ_CLASS TEXT not null ); CREATE TABLE IMG_OBJ ( IMG_ID INTEGER default 0 not null, OBJ_SAMPLE_ID INTEGER default 0 not null, OBJ_CLASS_ID INTEGER null, X INTEGER null, Y INTEGER null, W INTEGER null, H INTEGER null, primary key (IMG_ID, OBJ_SAMPLE_ID), foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID) ); CREATE TABLE IMG_OBJ_ATT ( IMG_ID INTEGER default 0 not null, ATT_CLASS_ID INTEGER default 0 not null, OBJ_SAMPLE_ID INTEGER default 0 not null, primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID), foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID), foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID) ); CREATE TABLE PRED_CLASSES ( PRED_CLASS_ID INTEGER default 0 not null primary key, PRED_CLASS TEXT not null ); CREATE TABLE IMG_REL ( IMG_ID INTEGER default 0 not null, PRED_CLASS_ID INTEGER default 0 not null, OBJ1_SAMPLE_ID INTEGER default 0 not null, OBJ2_SAMPLE_ID INTEGER default 0 not null, primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID), foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID), foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID), foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID) );
public_review_platform
Find out which business is opened for 24/7 and list out what is the business attribute.
opened for 24/7 refers to Business_Hours WHERE opening_time = closing_time and business_id COUNT(day_id) = 7; business attribute refers to attribute_name
SELECT T5.attribute_name FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id INNER JOIN Business AS T3 ON T1.business_id = T3.business_id INNER JOIN Business_Attributes AS T4 ON T3.business_id = T4.business_id INNER JOIN Attributes AS T5 ON T4.attribute_id = T5.attribute_id WHERE T2.day_id LIKE '1' AND '2' AND '3' AND '4' AND '5' AND '6' AND '7' AND T1.opening_time = T1.closing_time GROUP BY T5.attribute_name
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
codebase_comments
How many followers do the most followed repository on Github have? Give the github address of the repository.
more forks refers to more people follow this repository; most followed repository refers to max(Forks);  the github address of the repository refers to Url;
SELECT Forks, Url FROM Repo WHERE Forks = ( SELECT MAX(Forks) FROM Repo )
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "Method" ( Id INTEGER not null primary key autoincrement, Name TEXT, FullComment TEXT, Summary TEXT, ApiCalls TEXT, CommentIsXml INTEGER, SampledAt INTEGER, SolutionId INTEGER, Lang TEXT, NameTokenized TEXT ); CREATE TABLE IF NOT EXISTS "MethodParameter" ( Id INTEGER not null primary key autoincrement, MethodId TEXT, Type TEXT, Name TEXT ); CREATE TABLE Repo ( Id INTEGER not null primary key autoincrement, Url TEXT, Stars INTEGER, Forks INTEGER, Watchers INTEGER, ProcessedTime INTEGER ); CREATE TABLE Solution ( Id INTEGER not null primary key autoincrement, RepoId INTEGER, Path TEXT, ProcessedTime INTEGER, WasCompiled INTEGER );
video_games
In 2004, what are the names of the platforms where Codemasters publish its games?
name of platform refers to platform_name; Codemasters refers to publisher_name = 'Codemasters'; in 2004 refers to release_year = 2004
SELECT T4.platform_name FROM publisher AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.publisher_id INNER JOIN game_platform AS T3 ON T2.id = T3.game_publisher_id INNER JOIN platform AS T4 ON T3.platform_id = T4.id WHERE T3.release_year = 2004 AND T1.publisher_name = 'Codemasters'
CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE game ( id INTEGER not null primary key, genre_id INTEGER default NULL, game_name TEXT default NULL, foreign key (genre_id) references genre(id) ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL ); CREATE TABLE game_publisher ( id INTEGER not null primary key, game_id INTEGER default NULL, publisher_id INTEGER default NULL, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id) ); CREATE TABLE game_platform ( id INTEGER not null primary key, game_publisher_id INTEGER default NULL, platform_id INTEGER default NULL, release_year INTEGER default NULL, foreign key (game_publisher_id) references game_publisher(id), foreign key (platform_id) references platform(id) ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL ); CREATE TABLE region_sales ( region_id INTEGER default NULL, game_platform_id INTEGER default NULL, num_sales REAL default NULL, foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id) );
movielens
How many unique directors with an average earnings of 2 and a quality of 3 have not made comedy films? List them.
SELECT DISTINCT T1.directorid FROM directors AS T1 INNER JOIN movies2directors AS T2 ON T1.directorid = T2.directorid WHERE T1.d_quality = 3 AND T1.avg_revenue = 2 AND T2.genre != 'Comedy'
CREATE TABLE users ( userid INTEGER default 0 not null primary key, age TEXT not null, u_gender TEXT not null, occupation TEXT not null ); CREATE TABLE IF NOT EXISTS "directors" ( directorid INTEGER not null primary key, d_quality INTEGER not null, avg_revenue INTEGER not null ); CREATE INDEX avg_revenue on directors (avg_revenue); CREATE INDEX d_quality on directors (d_quality); CREATE TABLE IF NOT EXISTS "actors" ( actorid INTEGER not null primary key, a_gender TEXT not null, a_quality INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies" ( movieid INTEGER default 0 not null primary key, year INTEGER not null, isEnglish TEXT not null, country TEXT not null, runningtime INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies2actors" ( movieid INTEGER not null references movies on update cascade on delete cascade, actorid INTEGER not null references actors on update cascade on delete cascade, cast_num INTEGER not null, primary key (movieid, actorid) ); CREATE TABLE IF NOT EXISTS "movies2directors" ( movieid INTEGER not null references movies on update cascade on delete cascade, directorid INTEGER not null references directors on update cascade on delete cascade, genre TEXT not null, primary key (movieid, directorid) ); CREATE TABLE IF NOT EXISTS "u2base" ( userid INTEGER default 0 not null references users on update cascade on delete cascade, movieid INTEGER not null references movies on update cascade on delete cascade, rating TEXT not null, primary key (userid, movieid) );
movielens
Among the English comedy movies produced in the UK, how many movies with a running time of 3 was rated the highest by users between the age 45-50? Indicate the movie names.
UK is a country
SELECT DISTINCT T1.movieid FROM movies AS T1 INNER JOIN movies2directors AS T2 ON T1.movieid = T2.movieid INNER JOIN u2base AS T3 ON T1.movieid = T3.movieid INNER JOIN users AS T4 ON T3.userid = T4.userid WHERE T1.country = 'UK' AND T2.genre = 'Comedy' AND T1.runningtime = 3 AND T3.rating = 5 AND T4.age BETWEEN 45 AND 50 AND T1.isEnglish = 'T'
CREATE TABLE users ( userid INTEGER default 0 not null primary key, age TEXT not null, u_gender TEXT not null, occupation TEXT not null ); CREATE TABLE IF NOT EXISTS "directors" ( directorid INTEGER not null primary key, d_quality INTEGER not null, avg_revenue INTEGER not null ); CREATE INDEX avg_revenue on directors (avg_revenue); CREATE INDEX d_quality on directors (d_quality); CREATE TABLE IF NOT EXISTS "actors" ( actorid INTEGER not null primary key, a_gender TEXT not null, a_quality INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies" ( movieid INTEGER default 0 not null primary key, year INTEGER not null, isEnglish TEXT not null, country TEXT not null, runningtime INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies2actors" ( movieid INTEGER not null references movies on update cascade on delete cascade, actorid INTEGER not null references actors on update cascade on delete cascade, cast_num INTEGER not null, primary key (movieid, actorid) ); CREATE TABLE IF NOT EXISTS "movies2directors" ( movieid INTEGER not null references movies on update cascade on delete cascade, directorid INTEGER not null references directors on update cascade on delete cascade, genre TEXT not null, primary key (movieid, directorid) ); CREATE TABLE IF NOT EXISTS "u2base" ( userid INTEGER default 0 not null references users on update cascade on delete cascade, movieid INTEGER not null references movies on update cascade on delete cascade, rating TEXT not null, primary key (userid, movieid) );
college_completion
What is the average percentage of students graduating within 100 percent of normal/expected time for Central Alabama Community College?
average = DIVIDE(SUM(grad_100_rate), (SUM(grad_100), SUM(grad_150))); percentage of students graduating within 100 percent of normal/expected time refers to grade_100_rate; Central Alabama Community College refers to chronname = 'Central Alabama Community College';
SELECT AVG(T2.grad_100_rate) FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T2.unitid = T1.unitid WHERE T1.chronname = 'Central Alabama Community College'
CREATE TABLE institution_details ( unitid INTEGER constraint institution_details_pk primary key, chronname TEXT, city TEXT, state TEXT, level TEXT, control TEXT, basic TEXT, hbcu TEXT, flagship TEXT, long_x REAL, lat_y REAL, site TEXT, student_count INTEGER, awards_per_value REAL, awards_per_state_value REAL, awards_per_natl_value REAL, exp_award_value INTEGER, exp_award_state_value INTEGER, exp_award_natl_value INTEGER, exp_award_percentile INTEGER, ft_pct REAL, fte_value INTEGER, fte_percentile INTEGER, med_sat_value TEXT, med_sat_percentile TEXT, aid_value INTEGER, aid_percentile INTEGER, endow_value TEXT, endow_percentile TEXT, grad_100_value REAL, grad_100_percentile INTEGER, grad_150_value REAL, grad_150_percentile INTEGER, pell_value REAL, pell_percentile INTEGER, retain_value REAL, retain_percentile INTEGER, ft_fac_value REAL, ft_fac_percentile INTEGER, vsa_year TEXT, vsa_grad_after4_first TEXT, vsa_grad_elsewhere_after4_first TEXT, vsa_enroll_after4_first TEXT, vsa_enroll_elsewhere_after4_first TEXT, vsa_grad_after6_first TEXT, vsa_grad_elsewhere_after6_first TEXT, vsa_enroll_after6_first TEXT, vsa_enroll_elsewhere_after6_first TEXT, vsa_grad_after4_transfer TEXT, vsa_grad_elsewhere_after4_transfer TEXT, vsa_enroll_after4_transfer TEXT, vsa_enroll_elsewhere_after4_transfer TEXT, vsa_grad_after6_transfer TEXT, vsa_grad_elsewhere_after6_transfer TEXT, vsa_enroll_after6_transfer TEXT, vsa_enroll_elsewhere_after6_transfer TEXT, similar TEXT, state_sector_ct INTEGER, carnegie_ct INTEGER, counted_pct TEXT, nicknames TEXT, cohort_size INTEGER ); CREATE TABLE institution_grads ( unitid INTEGER, year INTEGER, gender TEXT, race TEXT, cohort TEXT, grad_cohort TEXT, grad_100 TEXT, grad_150 TEXT, grad_100_rate TEXT, grad_150_rate TEXT, foreign key (unitid) references institution_details(unitid) ); CREATE TABLE state_sector_grads ( stateid INTEGER, state TEXT, state_abbr TEXT, control TEXT, level TEXT, year INTEGER, gender TEXT, race TEXT, cohort TEXT, grad_cohort TEXT, grad_100 TEXT, grad_150 TEXT, grad_100_rate TEXT, grad_150_rate TEXT, grad_cohort_ct INTEGER, foreign key (state) references institution_details(state), foreign key (stateid) references state_sector_details(stateid) ); CREATE TABLE IF NOT EXISTS "state_sector_details" ( stateid INTEGER, state TEXT references institution_details (state), state_post TEXT, level TEXT, control TEXT, schools_count INTEGER, counted_pct TEXT, awards_per_state_value TEXT, awards_per_natl_value REAL, exp_award_state_value TEXT, exp_award_natl_value INTEGER, state_appr_value TEXT, state_appr_rank TEXT, grad_rate_rank TEXT, awards_per_rank TEXT, primary key (stateid, level, control) );
movies_4
Find out the popularity of the movies with the highest vote count.
highest vote count refers to max(vote_count)
SELECT popularity FROM movie ORDER BY vote_COUNT DESC LIMIT 1
CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, country_name TEXT default NULL ); CREATE TABLE department ( department_id INTEGER not null primary key, department_name TEXT default NULL ); CREATE TABLE gender ( gender_id INTEGER not null primary key, gender TEXT default NULL ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL ); CREATE TABLE language ( language_id INTEGER not null primary key, language_code TEXT default NULL, language_name TEXT default NULL ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL ); CREATE TABLE movie ( movie_id INTEGER not null primary key, title TEXT default NULL, budget INTEGER default NULL, homepage TEXT default NULL, overview TEXT default NULL, popularity REAL default NULL, release_date DATE default NULL, revenue INTEGER default NULL, runtime INTEGER default NULL, movie_status TEXT default NULL, tagline TEXT default NULL, vote_average REAL default NULL, vote_count INTEGER default NULL ); CREATE TABLE movie_genres ( movie_id INTEGER default NULL, genre_id INTEGER default NULL, foreign key (genre_id) references genre(genre_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_languages ( movie_id INTEGER default NULL, language_id INTEGER default NULL, language_role_id INTEGER default NULL, foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), foreign key (language_role_id) references language_role(role_id) ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL ); CREATE TABLE movie_crew ( movie_id INTEGER default NULL, person_id INTEGER default NULL, department_id INTEGER default NULL, job TEXT default NULL, foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE production_company ( company_id INTEGER not null primary key, company_name TEXT default NULL ); CREATE TABLE production_country ( movie_id INTEGER default NULL, country_id INTEGER default NULL, foreign key (country_id) references country(country_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_cast ( movie_id INTEGER default NULL, person_id INTEGER default NULL, character_name TEXT default NULL, gender_id INTEGER default NULL, cast_order INTEGER default NULL, foreign key (gender_id) references gender(gender_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE IF NOT EXISTS "movie_keywords" ( movie_id INTEGER default NULL references movie, keyword_id INTEGER default NULL references keyword ); CREATE TABLE IF NOT EXISTS "movie_company" ( movie_id INTEGER default NULL references movie, company_id INTEGER default NULL references production_company );
donor
What is the total price including optional support received by the teacher who posted the essay titled "Recording Rockin' Readers"?
SELECT SUM(T1.total_price_including_optional_support) FROM projects AS T1 INNER JOIN essays AS T2 ON T1.projectid = T2.projectid WHERE T2.title = 'Recording Rockin'' Readers'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "essays" ( projectid TEXT, teacher_acctid TEXT, title TEXT, short_description TEXT, need_statement TEXT, essay TEXT ); CREATE TABLE IF NOT EXISTS "projects" ( projectid TEXT not null primary key, teacher_acctid TEXT, schoolid TEXT, school_ncesid TEXT, school_latitude REAL, school_longitude REAL, school_city TEXT, school_state TEXT, school_zip INTEGER, school_metro TEXT, school_district TEXT, school_county TEXT, school_charter TEXT, school_magnet TEXT, school_year_round TEXT, school_nlns TEXT, school_kipp TEXT, school_charter_ready_promise TEXT, teacher_prefix TEXT, teacher_teach_for_america TEXT, teacher_ny_teaching_fellow TEXT, primary_focus_subject TEXT, primary_focus_area TEXT, secondary_focus_subject TEXT, secondary_focus_area TEXT, resource_type TEXT, poverty_level TEXT, grade_level TEXT, fulfillment_labor_materials REAL, total_price_excluding_optional_support REAL, total_price_including_optional_support REAL, students_reached INTEGER, eligible_double_your_impact_match TEXT, eligible_almost_home_match TEXT, date_posted DATE ); CREATE TABLE donations ( donationid TEXT not null primary key, projectid TEXT, donor_acctid TEXT, donor_city TEXT, donor_state TEXT, donor_zip TEXT, is_teacher_acct TEXT, donation_timestamp DATETIME, donation_to_project REAL, donation_optional_support REAL, donation_total REAL, dollar_amount TEXT, donation_included_optional_support TEXT, payment_method TEXT, payment_included_acct_credit TEXT, payment_included_campaign_gift_card TEXT, payment_included_web_purchased_gift_card TEXT, payment_was_promo_matched TEXT, via_giving_page TEXT, for_honoree TEXT, donation_message TEXT, foreign key (projectid) references projects(projectid) ); CREATE TABLE resources ( resourceid TEXT not null primary key, projectid TEXT, vendorid INTEGER, vendor_name TEXT, project_resource_type TEXT, item_name TEXT, item_number TEXT, item_unit_price REAL, item_quantity INTEGER, foreign key (projectid) references projects(projectid) );
public_review_platform
Among all the users with the average ratings of at least 4 and above of all reviews, calculate the percent that have no fans or followers.
average ratings of at least 4 refers to user_average_stars > = 4; no fans or followers refers to user_fans = 'None'; percentage = divide(count(user_id where user_average_stars > = 4 and user_fans = 'None'), sum(user_id where user_average_stars > = 4))*100%
SELECT CAST(SUM(CASE WHEN user_fans = 'None' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(user_id) FROM Users WHERE user_average_stars >= 4
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
regional_sales
How many CDP stores are there in California?
California is a state; CDP stores refer to StoreID where Type = 'CDP';
SELECT SUM(CASE WHEN State = 'California' AND Type = 'CDP' THEN 1 ELSE 0 END) FROM `Store Locations`
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT constraint Regions_pk primary key, State TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Sales Team" ( SalesTeamID INTEGER constraint "Sales Team_pk" primary key, "Sales Team" TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Store Locations" ( StoreID INTEGER constraint "Store Locations_pk" primary key, "City Name" TEXT, County TEXT, StateCode TEXT constraint "Store Locations_Regions_StateCode_fk" references Regions(StateCode), State TEXT, Type TEXT, Latitude REAL, Longitude REAL, AreaCode INTEGER, Population INTEGER, "Household Income" INTEGER, "Median Income" INTEGER, "Land Area" INTEGER, "Water Area" INTEGER, "Time Zone" TEXT ); CREATE TABLE IF NOT EXISTS "Sales Orders" ( OrderNumber TEXT constraint "Sales Orders_pk" primary key, "Sales Channel" TEXT, WarehouseCode TEXT, ProcuredDate TEXT, OrderDate TEXT, ShipDate TEXT, DeliveryDate TEXT, CurrencyCode TEXT, _SalesTeamID INTEGER constraint "Sales Orders_Sales Team_SalesTeamID_fk" references "Sales Team"(SalesTeamID), _CustomerID INTEGER constraint "Sales Orders_Customers_CustomerID_fk" references Customers(CustomerID), _StoreID INTEGER constraint "Sales Orders_Store Locations_StoreID_fk" references "Store Locations"(StoreID), _ProductID INTEGER constraint "Sales Orders_Products_ProductID_fk" references Products(ProductID), "Order Quantity" INTEGER, "Discount Applied" REAL, "Unit Price" TEXT, "Unit Cost" TEXT );
books
Indicate the ISBN13 of all the books that have less than 140 pages and more than 135.
ISBN13 refers to isbn13; less than 140 pages and more than 135 refers to num_pages > 135 AND num_pages < 140;
SELECT isbn13 FROM book WHERE num_pages < 140 AND num_pages > 135
CREATE TABLE address_status ( status_id INTEGER primary key, address_status TEXT ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT ); CREATE TABLE book_language ( language_id INTEGER primary key, language_code TEXT, language_name TEXT ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT ); CREATE TABLE address ( address_id INTEGER primary key, street_number TEXT, street_name TEXT, city TEXT, country_id INTEGER, foreign key (country_id) references country(country_id) ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, last_name TEXT, email TEXT ); CREATE TABLE customer_address ( customer_id INTEGER, address_id INTEGER, status_id INTEGER, primary key (customer_id, address_id), foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id) ); CREATE TABLE order_status ( status_id INTEGER primary key, status_value TEXT ); CREATE TABLE publisher ( publisher_id INTEGER primary key, publisher_name TEXT ); CREATE TABLE book ( book_id INTEGER primary key, title TEXT, isbn13 TEXT, language_id INTEGER, num_pages INTEGER, publication_date DATE, publisher_id INTEGER, foreign key (language_id) references book_language(language_id), foreign key (publisher_id) references publisher(publisher_id) ); CREATE TABLE book_author ( book_id INTEGER, author_id INTEGER, primary key (book_id, author_id), foreign key (author_id) references author(author_id), foreign key (book_id) references book(book_id) ); CREATE TABLE shipping_method ( method_id INTEGER primary key, method_name TEXT, cost REAL ); CREATE TABLE IF NOT EXISTS "cust_order" ( order_id INTEGER primary key autoincrement, order_date DATETIME, customer_id INTEGER references customer, shipping_method_id INTEGER references shipping_method, dest_address_id INTEGER references address ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "order_history" ( history_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, status_id INTEGER references order_status, status_date DATETIME ); CREATE TABLE IF NOT EXISTS "order_line" ( line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, book_id INTEGER references book, price REAL );
social_media
Give the number of users who do not show their genders.
do not show their gender refers to Gender = 'Unknown'
SELECT COUNT(UserID) AS user_number FROM user WHERE Gender = 'Unknown'
CREATE TABLE location ( LocationID INTEGER constraint location_pk primary key, Country TEXT, State TEXT, StateCode TEXT, City TEXT ); CREATE TABLE user ( UserID TEXT constraint user_pk primary key, Gender TEXT ); CREATE TABLE twitter ( TweetID TEXT primary key, Weekday TEXT, Hour INTEGER, Day INTEGER, Lang TEXT, IsReshare TEXT, Reach INTEGER, RetweetCount INTEGER, Likes INTEGER, Klout INTEGER, Sentiment REAL, "text" TEXT, LocationID INTEGER, UserID TEXT, foreign key (LocationID) references location(LocationID), foreign key (UserID) references user(UserID) );
mondial_geo
What form of governance does the least prosperous nation in the world have?
Nation and country are synonyms; Form of governance was mentioned in politics.Government; Least prosperous means lowest GDP
SELECT T3.Government FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country INNER JOIN politics AS T3 ON T3.Country = T2.Country WHERE T2.GDP IS NOT NULL ORDER BY T2.GDP ASC LIMIT 1
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
hockey
In 2006, what is the overall number of october defeats for the team with the most October defeats? Indicate the team ID.
team ID refers to tmID; 'defeats' and 'loses' are synonyms; most October defeats refers to max(OctL)
SELECT OctL, tmID FROM TeamSplits WHERE year = '2006' ORDER BY OctL DESC LIMIT 1
CREATE TABLE AwardsMisc ( name TEXT not null primary key, ID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT ); CREATE TABLE HOF ( year INTEGER, hofID TEXT not null primary key, name TEXT, category TEXT ); CREATE TABLE Teams ( year INTEGER not null, lgID TEXT, tmID TEXT not null, franchID TEXT, confID TEXT, divID TEXT, rank INTEGER, playoff TEXT, G INTEGER, W INTEGER, L INTEGER, T INTEGER, OTL TEXT, Pts INTEGER, SoW TEXT, SoL TEXT, GF INTEGER, GA INTEGER, name TEXT, PIM TEXT, BenchMinor TEXT, PPG TEXT, PPC TEXT, SHA TEXT, PKG TEXT, PKC TEXT, SHF TEXT, primary key (year, tmID) ); CREATE TABLE Coaches ( coachID TEXT not null, year INTEGER not null, tmID TEXT not null, lgID TEXT, stint INTEGER not null, notes TEXT, g INTEGER, w INTEGER, l INTEGER, t INTEGER, postg TEXT, postw TEXT, postl TEXT, postt TEXT, primary key (coachID, year, tmID, stint), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE AwardsCoaches ( coachID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT, foreign key (coachID) references Coaches (coachID) ); CREATE TABLE Master ( playerID TEXT, coachID TEXT, hofID TEXT, firstName TEXT, lastName TEXT not null, nameNote TEXT, nameGiven TEXT, nameNick TEXT, height TEXT, weight TEXT, shootCatch TEXT, legendsID TEXT, ihdbID TEXT, hrefID TEXT, firstNHL TEXT, lastNHL TEXT, firstWHA TEXT, lastWHA TEXT, pos TEXT, birthYear TEXT, birthMon TEXT, birthDay TEXT, birthCountry TEXT, birthState TEXT, birthCity TEXT, deathYear TEXT, deathMon TEXT, deathDay TEXT, deathCountry TEXT, deathState TEXT, deathCity TEXT, foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade ); CREATE TABLE AwardsPlayers ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT, note TEXT, pos TEXT, primary key (playerID, award, year), foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE CombinedShutouts ( year INTEGER, month INTEGER, date INTEGER, tmID TEXT, oppID TEXT, "R/P" TEXT, IDgoalie1 TEXT, IDgoalie2 TEXT, foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE Goalies ( playerID TEXT not null, year INTEGER not null, stint INTEGER not null, tmID TEXT, lgID TEXT, GP TEXT, Min TEXT, W TEXT, L TEXT, "T/OL" TEXT, ENG TEXT, SHO TEXT, GA TEXT, SA TEXT, PostGP TEXT, PostMin TEXT, PostW TEXT, PostL TEXT, PostT TEXT, PostENG TEXT, PostSHO TEXT, PostGA TEXT, PostSA TEXT, primary key (playerID, year, stint), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE GoaliesSC ( playerID TEXT not null, year INTEGER not null, tmID TEXT, lgID TEXT, GP INTEGER, Min INTEGER, W INTEGER, L INTEGER, T INTEGER, SHO INTEGER, GA INTEGER, primary key (playerID, year), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE GoaliesShootout ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, W INTEGER, L INTEGER, SA INTEGER, GA INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE Scoring ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, lgID TEXT, pos TEXT, GP INTEGER, G INTEGER, A INTEGER, Pts INTEGER, PIM INTEGER, "+/-" TEXT, PPG TEXT, PPA TEXT, SHG TEXT, SHA TEXT, GWG TEXT, GTG TEXT, SOG TEXT, PostGP TEXT, PostG TEXT, PostA TEXT, PostPts TEXT, PostPIM TEXT, "Post+/-" TEXT, PostPPG TEXT, PostPPA TEXT, PostSHG TEXT, PostSHA TEXT, PostGWG TEXT, PostSOG TEXT, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringSC ( playerID TEXT, year INTEGER, tmID TEXT, lgID TEXT, pos TEXT, GP INTEGER, G INTEGER, A INTEGER, Pts INTEGER, PIM INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringShootout ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, S INTEGER, G INTEGER, GDG INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringSup ( playerID TEXT, year INTEGER, PPA TEXT, SHA TEXT, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE SeriesPost ( year INTEGER, round TEXT, series TEXT, tmIDWinner TEXT, lgIDWinner TEXT, tmIDLoser TEXT, lgIDLoser TEXT, W INTEGER, L INTEGER, T INTEGER, GoalsWinner INTEGER, GoalsLoser INTEGER, note TEXT, foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamSplits ( year INTEGER not null, lgID TEXT, tmID TEXT not null, hW INTEGER, hL INTEGER, hT INTEGER, hOTL TEXT, rW INTEGER, rL INTEGER, rT INTEGER, rOTL TEXT, SepW TEXT, SepL TEXT, SepT TEXT, SepOL TEXT, OctW TEXT, OctL TEXT, OctT TEXT, OctOL TEXT, NovW TEXT, NovL TEXT, NovT TEXT, NovOL TEXT, DecW TEXT, DecL TEXT, DecT TEXT, DecOL TEXT, JanW INTEGER, JanL INTEGER, JanT INTEGER, JanOL TEXT, FebW INTEGER, FebL INTEGER, FebT INTEGER, FebOL TEXT, MarW TEXT, MarL TEXT, MarT TEXT, MarOL TEXT, AprW TEXT, AprL TEXT, AprT TEXT, AprOL TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamVsTeam ( year INTEGER not null, lgID TEXT, tmID TEXT not null, oppID TEXT not null, W INTEGER, L INTEGER, T INTEGER, OTL TEXT, primary key (year, tmID, oppID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE TeamsHalf ( year INTEGER not null, lgID TEXT, tmID TEXT not null, half INTEGER not null, rank INTEGER, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, primary key (year, tmID, half), foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE TeamsPost ( year INTEGER not null, lgID TEXT, tmID TEXT not null, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, PIM TEXT, BenchMinor TEXT, PPG TEXT, PPC TEXT, SHA TEXT, PKG TEXT, PKC TEXT, SHF TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamsSC ( year INTEGER not null, lgID TEXT, tmID TEXT not null, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, PIM TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE abbrev ( Type TEXT not null, Code TEXT not null, Fullname TEXT, primary key (Type, Code) );
address
Tell the name of the county which is represented by Hartzler Vicky.
name of county refers to county
SELECT T1.county FROM country AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code INNER JOIN congress AS T3 ON T2.district = T3.cognress_rep_id WHERE T3.first_name = 'Hartzler' AND T3.last_name = 'Vicky' GROUP BY T1.county
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name TEXT, CID TEXT, party TEXT, state TEXT, abbreviation TEXT, House TEXT, District INTEGER, land_area REAL, foreign key (abbreviation) references state(abbreviation) ); CREATE TABLE zip_data ( zip_code INTEGER primary key, city TEXT, state TEXT, multi_county TEXT, type TEXT, organization TEXT, time_zone TEXT, daylight_savings TEXT, latitude REAL, longitude REAL, elevation INTEGER, state_fips INTEGER, county_fips INTEGER, region TEXT, division TEXT, population_2020 INTEGER, population_2010 INTEGER, households INTEGER, avg_house_value INTEGER, avg_income_per_household INTEGER, persons_per_household REAL, white_population INTEGER, black_population INTEGER, hispanic_population INTEGER, asian_population INTEGER, american_indian_population INTEGER, hawaiian_population INTEGER, other_population INTEGER, male_population INTEGER, female_population INTEGER, median_age REAL, male_median_age REAL, female_median_age REAL, residential_mailboxes INTEGER, business_mailboxes INTEGER, total_delivery_receptacles INTEGER, businesses INTEGER, "1st_quarter_payroll" INTEGER, annual_payroll INTEGER, employees INTEGER, water_area REAL, land_area REAL, single_family_delivery_units INTEGER, multi_family_delivery_units INTEGER, total_beneficiaries INTEGER, retired_workers INTEGER, disabled_workers INTEGER, parents_and_widowed INTEGER, spouses INTEGER, children INTEGER, over_65 INTEGER, monthly_benefits_all INTEGER, monthly_benefits_retired_workers INTEGER, monthly_benefits_widowed INTEGER, CBSA INTEGER, foreign key (state) references state(abbreviation), foreign key (CBSA) references CBSA(CBSA) ); CREATE TABLE alias ( zip_code INTEGER primary key, alias TEXT, foreign key (zip_code) references zip_data(zip_code) ); CREATE TABLE area_code ( zip_code INTEGER, area_code INTEGER, primary key (zip_code, area_code), foreign key (zip_code) references zip_data(zip_code) ); CREATE TABLE avoid ( zip_code INTEGER, bad_alias TEXT, primary key (zip_code, bad_alias), foreign key (zip_code) references zip_data(zip_code) ); CREATE TABLE country ( zip_code INTEGER, county TEXT, state TEXT, primary key (zip_code, county), foreign key (zip_code) references zip_data(zip_code), foreign key (state) references state(abbreviation) ); CREATE TABLE zip_congress ( zip_code INTEGER, district TEXT, primary key (zip_code, district), foreign key (district) references congress(cognress_rep_id), foreign key (zip_code) references zip_data(zip_code) );
public_review_platform
How many businesses have shopping centers and received high review count?
"Shopping Centers" is the category_name; high review count refers to review_count = 'High'
SELECT COUNT(T2.business_id) FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name = 'Shopping Centers' AND T3.review_count = 'High'
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
donor
Which project have the highest total price including optional support? Indicate the project id.
highest total price including optional support refers to max(total_price_including_optional_support)
SELECT projectid FROM projects ORDER BY total_price_including_optional_support DESC LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "essays" ( projectid TEXT, teacher_acctid TEXT, title TEXT, short_description TEXT, need_statement TEXT, essay TEXT ); CREATE TABLE IF NOT EXISTS "projects" ( projectid TEXT not null primary key, teacher_acctid TEXT, schoolid TEXT, school_ncesid TEXT, school_latitude REAL, school_longitude REAL, school_city TEXT, school_state TEXT, school_zip INTEGER, school_metro TEXT, school_district TEXT, school_county TEXT, school_charter TEXT, school_magnet TEXT, school_year_round TEXT, school_nlns TEXT, school_kipp TEXT, school_charter_ready_promise TEXT, teacher_prefix TEXT, teacher_teach_for_america TEXT, teacher_ny_teaching_fellow TEXT, primary_focus_subject TEXT, primary_focus_area TEXT, secondary_focus_subject TEXT, secondary_focus_area TEXT, resource_type TEXT, poverty_level TEXT, grade_level TEXT, fulfillment_labor_materials REAL, total_price_excluding_optional_support REAL, total_price_including_optional_support REAL, students_reached INTEGER, eligible_double_your_impact_match TEXT, eligible_almost_home_match TEXT, date_posted DATE ); CREATE TABLE donations ( donationid TEXT not null primary key, projectid TEXT, donor_acctid TEXT, donor_city TEXT, donor_state TEXT, donor_zip TEXT, is_teacher_acct TEXT, donation_timestamp DATETIME, donation_to_project REAL, donation_optional_support REAL, donation_total REAL, dollar_amount TEXT, donation_included_optional_support TEXT, payment_method TEXT, payment_included_acct_credit TEXT, payment_included_campaign_gift_card TEXT, payment_included_web_purchased_gift_card TEXT, payment_was_promo_matched TEXT, via_giving_page TEXT, for_honoree TEXT, donation_message TEXT, foreign key (projectid) references projects(projectid) ); CREATE TABLE resources ( resourceid TEXT not null primary key, projectid TEXT, vendorid INTEGER, vendor_name TEXT, project_resource_type TEXT, item_name TEXT, item_number TEXT, item_unit_price REAL, item_quantity INTEGER, foreign key (projectid) references projects(projectid) );
movie_3
Indicate the name of the actors of the films rated as 'Parents Strongly Precautioned' with the highest replacement cost.
name refers to first_name, last_name; Parents Strongly Precautioned' refers to rating = 'PG-13'; highest replacement cost refers to MAX(replacement_cost)
SELECT T1.first_name, T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.rating = 'PG-13' ORDER BY T3.replacement_cost DESC LIMIT 1
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
social_media
Among all the users that have posted a tweet with over 1000 likes, how many of them are male?
over 1000 likes refers to Likes > 1000; 'Male' is the Gender of user
SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.Likes > 10 AND T2.Gender = 'Male'
CREATE TABLE location ( LocationID INTEGER constraint location_pk primary key, Country TEXT, State TEXT, StateCode TEXT, City TEXT ); CREATE TABLE user ( UserID TEXT constraint user_pk primary key, Gender TEXT ); CREATE TABLE twitter ( TweetID TEXT primary key, Weekday TEXT, Hour INTEGER, Day INTEGER, Lang TEXT, IsReshare TEXT, Reach INTEGER, RetweetCount INTEGER, Likes INTEGER, Klout INTEGER, Sentiment REAL, "text" TEXT, LocationID INTEGER, UserID TEXT, foreign key (LocationID) references location(LocationID), foreign key (UserID) references user(UserID) );
synthea
Provide the allergen of the Dominican patient named Dirk Languish.
allergen refers to allergies.DESCRIPTION;
SELECT T1.DESCRIPTION FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Dirk' AND T2.last = 'Langosh' AND T2.ethnicity = 'dominican'
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ); CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ); CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ); CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE IF NOT EXISTS "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER );
books
How many addresses are from the Philippines?
"Philippines" is the country_name
SELECT COUNT(T2.country_id) FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Philippines'
CREATE TABLE address_status ( status_id INTEGER primary key, address_status TEXT ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT ); CREATE TABLE book_language ( language_id INTEGER primary key, language_code TEXT, language_name TEXT ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT ); CREATE TABLE address ( address_id INTEGER primary key, street_number TEXT, street_name TEXT, city TEXT, country_id INTEGER, foreign key (country_id) references country(country_id) ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, last_name TEXT, email TEXT ); CREATE TABLE customer_address ( customer_id INTEGER, address_id INTEGER, status_id INTEGER, primary key (customer_id, address_id), foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id) ); CREATE TABLE order_status ( status_id INTEGER primary key, status_value TEXT ); CREATE TABLE publisher ( publisher_id INTEGER primary key, publisher_name TEXT ); CREATE TABLE book ( book_id INTEGER primary key, title TEXT, isbn13 TEXT, language_id INTEGER, num_pages INTEGER, publication_date DATE, publisher_id INTEGER, foreign key (language_id) references book_language(language_id), foreign key (publisher_id) references publisher(publisher_id) ); CREATE TABLE book_author ( book_id INTEGER, author_id INTEGER, primary key (book_id, author_id), foreign key (author_id) references author(author_id), foreign key (book_id) references book(book_id) ); CREATE TABLE shipping_method ( method_id INTEGER primary key, method_name TEXT, cost REAL ); CREATE TABLE IF NOT EXISTS "cust_order" ( order_id INTEGER primary key autoincrement, order_date DATETIME, customer_id INTEGER references customer, shipping_method_id INTEGER references shipping_method, dest_address_id INTEGER references address ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "order_history" ( history_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, status_id INTEGER references order_status, status_date DATETIME ); CREATE TABLE IF NOT EXISTS "order_line" ( line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, book_id INTEGER references book, price REAL );
talkingdata
How many users are there in the Home Decoration category?
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_all` ( `app_id` INTEGER NOT NULL, PRIMARY KEY (`app_id`) ); CREATE TABLE `app_events` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_events_relevant` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER DEFAULT NULL, `is_active` INTEGER DEFAULT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_labels` ( `app_id` INTEGER NOT NULL, `label_id` INTEGER NOT NULL, FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `events` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME DEFAULT NULL, `longitude` REAL DEFAULT NULL, `latitude` REAL DEFAULT NULL, PRIMARY KEY (`event_id`) ); CREATE TABLE `events_relevant` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME NOT NULL, `longitude` REAL NOT NULL, `latitude` REAL NOT NULL, PRIMARY KEY (`event_id`), FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`), FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age_test` ( `device_id` INTEGER NOT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `gender_age_train` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `label_categories` ( `label_id` INTEGER NOT NULL, `category` TEXT DEFAULT NULL, PRIMARY KEY (`label_id`) ); CREATE TABLE `phone_brand_device_model2` ( `device_id` INTEGER NOT NULL, `phone_brand` TEXT NOT NULL, `device_model` TEXT NOT NULL, PRIMARY KEY (`device_id`,`phone_brand`,`device_model`) ); CREATE TABLE `sample_submission` ( `device_id` INTEGER NOT NULL, `F23-` REAL DEFAULT NULL, `F24-26` REAL DEFAULT NULL, `F27-28` REAL DEFAULT NULL, `F29-32` REAL DEFAULT NULL, `F33-42` REAL DEFAULT NULL, `F43+` REAL DEFAULT NULL, `M22-` REAL DEFAULT NULL, `M23-26` REAL DEFAULT NULL, `M27-28` REAL DEFAULT NULL, `M29-31` REAL DEFAULT NULL, `M32-38` REAL DEFAULT NULL, `M39+` REAL DEFAULT NULL, PRIMARY KEY (`device_id`) );
public_review_platform
Among the Yelp_Businesses in Arizona, how many of them do not provide alcohol?
Arizona refers to state = 'AZ'; do not provide alcohol refers to attribute_name = 'Alcohol' and attribute_value = 'none'
SELECT COUNT(T2.business_id) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.attribute_name LIKE 'Alcohol' AND T2.attribute_value LIKE 'none' AND T3.state LIKE 'AZ'
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
university
How many criteria are associated with ranking system Center for World University Rankings?
ranking system Center for World University Rankings refers to system_name = 'Center for World University Rankings';
SELECT COUNT(T2.criteria_name) FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Center for World University Rankings'
CREATE TABLE country ( id INTEGER not null primary key, country_name TEXT default NULL ); CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, criteria_name TEXT default NULL, foreign key (ranking_system_id) references ranking_system(id) ); CREATE TABLE university ( id INTEGER not null primary key, country_id INTEGER default NULL, university_name TEXT default NULL, foreign key (country_id) references country(id) ); CREATE TABLE university_ranking_year ( university_id INTEGER default NULL, ranking_criteria_id INTEGER default NULL, year INTEGER default NULL, score INTEGER default NULL, foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id) ); CREATE TABLE university_year ( university_id INTEGER default NULL, year INTEGER default NULL, num_students INTEGER default NULL, student_staff_ratio REAL default NULL, pct_international_students INTEGER default NULL, pct_female_students INTEGER default NULL, foreign key (university_id) references university(id) );
olympics
For Peter Kohnke, show the name of his/her region.
name of his/her region refers to region_name;
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 = 'Peter Kohnke'
CREATE TABLE city ( id INTEGER not null primary key, city_name TEXT default NULL ); CREATE TABLE games ( id INTEGER not null primary key, games_year INTEGER default NULL, games_name TEXT default NULL, season TEXT default NULL ); CREATE TABLE games_city ( games_id INTEGER default NULL, city_id INTEGER default NULL, foreign key (city_id) references city(id), foreign key (games_id) references games(id) ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL ); CREATE TABLE noc_region ( id INTEGER not null primary key, noc TEXT default NULL, region_name TEXT default NULL ); CREATE TABLE person ( id INTEGER not null primary key, full_name TEXT default NULL, gender TEXT default NULL, height INTEGER default NULL, weight INTEGER default NULL ); CREATE TABLE games_competitor ( id INTEGER not null primary key, games_id INTEGER default NULL, person_id INTEGER default NULL, age INTEGER default NULL, foreign key (games_id) references games(id), foreign key (person_id) references person(id) ); CREATE TABLE person_region ( person_id INTEGER default NULL, region_id INTEGER default NULL, foreign key (person_id) references person(id), foreign key (region_id) references noc_region(id) ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL ); CREATE TABLE event ( id INTEGER not null primary key, sport_id INTEGER default NULL, event_name TEXT default NULL, foreign key (sport_id) references sport(id) ); CREATE TABLE competitor_event ( event_id INTEGER default NULL, competitor_id INTEGER default NULL, medal_id INTEGER default NULL, foreign key (competitor_id) references games_competitor(id), foreign key (event_id) references event(id), foreign key (medal_id) references medal(id) );
movielens
How many drama movie with the rating of 3?
SELECT COUNT(DISTINCT T2.movieid) FROM u2base AS T1 INNER JOIN movies2directors AS T2 ON T1.movieid = T2.movieid WHERE T2.genre = 'drama' AND T1.rating = 3
CREATE TABLE users ( userid INTEGER default 0 not null primary key, age TEXT not null, u_gender TEXT not null, occupation TEXT not null ); CREATE TABLE IF NOT EXISTS "directors" ( directorid INTEGER not null primary key, d_quality INTEGER not null, avg_revenue INTEGER not null ); CREATE INDEX avg_revenue on directors (avg_revenue); CREATE INDEX d_quality on directors (d_quality); CREATE TABLE IF NOT EXISTS "actors" ( actorid INTEGER not null primary key, a_gender TEXT not null, a_quality INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies" ( movieid INTEGER default 0 not null primary key, year INTEGER not null, isEnglish TEXT not null, country TEXT not null, runningtime INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies2actors" ( movieid INTEGER not null references movies on update cascade on delete cascade, actorid INTEGER not null references actors on update cascade on delete cascade, cast_num INTEGER not null, primary key (movieid, actorid) ); CREATE TABLE IF NOT EXISTS "movies2directors" ( movieid INTEGER not null references movies on update cascade on delete cascade, directorid INTEGER not null references directors on update cascade on delete cascade, genre TEXT not null, primary key (movieid, directorid) ); CREATE TABLE IF NOT EXISTS "u2base" ( userid INTEGER default 0 not null references users on update cascade on delete cascade, movieid INTEGER not null references movies on update cascade on delete cascade, rating TEXT not null, primary key (userid, movieid) );
talkingdata
How many female users use device model of MI 3?
female refers to gender = 'F';
SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' AND T2.device_model = 'MI 3'
CREATE TABLE `app_all` ( `app_id` INTEGER NOT NULL, PRIMARY KEY (`app_id`) ); CREATE TABLE `app_events` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_events_relevant` ( `event_id` INTEGER NOT NULL, `app_id` INTEGER NOT NULL, `is_installed` INTEGER DEFAULT NULL, `is_active` INTEGER DEFAULT NULL, PRIMARY KEY (`event_id`,`app_id`), FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `app_labels` ( `app_id` INTEGER NOT NULL, `label_id` INTEGER NOT NULL, FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `events` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME DEFAULT NULL, `longitude` REAL DEFAULT NULL, `latitude` REAL DEFAULT NULL, PRIMARY KEY (`event_id`) ); CREATE TABLE `events_relevant` ( `event_id` INTEGER NOT NULL, `device_id` INTEGER DEFAULT NULL, `timestamp` DATETIME NOT NULL, `longitude` REAL NOT NULL, `latitude` REAL NOT NULL, PRIMARY KEY (`event_id`), FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`), FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE `gender_age_test` ( `device_id` INTEGER NOT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `gender_age_train` ( `device_id` INTEGER NOT NULL, `gender` TEXT DEFAULT NULL, `age` INTEGER DEFAULT NULL, `group` TEXT DEFAULT NULL, PRIMARY KEY (`device_id`) ); CREATE TABLE `label_categories` ( `label_id` INTEGER NOT NULL, `category` TEXT DEFAULT NULL, PRIMARY KEY (`label_id`) ); CREATE TABLE `phone_brand_device_model2` ( `device_id` INTEGER NOT NULL, `phone_brand` TEXT NOT NULL, `device_model` TEXT NOT NULL, PRIMARY KEY (`device_id`,`phone_brand`,`device_model`) ); CREATE TABLE `sample_submission` ( `device_id` INTEGER NOT NULL, `F23-` REAL DEFAULT NULL, `F24-26` REAL DEFAULT NULL, `F27-28` REAL DEFAULT NULL, `F29-32` REAL DEFAULT NULL, `F33-42` REAL DEFAULT NULL, `F43+` REAL DEFAULT NULL, `M22-` REAL DEFAULT NULL, `M23-26` REAL DEFAULT NULL, `M27-28` REAL DEFAULT NULL, `M29-31` REAL DEFAULT NULL, `M32-38` REAL DEFAULT NULL, `M39+` REAL DEFAULT NULL, PRIMARY KEY (`device_id`) );
college_completion
In the state of Connecticut, what is the name of the instution with the highest percent rank for freshman retention percentage within the sector?
name of the institution refers to chronname;  highest percent rank for freshman retention percentage within the sector refers to MAX(retain_percentile);
SELECT chronname FROM institution_details WHERE state = 'Connecticut' AND retain_percentile = ( SELECT MAX(retain_percentile) FROM institution_details WHERE state = 'Connecticut' )
CREATE TABLE institution_details ( unitid INTEGER constraint institution_details_pk primary key, chronname TEXT, city TEXT, state TEXT, level TEXT, control TEXT, basic TEXT, hbcu TEXT, flagship TEXT, long_x REAL, lat_y REAL, site TEXT, student_count INTEGER, awards_per_value REAL, awards_per_state_value REAL, awards_per_natl_value REAL, exp_award_value INTEGER, exp_award_state_value INTEGER, exp_award_natl_value INTEGER, exp_award_percentile INTEGER, ft_pct REAL, fte_value INTEGER, fte_percentile INTEGER, med_sat_value TEXT, med_sat_percentile TEXT, aid_value INTEGER, aid_percentile INTEGER, endow_value TEXT, endow_percentile TEXT, grad_100_value REAL, grad_100_percentile INTEGER, grad_150_value REAL, grad_150_percentile INTEGER, pell_value REAL, pell_percentile INTEGER, retain_value REAL, retain_percentile INTEGER, ft_fac_value REAL, ft_fac_percentile INTEGER, vsa_year TEXT, vsa_grad_after4_first TEXT, vsa_grad_elsewhere_after4_first TEXT, vsa_enroll_after4_first TEXT, vsa_enroll_elsewhere_after4_first TEXT, vsa_grad_after6_first TEXT, vsa_grad_elsewhere_after6_first TEXT, vsa_enroll_after6_first TEXT, vsa_enroll_elsewhere_after6_first TEXT, vsa_grad_after4_transfer TEXT, vsa_grad_elsewhere_after4_transfer TEXT, vsa_enroll_after4_transfer TEXT, vsa_enroll_elsewhere_after4_transfer TEXT, vsa_grad_after6_transfer TEXT, vsa_grad_elsewhere_after6_transfer TEXT, vsa_enroll_after6_transfer TEXT, vsa_enroll_elsewhere_after6_transfer TEXT, similar TEXT, state_sector_ct INTEGER, carnegie_ct INTEGER, counted_pct TEXT, nicknames TEXT, cohort_size INTEGER ); CREATE TABLE institution_grads ( unitid INTEGER, year INTEGER, gender TEXT, race TEXT, cohort TEXT, grad_cohort TEXT, grad_100 TEXT, grad_150 TEXT, grad_100_rate TEXT, grad_150_rate TEXT, foreign key (unitid) references institution_details(unitid) ); CREATE TABLE state_sector_grads ( stateid INTEGER, state TEXT, state_abbr TEXT, control TEXT, level TEXT, year INTEGER, gender TEXT, race TEXT, cohort TEXT, grad_cohort TEXT, grad_100 TEXT, grad_150 TEXT, grad_100_rate TEXT, grad_150_rate TEXT, grad_cohort_ct INTEGER, foreign key (state) references institution_details(state), foreign key (stateid) references state_sector_details(stateid) ); CREATE TABLE IF NOT EXISTS "state_sector_details" ( stateid INTEGER, state TEXT references institution_details (state), state_post TEXT, level TEXT, control TEXT, schools_count INTEGER, counted_pct TEXT, awards_per_state_value TEXT, awards_per_natl_value REAL, exp_award_state_value TEXT, exp_award_natl_value INTEGER, state_appr_value TEXT, state_appr_rank TEXT, grad_rate_rank TEXT, awards_per_rank TEXT, primary key (stateid, level, control) );
restaurant
What are the most popular restaurants in San Francisco among diners?
the most popular refers to max(review); restaurant refers to label; San Francisco refers to city = 'San Francisco'
SELECT id_restaurant, label FROM generalinfo WHERE city = 'San Francisco' AND review = ( SELECT MAX(review) FROM generalinfo WHERE city = 'San Francisco' )
CREATE TABLE geographic ( city TEXT not null primary key, county TEXT null, region TEXT null ); CREATE TABLE generalinfo ( id_restaurant INTEGER not null primary key, label TEXT null, food_type TEXT null, city TEXT null, review REAL null, foreign key (city) references geographic(city) on update cascade on delete cascade ); CREATE TABLE location ( id_restaurant INTEGER not null primary key, street_num INTEGER null, street_name TEXT null, city TEXT null, foreign key (city) references geographic (city) on update cascade on delete cascade, foreign key (id_restaurant) references generalinfo (id_restaurant) on update cascade on delete cascade );
public_review_platform
How many short tips were left for the business with ID no.2?
short tip refers to tip_length = 'Short'; business category refers to category_name
SELECT COUNT(business_id) FROM Tips WHERE business_id = 2 AND tip_length = 'Short'
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
regional_sales
How much more is the Florida store's computer product unit price than the Texas store?
"Florida" and "Texas" are both the name of State; Computer product refers to Product Name = 'Computers; difference in unit price = Subtract (Unit Price where State = 'Florida', Unit Price where State = 'Texas')
SELECT SUM(CASE WHEN T3.State = 'Florida' THEN T2.`Unit Price` ELSE 0 END) - SUM(CASE WHEN T3.State = 'Texas' THEN T2.`Unit Price` ELSE 0 END) FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` AS T3 ON T3.StoreID = T2._StoreID WHERE T1.`Product Name` = 'Computers'
CREATE TABLE Customers ( CustomerID INTEGER constraint Customers_pk primary key, "Customer Names" TEXT ); CREATE TABLE Products ( ProductID INTEGER constraint Products_pk primary key, "Product Name" TEXT ); CREATE TABLE Regions ( StateCode TEXT constraint Regions_pk primary key, State TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Sales Team" ( SalesTeamID INTEGER constraint "Sales Team_pk" primary key, "Sales Team" TEXT, Region TEXT ); CREATE TABLE IF NOT EXISTS "Store Locations" ( StoreID INTEGER constraint "Store Locations_pk" primary key, "City Name" TEXT, County TEXT, StateCode TEXT constraint "Store Locations_Regions_StateCode_fk" references Regions(StateCode), State TEXT, Type TEXT, Latitude REAL, Longitude REAL, AreaCode INTEGER, Population INTEGER, "Household Income" INTEGER, "Median Income" INTEGER, "Land Area" INTEGER, "Water Area" INTEGER, "Time Zone" TEXT ); CREATE TABLE IF NOT EXISTS "Sales Orders" ( OrderNumber TEXT constraint "Sales Orders_pk" primary key, "Sales Channel" TEXT, WarehouseCode TEXT, ProcuredDate TEXT, OrderDate TEXT, ShipDate TEXT, DeliveryDate TEXT, CurrencyCode TEXT, _SalesTeamID INTEGER constraint "Sales Orders_Sales Team_SalesTeamID_fk" references "Sales Team"(SalesTeamID), _CustomerID INTEGER constraint "Sales Orders_Customers_CustomerID_fk" references Customers(CustomerID), _StoreID INTEGER constraint "Sales Orders_Store Locations_StoreID_fk" references "Store Locations"(StoreID), _ProductID INTEGER constraint "Sales Orders_Products_ProductID_fk" references Products(ProductID), "Order Quantity" INTEGER, "Discount Applied" REAL, "Unit Price" TEXT, "Unit Cost" TEXT );
public_review_platform
How many businesses are opened for 24 hours?
opened for 24 hours refers to attribute_name = 'Open 24 Hours' AND attribute_value = 'true'
SELECT COUNT(T2.business_id) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T2.attribute_value LIKE 'TRUE' AND T1.attribute_name LIKE 'Open 24 Hours'
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
olympics
How many people who are below 30 and participated in the summer season?
people who are below 30 refer to person_id where age < 30; the summer season refers to season = 'Summer';
SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.season = 'Summer' AND T2.age < 30
CREATE TABLE city ( id INTEGER not null primary key, city_name TEXT default NULL ); CREATE TABLE games ( id INTEGER not null primary key, games_year INTEGER default NULL, games_name TEXT default NULL, season TEXT default NULL ); CREATE TABLE games_city ( games_id INTEGER default NULL, city_id INTEGER default NULL, foreign key (city_id) references city(id), foreign key (games_id) references games(id) ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL ); CREATE TABLE noc_region ( id INTEGER not null primary key, noc TEXT default NULL, region_name TEXT default NULL ); CREATE TABLE person ( id INTEGER not null primary key, full_name TEXT default NULL, gender TEXT default NULL, height INTEGER default NULL, weight INTEGER default NULL ); CREATE TABLE games_competitor ( id INTEGER not null primary key, games_id INTEGER default NULL, person_id INTEGER default NULL, age INTEGER default NULL, foreign key (games_id) references games(id), foreign key (person_id) references person(id) ); CREATE TABLE person_region ( person_id INTEGER default NULL, region_id INTEGER default NULL, foreign key (person_id) references person(id), foreign key (region_id) references noc_region(id) ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL ); CREATE TABLE event ( id INTEGER not null primary key, sport_id INTEGER default NULL, event_name TEXT default NULL, foreign key (sport_id) references sport(id) ); CREATE TABLE competitor_event ( event_id INTEGER default NULL, competitor_id INTEGER default NULL, medal_id INTEGER default NULL, foreign key (competitor_id) references games_competitor(id), foreign key (event_id) references event(id), foreign key (medal_id) references medal(id) );
menu
Provide the sponsor and event of the menu which includes Cerealine with Milk.
Cerealine with Milk is a name of dish;
SELECT T3.name, T3.event FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T4.name = 'Cerealine with Milk'
CREATE TABLE Dish ( id INTEGER primary key, name TEXT, description TEXT, menus_appeared INTEGER, times_appeared INTEGER, first_appeared INTEGER, last_appeared INTEGER, lowest_price REAL, highest_price REAL ); CREATE TABLE Menu ( id INTEGER primary key, name TEXT, sponsor TEXT, event TEXT, venue TEXT, place TEXT, physical_description TEXT, occasion TEXT, notes TEXT, call_number TEXT, keywords TEXT, language TEXT, date DATE, location TEXT, location_type TEXT, currency TEXT, currency_symbol TEXT, status TEXT, page_count INTEGER, dish_count INTEGER ); CREATE TABLE MenuPage ( id INTEGER primary key, menu_id INTEGER, page_number INTEGER, image_id REAL, full_height INTEGER, full_width INTEGER, uuid TEXT, foreign key (menu_id) references Menu(id) ); CREATE TABLE MenuItem ( id INTEGER primary key, menu_page_id INTEGER, price REAL, high_price REAL, dish_id INTEGER, created_at TEXT, updated_at TEXT, xpos REAL, ypos REAL, foreign key (dish_id) references Dish(id), foreign key (menu_page_id) references MenuPage(id) );
ice_hockey_draft
How tall is the player from Yale University who picked up 28 penalty minutes in the 2005-2006 season?
how tall refers to height_in_cm; Yale University refers to TEAM = 'Yale Univ.'; 28 penalty minutes refers to PIM = '28'; 2005-2006 season refers to SEASON = '2005-2006';
SELECT T3.height_in_cm FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID INNER JOIN height_info AS T3 ON T2.height = T3.height_id WHERE T1.SEASON = '2005-2006' AND T1.TEAM = 'Yale Univ.' AND T1.PIM = 28
CREATE TABLE height_info ( height_id INTEGER primary key, height_in_cm INTEGER, height_in_inch TEXT ); CREATE TABLE weight_info ( weight_id INTEGER primary key, weight_in_kg INTEGER, weight_in_lbs INTEGER ); CREATE TABLE PlayerInfo ( ELITEID INTEGER primary key, PlayerName TEXT, birthdate TEXT, birthyear DATE, birthmonth INTEGER, birthday INTEGER, birthplace TEXT, nation TEXT, height INTEGER, weight INTEGER, position_info TEXT, shoots TEXT, draftyear INTEGER, draftround INTEGER, overall INTEGER, overallby TEXT, CSS_rank INTEGER, sum_7yr_GP INTEGER, sum_7yr_TOI INTEGER, GP_greater_than_0 TEXT, foreign key (height) references height_info(height_id), foreign key (weight) references weight_info(weight_id) ); CREATE TABLE SeasonStatus ( ELITEID INTEGER, SEASON TEXT, TEAM TEXT, LEAGUE TEXT, GAMETYPE TEXT, GP INTEGER, G INTEGER, A INTEGER, P INTEGER, PIM INTEGER, PLUSMINUS INTEGER, foreign key (ELITEID) references PlayerInfo(ELITEID) );
soccer_2016
How many matches were there in May, 2008?
in May 2008 refers to SUBSTR(Match_Date, 1, 4) = '2008' AND SUBSTR(Match_Date, 7, 1) = '5'
SELECT COUNT(Match_Id) FROM `Match` WHERE SUBSTR(Match_Date, 1, 4) = '2008' AND SUBSTR(Match_Date, 7, 1) = '5'
CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT ); CREATE TABLE Bowling_Style ( Bowling_Id INTEGER primary key, Bowling_skill TEXT ); CREATE TABLE City ( City_Id INTEGER primary key, City_Name TEXT, Country_id INTEGER ); CREATE TABLE Country ( Country_Id INTEGER primary key, Country_Name TEXT, foreign key (Country_Id) references Country(Country_Id) ); CREATE TABLE Extra_Type ( Extra_Id INTEGER primary key, Extra_Name TEXT ); CREATE TABLE Extra_Runs ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Extra_Type_Id INTEGER, Extra_Runs INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Extra_Type_Id) references Extra_Type(Extra_Id) ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT ); CREATE TABLE Outcome ( Outcome_Id INTEGER primary key, Outcome_Type TEXT ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, DOB DATE, Batting_hand INTEGER, Bowling_skill INTEGER, Country_Name INTEGER, foreign key (Batting_hand) references Batting_Style(Batting_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), foreign key (Country_Name) references Country(Country_Id) ); CREATE TABLE Rolee ( Role_Id INTEGER primary key, Role_Desc TEXT ); CREATE TABLE Season ( Season_Id INTEGER primary key, Man_of_the_Series INTEGER, Orange_Cap INTEGER, Purple_Cap INTEGER, Season_Year INTEGER ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT ); CREATE TABLE Umpire ( Umpire_Id INTEGER primary key, Umpire_Name TEXT, Umpire_Country INTEGER, foreign key (Umpire_Country) references Country(Country_Id) ); CREATE TABLE Venue ( Venue_Id INTEGER primary key, Venue_Name TEXT, City_Id INTEGER, foreign key (City_Id) references City(City_Id) ); CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT ); CREATE TABLE Match ( Match_Id INTEGER primary key, Team_1 INTEGER, Team_2 INTEGER, Match_Date DATE, Season_Id INTEGER, Venue_Id INTEGER, Toss_Winner INTEGER, Toss_Decide INTEGER, Win_Type INTEGER, Win_Margin INTEGER, Outcome_type INTEGER, Match_Winner INTEGER, Man_of_the_Match INTEGER, foreign key (Team_1) references Team(Team_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Season_Id) references Season(Season_Id), foreign key (Venue_Id) references Venue(Venue_Id), foreign key (Toss_Winner) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Match_Winner) references Team(Team_Id), foreign key (Man_of_the_Match) references Player(Player_Id) ); CREATE TABLE Ball_by_Ball ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Innings_No INTEGER, Team_Batting INTEGER, Team_Bowling INTEGER, Striker_Batting_Position INTEGER, Striker INTEGER, Non_Striker INTEGER, Bowler INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id) ); CREATE TABLE Batsman_Scored ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Runs_Scored INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id) ); CREATE TABLE Player_Match ( Match_Id INTEGER, Player_Id INTEGER, Role_Id INTEGER, Team_Id INTEGER, primary key (Match_Id, Player_Id, Role_Id), foreign key (Match_Id) references Match(Match_Id), foreign key (Player_Id) references Player(Player_Id), foreign key (Team_Id) references Team(Team_Id), foreign key (Role_Id) references Rolee(Role_Id) ); CREATE TABLE Wicket_Taken ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Player_Out INTEGER, Kind_Out INTEGER, Fielders INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id), foreign key (Player_Out) references Player(Player_Id), foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id) );
airline
List the air carrier description and code of the flight with the shortest arrival time.
shortest arrival time refers to MIN(ARR_TIME);
SELECT T1.Description, T1.Code FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID ORDER BY T2.ARR_TIME ASC LIMIT 1
CREATE TABLE IF NOT EXISTS "Air Carriers" ( Code INTEGER primary key, Description TEXT ); CREATE TABLE Airports ( Code TEXT primary key, Description TEXT ); CREATE TABLE Airlines ( FL_DATE TEXT, OP_CARRIER_AIRLINE_ID INTEGER, TAIL_NUM TEXT, OP_CARRIER_FL_NUM INTEGER, ORIGIN_AIRPORT_ID INTEGER, ORIGIN_AIRPORT_SEQ_ID INTEGER, ORIGIN_CITY_MARKET_ID INTEGER, ORIGIN TEXT, DEST_AIRPORT_ID INTEGER, DEST_AIRPORT_SEQ_ID INTEGER, DEST_CITY_MARKET_ID INTEGER, DEST TEXT, CRS_DEP_TIME INTEGER, DEP_TIME INTEGER, DEP_DELAY INTEGER, DEP_DELAY_NEW INTEGER, ARR_TIME INTEGER, ARR_DELAY INTEGER, ARR_DELAY_NEW INTEGER, CANCELLED INTEGER, CANCELLATION_CODE TEXT, CRS_ELAPSED_TIME INTEGER, ACTUAL_ELAPSED_TIME INTEGER, CARRIER_DELAY INTEGER, WEATHER_DELAY INTEGER, NAS_DELAY INTEGER, SECURITY_DELAY INTEGER, LATE_AIRCRAFT_DELAY INTEGER, FOREIGN KEY (ORIGIN) REFERENCES Airports(Code), FOREIGN KEY (DEST) REFERENCES Airports(Code), FOREIGN KEY (OP_CARRIER_AIRLINE_ID) REFERENCES "Air Carriers"(Code) );
retail_world
What territories is the Inside Sales Coordinator in charge of?
territories refer to TerritoryDescription; Title = 'Inside Sales Coordinator';
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.Title = 'Inside Sales Coordinator'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
professional_basketball
Among the winning game from the team, what is the percentage of the winning was home game.
percentage of winning at the home = Divide(homeWon, won) * 100
SELECT CAST(homeWon AS REAL) * 100 / won FROM teams
CREATE TABLE awards_players ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT null, note TEXT null, pos TEXT null, primary key (playerID, year, award), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE coaches ( coachID TEXT not null, year INTEGER not null, tmID TEXT not null, lgID TEXT null, stint INTEGER not null, won INTEGER null, lost INTEGER null, post_wins INTEGER null, post_losses INTEGER null, primary key (coachID, year, tmID, stint), foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE draft ( id INTEGER default 0 not null primary key, draftYear INTEGER null, draftRound INTEGER null, draftSelection INTEGER null, draftOverall INTEGER null, tmID TEXT null, firstName TEXT null, lastName TEXT null, suffixName TEXT null, playerID TEXT null, draftFrom TEXT null, lgID TEXT null, foreign key (tmID, draftYear) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE player_allstar ( playerID TEXT not null, last_name TEXT null, first_name TEXT null, season_id INTEGER not null, conference TEXT null, league_id TEXT null, games_played INTEGER null, minutes INTEGER null, points INTEGER null, o_rebounds INTEGER null, d_rebounds INTEGER null, rebounds INTEGER null, assists INTEGER null, steals INTEGER null, blocks INTEGER null, turnovers INTEGER null, personal_fouls INTEGER null, fg_attempted INTEGER null, fg_made INTEGER null, ft_attempted INTEGER null, ft_made INTEGER null, three_attempted INTEGER null, three_made INTEGER null, primary key (playerID, season_id), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE players ( playerID TEXT not null primary key, useFirst TEXT null, firstName TEXT null, middleName TEXT null, lastName TEXT null, nameGiven TEXT null, fullGivenName TEXT null, nameSuffix TEXT null, nameNick TEXT null, pos TEXT null, firstseason INTEGER null, lastseason INTEGER null, height REAL null, weight INTEGER null, college TEXT null, collegeOther TEXT null, birthDate DATE null, birthCity TEXT null, birthState TEXT null, birthCountry TEXT null, highSchool TEXT null, hsCity TEXT null, hsState TEXT null, hsCountry TEXT null, deathDate DATE null, race TEXT null ); CREATE TABLE teams ( year INTEGER not null, lgID TEXT null, tmID TEXT not null, franchID TEXT null, confID TEXT null, divID TEXT null, `rank` INTEGER null, confRank INTEGER null, playoff TEXT null, name TEXT null, o_fgm INTEGER null, -- o_fga int null, o_ftm INTEGER null, -- o_fta int null, -- o_3pm int null, -- o_3pa int null, -- o_oreb int null, -- o_dreb int null, -- o_reb int null, -- o_asts int null, -- o_pf int null, -- o_stl int null, -- o_to int null, -- o_blk int null, o_pts INTEGER null, -- d_fgm int null, -- d_fga int null, -- d_ftm int null, -- d_fta int null, -- d_3pm int null, -- d_3pa int null, -- d_oreb int null, -- d_dreb int null, -- d_reb int null, -- d_asts int null, -- d_pf int null, -- d_stl int null, -- d_to int null, -- d_blk int null, d_pts INTEGER null, -- o_tmRebound int null, -- d_tmRebound int null, homeWon INTEGER null, homeLost INTEGER null, awayWon INTEGER null, awayLost INTEGER null, -- neutWon int null, -- neutLoss int null, -- confWon int null, -- confLoss int null, -- divWon int null, -- divLoss int null, -- pace int null, won INTEGER null, lost INTEGER null, games INTEGER null, -- min int null, arena TEXT null, -- attendance int null, -- bbtmID varchar(255) null, primary key (year, tmID) ); CREATE TABLE IF NOT EXISTS "awards_coaches" ( id INTEGER primary key autoincrement, year INTEGER, coachID TEXT, award TEXT, lgID TEXT, note TEXT, foreign key (coachID, year) references coaches (coachID, year) on update cascade on delete cascade ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "players_teams" ( id INTEGER primary key autoincrement, playerID TEXT not null references players on update cascade on delete cascade, year INTEGER, stint INTEGER, tmID TEXT, lgID TEXT, GP INTEGER, GS INTEGER, minutes INTEGER, points INTEGER, oRebounds INTEGER, dRebounds INTEGER, rebounds INTEGER, assists INTEGER, steals INTEGER, blocks INTEGER, turnovers INTEGER, PF INTEGER, fgAttempted INTEGER, fgMade INTEGER, ftAttempted INTEGER, ftMade INTEGER, threeAttempted INTEGER, threeMade INTEGER, PostGP INTEGER, PostGS INTEGER, PostMinutes INTEGER, PostPoints INTEGER, PostoRebounds INTEGER, PostdRebounds INTEGER, PostRebounds INTEGER, PostAssists INTEGER, PostSteals INTEGER, PostBlocks INTEGER, PostTurnovers INTEGER, PostPF INTEGER, PostfgAttempted INTEGER, PostfgMade INTEGER, PostftAttempted INTEGER, PostftMade INTEGER, PostthreeAttempted INTEGER, PostthreeMade INTEGER, note TEXT, foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "series_post" ( id INTEGER primary key autoincrement, year INTEGER, round TEXT, series TEXT, tmIDWinner TEXT, lgIDWinner TEXT, tmIDLoser TEXT, lgIDLoser TEXT, W INTEGER, L INTEGER, foreign key (tmIDWinner, year) references teams (tmID, year) on update cascade on delete cascade, foreign key (tmIDLoser, year) references teams (tmID, year) on update cascade on delete cascade );
car_retails
Which customer made the order No. 10160? Give the contact name.
SELECT t2.contactFirstName, t2.contactLastName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.orderNumber = '10160'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ); CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ); CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ); CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ); CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ); CREATE TABLE IF NOT EXISTS "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) );
mondial_geo
What is the population of the country with the highest infant mortality rate?
SELECT T1.Population FROM country AS T1 INNER JOIN population AS T2 ON T1.Code = T2.Country ORDER BY T2.Infant_Mortality DESC LIMIT 1
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
world
What is the life expectancy of the countries that uses Japanese as their language?
uses Japanese as their language refers to `Language` = 'Japanese';
SELECT AVG(T2.LifeExpectancy) FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Language = 'Japanese'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE `City` ( `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `Name` TEXT NOT NULL DEFAULT '', `CountryCode` TEXT NOT NULL DEFAULT '', `District` TEXT NOT NULL DEFAULT '', `Population` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`) ); CREATE TABLE `Country` ( `Code` TEXT NOT NULL DEFAULT '', `Name` TEXT NOT NULL DEFAULT '', `Continent` TEXT NOT NULL DEFAULT 'Asia', `Region` TEXT NOT NULL DEFAULT '', `SurfaceArea` REAL NOT NULL DEFAULT 0.00, `IndepYear` INTEGER DEFAULT NULL, `Population` INTEGER NOT NULL DEFAULT 0, `LifeExpectancy` REAL DEFAULT NULL, `GNP` REAL DEFAULT NULL, `GNPOld` REAL DEFAULT NULL, `LocalName` TEXT NOT NULL DEFAULT '', `GovernmentForm` TEXT NOT NULL DEFAULT '', `HeadOfState` TEXT DEFAULT NULL, `Capital` INTEGER DEFAULT NULL, `Code2` TEXT NOT NULL DEFAULT '', PRIMARY KEY (`Code`) ); CREATE TABLE `CountryLanguage` ( `CountryCode` TEXT NOT NULL DEFAULT '', `Language` TEXT NOT NULL DEFAULT '', `IsOfficial`TEXT NOT NULL DEFAULT 'F', `Percentage` REAL NOT NULL DEFAULT 0.0, PRIMARY KEY (`CountryCode`,`Language`), FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`) );
mondial_geo
What is the peak height of the highest volcanic type of mountain? Give it's name.
peak means the highest
SELECT Height, Name FROM mountain WHERE Type = 'volcanic' ORDER BY Height DESC LIMIT 1
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
professional_basketball
Among the NBA winning coaches, which are from STL team? Please list their coach id.
NBA refers to lgID = 'NBA'; STL team refers to tmID = 'STL'
SELECT DISTINCT T2.coachID FROM coaches AS T1 INNER JOIN awards_coaches AS T2 ON T1.coachID = T2.coachID WHERE T1.tmID = 'STL' AND T1.lgID = 'NBA'
CREATE TABLE awards_players ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT null, note TEXT null, pos TEXT null, primary key (playerID, year, award), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE coaches ( coachID TEXT not null, year INTEGER not null, tmID TEXT not null, lgID TEXT null, stint INTEGER not null, won INTEGER null, lost INTEGER null, post_wins INTEGER null, post_losses INTEGER null, primary key (coachID, year, tmID, stint), foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE draft ( id INTEGER default 0 not null primary key, draftYear INTEGER null, draftRound INTEGER null, draftSelection INTEGER null, draftOverall INTEGER null, tmID TEXT null, firstName TEXT null, lastName TEXT null, suffixName TEXT null, playerID TEXT null, draftFrom TEXT null, lgID TEXT null, foreign key (tmID, draftYear) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE player_allstar ( playerID TEXT not null, last_name TEXT null, first_name TEXT null, season_id INTEGER not null, conference TEXT null, league_id TEXT null, games_played INTEGER null, minutes INTEGER null, points INTEGER null, o_rebounds INTEGER null, d_rebounds INTEGER null, rebounds INTEGER null, assists INTEGER null, steals INTEGER null, blocks INTEGER null, turnovers INTEGER null, personal_fouls INTEGER null, fg_attempted INTEGER null, fg_made INTEGER null, ft_attempted INTEGER null, ft_made INTEGER null, three_attempted INTEGER null, three_made INTEGER null, primary key (playerID, season_id), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE players ( playerID TEXT not null primary key, useFirst TEXT null, firstName TEXT null, middleName TEXT null, lastName TEXT null, nameGiven TEXT null, fullGivenName TEXT null, nameSuffix TEXT null, nameNick TEXT null, pos TEXT null, firstseason INTEGER null, lastseason INTEGER null, height REAL null, weight INTEGER null, college TEXT null, collegeOther TEXT null, birthDate DATE null, birthCity TEXT null, birthState TEXT null, birthCountry TEXT null, highSchool TEXT null, hsCity TEXT null, hsState TEXT null, hsCountry TEXT null, deathDate DATE null, race TEXT null ); CREATE TABLE teams ( year INTEGER not null, lgID TEXT null, tmID TEXT not null, franchID TEXT null, confID TEXT null, divID TEXT null, `rank` INTEGER null, confRank INTEGER null, playoff TEXT null, name TEXT null, o_fgm INTEGER null, -- o_fga int null, o_ftm INTEGER null, -- o_fta int null, -- o_3pm int null, -- o_3pa int null, -- o_oreb int null, -- o_dreb int null, -- o_reb int null, -- o_asts int null, -- o_pf int null, -- o_stl int null, -- o_to int null, -- o_blk int null, o_pts INTEGER null, -- d_fgm int null, -- d_fga int null, -- d_ftm int null, -- d_fta int null, -- d_3pm int null, -- d_3pa int null, -- d_oreb int null, -- d_dreb int null, -- d_reb int null, -- d_asts int null, -- d_pf int null, -- d_stl int null, -- d_to int null, -- d_blk int null, d_pts INTEGER null, -- o_tmRebound int null, -- d_tmRebound int null, homeWon INTEGER null, homeLost INTEGER null, awayWon INTEGER null, awayLost INTEGER null, -- neutWon int null, -- neutLoss int null, -- confWon int null, -- confLoss int null, -- divWon int null, -- divLoss int null, -- pace int null, won INTEGER null, lost INTEGER null, games INTEGER null, -- min int null, arena TEXT null, -- attendance int null, -- bbtmID varchar(255) null, primary key (year, tmID) ); CREATE TABLE IF NOT EXISTS "awards_coaches" ( id INTEGER primary key autoincrement, year INTEGER, coachID TEXT, award TEXT, lgID TEXT, note TEXT, foreign key (coachID, year) references coaches (coachID, year) on update cascade on delete cascade ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "players_teams" ( id INTEGER primary key autoincrement, playerID TEXT not null references players on update cascade on delete cascade, year INTEGER, stint INTEGER, tmID TEXT, lgID TEXT, GP INTEGER, GS INTEGER, minutes INTEGER, points INTEGER, oRebounds INTEGER, dRebounds INTEGER, rebounds INTEGER, assists INTEGER, steals INTEGER, blocks INTEGER, turnovers INTEGER, PF INTEGER, fgAttempted INTEGER, fgMade INTEGER, ftAttempted INTEGER, ftMade INTEGER, threeAttempted INTEGER, threeMade INTEGER, PostGP INTEGER, PostGS INTEGER, PostMinutes INTEGER, PostPoints INTEGER, PostoRebounds INTEGER, PostdRebounds INTEGER, PostRebounds INTEGER, PostAssists INTEGER, PostSteals INTEGER, PostBlocks INTEGER, PostTurnovers INTEGER, PostPF INTEGER, PostfgAttempted INTEGER, PostfgMade INTEGER, PostftAttempted INTEGER, PostftMade INTEGER, PostthreeAttempted INTEGER, PostthreeMade INTEGER, note TEXT, foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "series_post" ( id INTEGER primary key autoincrement, year INTEGER, round TEXT, series TEXT, tmIDWinner TEXT, lgIDWinner TEXT, tmIDLoser TEXT, lgIDLoser TEXT, W INTEGER, L INTEGER, foreign key (tmIDWinner, year) references teams (tmID, year) on update cascade on delete cascade, foreign key (tmIDLoser, year) references teams (tmID, year) on update cascade on delete cascade );
sales
Count the total quantity for sales from id 1 to 10.
sales from id 1 to 10 refers to SalesID BETWEEN 1 AND 10;
SELECT SUM(Quantity) FROM Sales WHERE SalesID BETWEEN 1 AND 10
CREATE TABLE Customers ( CustomerID INTEGER not null primary key, FirstName TEXT not null, MiddleInitial TEXT null, LastName TEXT not null ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, FirstName TEXT not null, MiddleInitial TEXT null, LastName TEXT not null ); CREATE TABLE Products ( ProductID INTEGER not null primary key, Name TEXT not null, Price REAL null ); CREATE TABLE Sales ( SalesID INTEGER not null primary key, SalesPersonID INTEGER not null, CustomerID INTEGER not null, ProductID INTEGER not null, Quantity INTEGER not null, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade );
works_cycles
What product has the fewest online orders from one customer? List the product's class, line of business, and list price.
fewest online orders refer to MIN(Quantity);
SELECT T2.Class, T2.ProductLine, T2.ListPrice FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY SUM(Quantity) LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ( CultureID TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Currency ( CurrencyCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE CountryRegionCurrency ( CountryRegionCode TEXT not null, CurrencyCode TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (CountryRegionCode, CurrencyCode), foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode), foreign key (CurrencyCode) references Currency(CurrencyCode) ); CREATE TABLE Person ( BusinessEntityID INTEGER not null primary key, PersonType TEXT not null, NameStyle INTEGER default 0 not null, Title TEXT, FirstName TEXT not null, MiddleName TEXT, LastName TEXT not null, Suffix TEXT, EmailPromotion INTEGER default 0 not null, AdditionalContactInfo TEXT, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE BusinessEntityContact ( BusinessEntityID INTEGER not null, PersonID INTEGER not null, ContactTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, PersonID, ContactTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (ContactTypeID) references ContactType(ContactTypeID), foreign key (PersonID) references Person(BusinessEntityID) ); CREATE TABLE EmailAddress ( BusinessEntityID INTEGER not null, EmailAddressID INTEGER, EmailAddress TEXT, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (EmailAddressID, BusinessEntityID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Employee ( BusinessEntityID INTEGER not null primary key, NationalIDNumber TEXT not null unique, LoginID TEXT not null unique, OrganizationNode TEXT, OrganizationLevel INTEGER, JobTitle TEXT not null, BirthDate DATE not null, MaritalStatus TEXT not null, Gender TEXT not null, HireDate DATE not null, SalariedFlag INTEGER default 1 not null, VacationHours INTEGER default 0 not null, SickLeaveHours INTEGER default 0 not null, CurrentFlag INTEGER default 1 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Password ( BusinessEntityID INTEGER not null primary key, PasswordHash TEXT not null, PasswordSalt TEXT not null, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE PersonCreditCard ( BusinessEntityID INTEGER not null, CreditCardID INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, CreditCardID), foreign key (CreditCardID) references CreditCard(CreditCardID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE ProductCategory ( ProductCategoryID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductDescription ( ProductDescriptionID INTEGER primary key autoincrement, Description TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModel ( ProductModelID INTEGER primary key autoincrement, Name TEXT not null unique, CatalogDescription TEXT, Instructions TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModelProductDescriptionCulture ( ProductModelID INTEGER not null, ProductDescriptionID INTEGER not null, CultureID TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductModelID, ProductDescriptionID, CultureID), foreign key (ProductModelID) references ProductModel(ProductModelID), foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID), foreign key (CultureID) references Culture(CultureID) ); CREATE TABLE ProductPhoto ( ProductPhotoID INTEGER primary key autoincrement, ThumbNailPhoto BLOB, ThumbnailPhotoFileName TEXT, LargePhoto BLOB, LargePhotoFileName TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductSubcategory ( ProductSubcategoryID INTEGER primary key autoincrement, ProductCategoryID INTEGER not null, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID) ); CREATE TABLE SalesReason ( SalesReasonID INTEGER primary key autoincrement, Name TEXT not null, ReasonType TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SalesTerritory ( TerritoryID INTEGER primary key autoincrement, Name TEXT not null unique, CountryRegionCode TEXT not null, "Group" TEXT not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, CostYTD REAL default 0.0000 not null, CostLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode) ); CREATE TABLE SalesPerson ( BusinessEntityID INTEGER not null primary key, TerritoryID INTEGER, SalesQuota REAL, Bonus REAL default 0.0000 not null, CommissionPct REAL default 0.0000 not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references Employee(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE SalesPersonQuotaHistory ( BusinessEntityID INTEGER not null, QuotaDate DATETIME not null, SalesQuota REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, QuotaDate), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesTerritoryHistory ( BusinessEntityID INTEGER not null, TerritoryID INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, StartDate, TerritoryID), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE ScrapReason ( ScrapReasonID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE Shift ( ShiftID INTEGER primary key autoincrement, Name TEXT not null unique, StartTime TEXT not null, EndTime TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StartTime, EndTime) ); CREATE TABLE ShipMethod ( ShipMethodID INTEGER primary key autoincrement, Name TEXT not null unique, ShipBase REAL default 0.0000 not null, ShipRate REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SpecialOffer ( SpecialOfferID INTEGER primary key autoincrement, Description TEXT not null, DiscountPct REAL default 0.0000 not null, Type TEXT not null, Category TEXT not null, StartDate DATETIME not null, EndDate DATETIME not null, MinQty INTEGER default 0 not null, MaxQty INTEGER, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE BusinessEntityAddress ( BusinessEntityID INTEGER not null, AddressID INTEGER not null, AddressTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, AddressID, AddressTypeID), foreign key (AddressID) references Address(AddressID), foreign key (AddressTypeID) references AddressType(AddressTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE SalesTaxRate ( SalesTaxRateID INTEGER primary key autoincrement, StateProvinceID INTEGER not null, TaxType INTEGER not null, TaxRate REAL default 0.0000 not null, Name TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceID, TaxType), foreign key (StateProvinceID) references StateProvince(StateProvinceID) ); CREATE TABLE Store ( BusinessEntityID INTEGER not null primary key, Name TEXT not null, SalesPersonID INTEGER, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (SalesPersonID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesOrderHeaderSalesReason ( SalesOrderID INTEGER not null, SalesReasonID INTEGER not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SalesOrderID, SalesReasonID), foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SalesReasonID) references SalesReason(SalesReasonID) ); CREATE TABLE TransactionHistoryArchive ( TransactionID INTEGER not null primary key, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE UnitMeasure ( UnitMeasureCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductCostHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, StandardCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ProductDocument ( ProductID INTEGER not null, DocumentNode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, DocumentNode), foreign key (ProductID) references Product(ProductID), foreign key (DocumentNode) references Document(DocumentNode) ); CREATE TABLE ProductInventory ( ProductID INTEGER not null, LocationID INTEGER not null, Shelf TEXT not null, Bin INTEGER not null, Quantity INTEGER default 0 not null, rowguid TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, LocationID), foreign key (ProductID) references Product(ProductID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE ProductProductPhoto ( ProductID INTEGER not null, ProductPhotoID INTEGER not null, "Primary" INTEGER default 0 not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, ProductPhotoID), foreign key (ProductID) references Product(ProductID), foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID) ); CREATE TABLE ProductReview ( ProductReviewID INTEGER primary key autoincrement, ProductID INTEGER not null, ReviewerName TEXT not null, ReviewDate DATETIME default CURRENT_TIMESTAMP not null, EmailAddress TEXT not null, Rating INTEGER not null, Comments TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ShoppingCartItem ( ShoppingCartItemID INTEGER primary key autoincrement, ShoppingCartID TEXT not null, Quantity INTEGER default 1 not null, ProductID INTEGER not null, DateCreated DATETIME default CURRENT_TIMESTAMP not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SpecialOfferProduct ( SpecialOfferID INTEGER not null, ProductID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SpecialOfferID, ProductID), foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SalesOrderDetail ( SalesOrderID INTEGER not null, SalesOrderDetailID INTEGER primary key autoincrement, CarrierTrackingNumber TEXT, OrderQty INTEGER not null, ProductID INTEGER not null, SpecialOfferID INTEGER not null, UnitPrice REAL not null, UnitPriceDiscount REAL default 0.0000 not null, LineTotal REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID) ); CREATE TABLE TransactionHistory ( TransactionID INTEGER primary key autoincrement, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE Vendor ( BusinessEntityID INTEGER not null primary key, AccountNumber TEXT not null unique, Name TEXT not null, CreditRating INTEGER not null, PreferredVendorStatus INTEGER default 1 not null, ActiveFlag INTEGER default 1 not null, PurchasingWebServiceURL TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE ProductVendor ( ProductID INTEGER not null, BusinessEntityID INTEGER not null, AverageLeadTime INTEGER not null, StandardPrice REAL not null, LastReceiptCost REAL, LastReceiptDate DATETIME, MinOrderQty INTEGER not null, MaxOrderQty INTEGER not null, OnOrderQty INTEGER, UnitMeasureCode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, BusinessEntityID), foreign key (ProductID) references Product(ProductID), foreign key (BusinessEntityID) references Vendor(BusinessEntityID), foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode) ); CREATE TABLE PurchaseOrderHeader ( PurchaseOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, Status INTEGER default 1 not null, EmployeeID INTEGER not null, VendorID INTEGER not null, ShipMethodID INTEGER not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, ShipDate DATETIME, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (EmployeeID) references Employee(BusinessEntityID), foreign key (VendorID) references Vendor(BusinessEntityID), foreign key (ShipMethodID) references ShipMethod(ShipMethodID) ); CREATE TABLE PurchaseOrderDetail ( PurchaseOrderID INTEGER not null, PurchaseOrderDetailID INTEGER primary key autoincrement, DueDate DATETIME not null, OrderQty INTEGER not null, ProductID INTEGER not null, UnitPrice REAL not null, LineTotal REAL not null, ReceivedQty REAL not null, RejectedQty REAL not null, StockedQty REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE WorkOrder ( WorkOrderID INTEGER primary key autoincrement, ProductID INTEGER not null, OrderQty INTEGER not null, StockedQty INTEGER not null, ScrappedQty INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, DueDate DATETIME not null, ScrapReasonID INTEGER, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID), foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID) ); CREATE TABLE WorkOrderRouting ( WorkOrderID INTEGER not null, ProductID INTEGER not null, OperationSequence INTEGER not null, LocationID INTEGER not null, ScheduledStartDate DATETIME not null, ScheduledEndDate DATETIME not null, ActualStartDate DATETIME, ActualEndDate DATETIME, ActualResourceHrs REAL, PlannedCost REAL not null, ActualCost REAL, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (WorkOrderID, ProductID, OperationSequence), foreign key (WorkOrderID) references WorkOrder(WorkOrderID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE Customer ( CustomerID INTEGER primary key, PersonID INTEGER, StoreID INTEGER, TerritoryID INTEGER, AccountNumber TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (PersonID) references Person(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID), foreign key (StoreID) references Store(BusinessEntityID) ); CREATE TABLE ProductListPriceHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, ListPrice REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE IF NOT EXISTS "Address" ( AddressID INTEGER primary key autoincrement, AddressLine1 TEXT not null, AddressLine2 TEXT, City TEXT not null, StateProvinceID INTEGER not null references StateProvince, PostalCode TEXT not null, SpatialLocation TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode) ); CREATE TABLE IF NOT EXISTS "AddressType" ( AddressTypeID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "BillOfMaterials" ( BillOfMaterialsID INTEGER primary key autoincrement, ProductAssemblyID INTEGER references Product, ComponentID INTEGER not null references Product, StartDate DATETIME default current_timestamp not null, EndDate DATETIME, UnitMeasureCode TEXT not null references UnitMeasure, BOMLevel INTEGER not null, PerAssemblyQty REAL default 1.00 not null, ModifiedDate DATETIME default current_timestamp not null, unique (ProductAssemblyID, ComponentID, StartDate) ); CREATE TABLE IF NOT EXISTS "BusinessEntity" ( BusinessEntityID INTEGER primary key autoincrement, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "ContactType" ( ContactTypeID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "CurrencyRate" ( CurrencyRateID INTEGER primary key autoincrement, CurrencyRateDate DATETIME not null, FromCurrencyCode TEXT not null references Currency, ToCurrencyCode TEXT not null references Currency, AverageRate REAL not null, EndOfDayRate REAL not null, ModifiedDate DATETIME default current_timestamp not null, unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode) ); CREATE TABLE IF NOT EXISTS "Department" ( DepartmentID INTEGER primary key autoincrement, Name TEXT not null unique, GroupName TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory" ( BusinessEntityID INTEGER not null references Employee, DepartmentID INTEGER not null references Department, ShiftID INTEGER not null references Shift, StartDate DATE not null, EndDate DATE, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID) ); CREATE TABLE IF NOT EXISTS "EmployeePayHistory" ( BusinessEntityID INTEGER not null references Employee, RateChangeDate DATETIME not null, Rate REAL not null, PayFrequency INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, RateChangeDate) ); CREATE TABLE IF NOT EXISTS "JobCandidate" ( JobCandidateID INTEGER primary key autoincrement, BusinessEntityID INTEGER references Employee, Resume TEXT, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Location" ( LocationID INTEGER primary key autoincrement, Name TEXT not null unique, CostRate REAL default 0.0000 not null, Availability REAL default 0.00 not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "PhoneNumberType" ( PhoneNumberTypeID INTEGER primary key autoincrement, Name TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Product" ( ProductID INTEGER primary key autoincrement, Name TEXT not null unique, ProductNumber TEXT not null unique, MakeFlag INTEGER default 1 not null, FinishedGoodsFlag INTEGER default 1 not null, Color TEXT, SafetyStockLevel INTEGER not null, ReorderPoint INTEGER not null, StandardCost REAL not null, ListPrice REAL not null, Size TEXT, SizeUnitMeasureCode TEXT references UnitMeasure, WeightUnitMeasureCode TEXT references UnitMeasure, Weight REAL, DaysToManufacture INTEGER not null, ProductLine TEXT, Class TEXT, Style TEXT, ProductSubcategoryID INTEGER references ProductSubcategory, ProductModelID INTEGER references ProductModel, SellStartDate DATETIME not null, SellEndDate DATETIME, DiscontinuedDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Document" ( DocumentNode TEXT not null primary key, DocumentLevel INTEGER, Title TEXT not null, Owner INTEGER not null references Employee, FolderFlag INTEGER default 0 not null, FileName TEXT not null, FileExtension TEXT not null, Revision TEXT not null, ChangeNumber INTEGER default 0 not null, Status INTEGER not null, DocumentSummary TEXT, Document BLOB, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (DocumentLevel, DocumentNode) ); CREATE TABLE IF NOT EXISTS "StateProvince" ( StateProvinceID INTEGER primary key autoincrement, StateProvinceCode TEXT not null, CountryRegionCode TEXT not null references CountryRegion, IsOnlyStateProvinceFlag INTEGER default 1 not null, Name TEXT not null unique, TerritoryID INTEGER not null references SalesTerritory, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceCode, CountryRegionCode) ); CREATE TABLE IF NOT EXISTS "CreditCard" ( CreditCardID INTEGER primary key autoincrement, CardType TEXT not null, CardNumber TEXT not null unique, ExpMonth INTEGER not null, ExpYear INTEGER not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "SalesOrderHeader" ( SalesOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, DueDate DATETIME not null, ShipDate DATETIME, Status INTEGER default 1 not null, OnlineOrderFlag INTEGER default 1 not null, SalesOrderNumber TEXT not null unique, PurchaseOrderNumber TEXT, AccountNumber TEXT, CustomerID INTEGER not null references Customer, SalesPersonID INTEGER references SalesPerson, TerritoryID INTEGER references SalesTerritory, BillToAddressID INTEGER not null references Address, ShipToAddressID INTEGER not null references Address, ShipMethodID INTEGER not null references Address, CreditCardID INTEGER references CreditCard, CreditCardApprovalCode TEXT, CurrencyRateID INTEGER references CurrencyRate, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, Comment TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null );
student_loan
List all students that have been absent for 6 months.
absent for 6 months `month` = 6;
SELECT name FROM longest_absense_from_school WHERE `month` = 6
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE enlist ( "name" TEXT not null, organ TEXT not null, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE filed_for_bankrupcy ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, "month" INTEGER default 0 null, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE male ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE no_payment_due ( "name" TEXT default '' not null primary key, bool TEXT null, foreign key ("name") references person ("name") on update cascade on delete cascade, foreign key (bool) references bool ("name") on update cascade on delete cascade ); CREATE TABLE unemployed ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade ); CREATE TABLE `enrolled` ( `name` TEXT NOT NULL, `school` TEXT NOT NULL, `month` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (`name`,`school`), FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE );
retail_complains
How many priority urgent complaints were received in march of 2017? List the complaint ID of these complaints.
urgent complaints refers to priority = 2; march of 2017 refers to "Date received" BETWEEN '2017-01-01' AND '2017-01-31';
SELECT COUNT(`Complaint ID`) FROM callcenterlogs WHERE `Date received` LIKE '2017-01%' AND priority = ( SELECT MAX(priority) FROM callcenterlogs )
CREATE TABLE state ( StateCode TEXT constraint state_pk primary key, State TEXT, Region TEXT ); CREATE TABLE callcenterlogs ( "Date received" DATE, "Complaint ID" TEXT, "rand client" TEXT, phonefinal TEXT, "vru+line" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, primary key ("Complaint ID"), foreign key ("rand client") references client(client_id) ); CREATE TABLE client ( client_id TEXT primary key, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, foreign key (district_id) references district(district_id) ); CREATE TABLE district ( district_id INTEGER primary key, city TEXT, state_abbrev TEXT, division TEXT, foreign key (state_abbrev) references state(StateCode) ); CREATE TABLE events ( "Date received" DATE, Product TEXT, "Sub-product" TEXT, Issue TEXT, "Sub-issue" TEXT, "Consumer complaint narrative" TEXT, Tags TEXT, "Consumer consent provided?" TEXT, "Submitted via" TEXT, "Date sent to company" TEXT, "Company response to consumer" TEXT, "Timely response?" TEXT, "Consumer disputed?" TEXT, "Complaint ID" TEXT, Client_ID TEXT, primary key ("Complaint ID", Client_ID), foreign key ("Complaint ID") references callcenterlogs("Complaint ID"), foreign key (Client_ID) references client(client_id) ); CREATE TABLE reviews ( "Date" DATE primary key, Stars INTEGER, Reviews TEXT, Product TEXT, district_id INTEGER, foreign key (district_id) references district(district_id) );
public_review_platform
How many attributes ID owned by business ID 2?
SELECT COUNT(attribute_id) FROM Business_Attributes WHERE business_id = 2
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
video_games
How many games were released in the year 2001?
released in the year 2001 refers to release_year = 2001;
SELECT COUNT(id) FROM game_platform AS T WHERE T.release_year = 2001
CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE game ( id INTEGER not null primary key, genre_id INTEGER default NULL, game_name TEXT default NULL, foreign key (genre_id) references genre(id) ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL ); CREATE TABLE game_publisher ( id INTEGER not null primary key, game_id INTEGER default NULL, publisher_id INTEGER default NULL, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id) ); CREATE TABLE game_platform ( id INTEGER not null primary key, game_publisher_id INTEGER default NULL, platform_id INTEGER default NULL, release_year INTEGER default NULL, foreign key (game_publisher_id) references game_publisher(id), foreign key (platform_id) references platform(id) ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL ); CREATE TABLE region_sales ( region_id INTEGER default NULL, game_platform_id INTEGER default NULL, num_sales REAL default NULL, foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id) );
authors
List the names of all authors affiliated with Birkbeck University of London.
affiliated with Birkbeck University of London refers to Affiliation = 'Birkbeck University of London'
SELECT Name FROM Author WHERE Affiliation = 'Birkbeck University of London'
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE IF NOT EXISTS "Journal" ( Id INTEGER constraint Journal_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE Paper ( Id INTEGER primary key, Title TEXT, Year INTEGER, ConferenceId INTEGER, JournalId INTEGER, Keyword TEXT, foreign key (ConferenceId) references Conference(Id), foreign key (JournalId) references Journal(Id) ); CREATE TABLE PaperAuthor ( PaperId INTEGER, AuthorId INTEGER, Name TEXT, Affiliation TEXT, foreign key (PaperId) references Paper(Id), foreign key (AuthorId) references Author(Id) );
car_retails
How many motorcycles have been ordered in 2004?
Motorcycles refer to productLine = 'motorcycles'; ordered in 2004 refers to year(orderDate) = 2004;
SELECT SUM(t2.quantityOrdered) FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t2.productCode = t3.productCode WHERE t3.productLine = 'motorcycles' AND STRFTIME('%Y', t1.orderDate) = '2004'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ); CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ); CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ); CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ); CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ); CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ); CREATE TABLE IF NOT EXISTS "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) );
computer_student
List the professor ID who taught the course ID from 121 to 130 of basic undergraduate courses.
professor ID refers to taughtBy.p_id; course ID from 121 to 130 of basic undergraduate courses refers to courseLevel = 'Level_300' and course.course_id between 121 and 130
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_300' AND T1.course_id > 121 AND T1.course_id < 130
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT ); CREATE TABLE person ( p_id INTEGER constraint person_pk primary key, professor INTEGER, student INTEGER, hasPosition TEXT, inPhase TEXT, yearsInProgram TEXT ); CREATE TABLE IF NOT EXISTS "advisedBy" ( p_id INTEGER, p_id_dummy INTEGER, constraint advisedBy_pk primary key (p_id, p_id_dummy), constraint advisedBy_person_p_id_p_id_fk foreign key (p_id, p_id_dummy) references person (p_id, p_id) ); CREATE TABLE taughtBy ( course_id INTEGER, p_id INTEGER, primary key (course_id, p_id), foreign key (p_id) references person(p_id), foreign key (course_id) references course(course_id) );
synthea
List the full names of patients with nut allergy.
full names = first, last; nut allergy refers to allergies.DESCRIPTION = 'Allergy to nut';
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to nut'
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ); CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ); CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ); CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ); CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ); CREATE TABLE IF NOT EXISTS "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER );
legislator
Please list the official full names of all the current legislators who have served in the U.S. House.
have served in the U.S. House refers to house_history_id is not null;
SELECT official_full_name FROM current WHERE house_history_id IS NOT NULL
CREATE TABLE current ( ballotpedia_id TEXT, bioguide_id TEXT, birthday_bio DATE, cspan_id REAL, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id REAL, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id INTEGER, votesmart_id REAL, wikidata_id TEXT, wikipedia_id TEXT, primary key (bioguide_id, cspan_id) ); CREATE TABLE IF NOT EXISTS "current-terms" ( address TEXT, bioguide TEXT, caucus TEXT, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, primary key (bioguide, end), foreign key (bioguide) references current(bioguide_id) ); CREATE TABLE historical ( ballotpedia_id TEXT, bioguide_id TEXT primary key, bioguide_previous_id TEXT, birthday_bio TEXT, cspan_id TEXT, fec_id TEXT, first_name TEXT, gender_bio TEXT, google_entity_id_id TEXT, govtrack_id INTEGER, house_history_alternate_id TEXT, house_history_id REAL, icpsr_id REAL, last_name TEXT, lis_id TEXT, maplight_id TEXT, middle_name TEXT, nickname_name TEXT, official_full_name TEXT, opensecrets_id TEXT, religion_bio TEXT, suffix_name TEXT, thomas_id TEXT, votesmart_id TEXT, wikidata_id TEXT, wikipedia_id TEXT ); CREATE TABLE IF NOT EXISTS "historical-terms" ( address TEXT, bioguide TEXT primary key, chamber TEXT, class REAL, contact_form TEXT, district REAL, end TEXT, fax TEXT, last TEXT, middle TEXT, name TEXT, office TEXT, party TEXT, party_affiliations TEXT, phone TEXT, relation TEXT, rss_url TEXT, start TEXT, state TEXT, state_rank TEXT, title TEXT, type TEXT, url TEXT, foreign key (bioguide) references historical(bioguide_id) ); CREATE TABLE IF NOT EXISTS "social-media" ( bioguide TEXT primary key, facebook TEXT, facebook_id REAL, govtrack REAL, instagram TEXT, instagram_id REAL, thomas INTEGER, twitter TEXT, twitter_id REAL, youtube TEXT, youtube_id TEXT, foreign key (bioguide) references current(bioguide_id) );
disney
How many of Gary Trousdale's movies are adventure movies?
Gary Trousdale refers director = 'Gary Trousdale'; the adventure movie refers to genre = 'Adventure';
SELECT COUNT(T.name) FROM ( SELECT T1.name FROM director AS T1 INNER JOIN movies_total_gross AS T2 ON T1.name = T2.movie_title WHERE T1.director = 'Gary Trousdale' AND T2.genre = 'Adventure' GROUP BY T1.name ) T
CREATE TABLE characters ( movie_title TEXT primary key, release_date TEXT, hero TEXT, villian TEXT, song TEXT, foreign key (hero) references "voice-actors"(character) ); CREATE TABLE director ( name TEXT primary key, director TEXT, foreign key (name) references characters(movie_title) ); CREATE TABLE movies_total_gross ( movie_title TEXT, release_date TEXT, genre TEXT, MPAA_rating TEXT, total_gross TEXT, inflation_adjusted_gross TEXT, primary key (movie_title, release_date), foreign key (movie_title) references characters(movie_title) ); CREATE TABLE revenue ( Year INTEGER primary key, "Studio Entertainment[NI 1]" REAL, "Disney Consumer Products[NI 2]" REAL, "Disney Interactive[NI 3][Rev 1]" INTEGER, "Walt Disney Parks and Resorts" REAL, "Disney Media Networks" TEXT, Total INTEGER ); CREATE TABLE IF NOT EXISTS "voice-actors" ( character TEXT primary key, "voice-actor" TEXT, movie TEXT, foreign key (movie) references characters(movie_title) );
retail_complains
List priority 2 complaints by date received.
SELECT DISTINCT `Complaint ID` FROM callcenterlogs WHERE priority = 2 ORDER BY `Date received` DESC
CREATE TABLE state ( StateCode TEXT constraint state_pk primary key, State TEXT, Region TEXT ); CREATE TABLE callcenterlogs ( "Date received" DATE, "Complaint ID" TEXT, "rand client" TEXT, phonefinal TEXT, "vru+line" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, primary key ("Complaint ID"), foreign key ("rand client") references client(client_id) ); CREATE TABLE client ( client_id TEXT primary key, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, foreign key (district_id) references district(district_id) ); CREATE TABLE district ( district_id INTEGER primary key, city TEXT, state_abbrev TEXT, division TEXT, foreign key (state_abbrev) references state(StateCode) ); CREATE TABLE events ( "Date received" DATE, Product TEXT, "Sub-product" TEXT, Issue TEXT, "Sub-issue" TEXT, "Consumer complaint narrative" TEXT, Tags TEXT, "Consumer consent provided?" TEXT, "Submitted via" TEXT, "Date sent to company" TEXT, "Company response to consumer" TEXT, "Timely response?" TEXT, "Consumer disputed?" TEXT, "Complaint ID" TEXT, Client_ID TEXT, primary key ("Complaint ID", Client_ID), foreign key ("Complaint ID") references callcenterlogs("Complaint ID"), foreign key (Client_ID) references client(client_id) ); CREATE TABLE reviews ( "Date" DATE primary key, Stars INTEGER, Reviews TEXT, Product TEXT, district_id INTEGER, foreign key (district_id) references district(district_id) );
retail_world
What is the shipping company for order number 10558?
order number 10558 refers to OrderID = 10558;
SELECT T2.CompanyName FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.OrderID = 10558
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
donor
From the total amount of donation to projects, what is the percentage of the amount is for school projects located in the rural area?
located in the rural area refers to school_metro = 'rural'; percentage = divide(sum(donation_to_project), sum(donation_to_project where school_metro = 'rural'))*100%
SELECT CAST(SUM(CASE WHEN T2.school_metro = 'rural' THEN T1.donation_to_project ELSE 0 END) AS REAL) * 100 / SUM(donation_to_project) FROM donations AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "essays" ( projectid TEXT, teacher_acctid TEXT, title TEXT, short_description TEXT, need_statement TEXT, essay TEXT ); CREATE TABLE IF NOT EXISTS "projects" ( projectid TEXT not null primary key, teacher_acctid TEXT, schoolid TEXT, school_ncesid TEXT, school_latitude REAL, school_longitude REAL, school_city TEXT, school_state TEXT, school_zip INTEGER, school_metro TEXT, school_district TEXT, school_county TEXT, school_charter TEXT, school_magnet TEXT, school_year_round TEXT, school_nlns TEXT, school_kipp TEXT, school_charter_ready_promise TEXT, teacher_prefix TEXT, teacher_teach_for_america TEXT, teacher_ny_teaching_fellow TEXT, primary_focus_subject TEXT, primary_focus_area TEXT, secondary_focus_subject TEXT, secondary_focus_area TEXT, resource_type TEXT, poverty_level TEXT, grade_level TEXT, fulfillment_labor_materials REAL, total_price_excluding_optional_support REAL, total_price_including_optional_support REAL, students_reached INTEGER, eligible_double_your_impact_match TEXT, eligible_almost_home_match TEXT, date_posted DATE ); CREATE TABLE donations ( donationid TEXT not null primary key, projectid TEXT, donor_acctid TEXT, donor_city TEXT, donor_state TEXT, donor_zip TEXT, is_teacher_acct TEXT, donation_timestamp DATETIME, donation_to_project REAL, donation_optional_support REAL, donation_total REAL, dollar_amount TEXT, donation_included_optional_support TEXT, payment_method TEXT, payment_included_acct_credit TEXT, payment_included_campaign_gift_card TEXT, payment_included_web_purchased_gift_card TEXT, payment_was_promo_matched TEXT, via_giving_page TEXT, for_honoree TEXT, donation_message TEXT, foreign key (projectid) references projects(projectid) ); CREATE TABLE resources ( resourceid TEXT not null primary key, projectid TEXT, vendorid INTEGER, vendor_name TEXT, project_resource_type TEXT, item_name TEXT, item_number TEXT, item_unit_price REAL, item_quantity INTEGER, foreign key (projectid) references projects(projectid) );
movie_platform
What is the average rating score of the movie "The Crowd" and who was its director?
director refer to director_name; The Crowd refer to movie_title; Average refer to AVG(rating_score)
SELECT AVG(T2.rating_score), T1.director_name FROM movies AS T1 INNER JOIN ratings AS T2 ON T1.movie_id = T2.movie_id WHERE T1.movie_title = 'The Crowd'
CREATE TABLE IF NOT EXISTS "lists" ( user_id INTEGER references lists_users (user_id), list_id INTEGER not null primary key, list_title TEXT, list_movie_number INTEGER, list_update_timestamp_utc TEXT, list_creation_timestamp_utc TEXT, list_followers INTEGER, list_url TEXT, list_comments INTEGER, list_description TEXT, list_cover_image_url TEXT, list_first_image_url TEXT, list_second_image_url TEXT, list_third_image_url TEXT ); CREATE TABLE IF NOT EXISTS "movies" ( movie_id INTEGER not null primary key, movie_title TEXT, movie_release_year INTEGER, movie_url TEXT, movie_title_language TEXT, movie_popularity INTEGER, movie_image_url TEXT, director_id TEXT, director_name TEXT, director_url TEXT ); CREATE TABLE IF NOT EXISTS "ratings_users" ( user_id INTEGER references lists_users (user_id), rating_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER ); CREATE TABLE lists_users ( user_id INTEGER not null , list_id INTEGER not null , list_update_date_utc TEXT, list_creation_date_utc TEXT, user_trialist INTEGER, user_subscriber INTEGER, user_avatar_image_url TEXT, user_cover_image_url TEXT, user_eligible_for_trial TEXT, user_has_payment_method TEXT, primary key (user_id, list_id), foreign key (list_id) references lists(list_id), foreign key (user_id) references lists(user_id) ); CREATE TABLE ratings ( movie_id INTEGER, rating_id INTEGER, rating_url TEXT, rating_score INTEGER, rating_timestamp_utc TEXT, critic TEXT, critic_likes INTEGER, critic_comments INTEGER, user_id INTEGER, user_trialist INTEGER, user_subscriber INTEGER, user_eligible_for_trial INTEGER, user_has_payment_method INTEGER, foreign key (movie_id) references movies(movie_id), foreign key (user_id) references lists_users(user_id), foreign key (rating_id) references ratings(rating_id), foreign key (user_id) references ratings_users(user_id) );
video_games
List down the game platform ID and region name where the games achieved 20000 sales and below.
20000 sales and below refers to num_sales < 0.2;
SELECT T2.game_platform_id, T1.region_name FROM region AS T1 INNER JOIN region_sales AS T2 ON T1.id = T2.region_id WHERE T2.num_sales * 100000 <= 20000
CREATE TABLE genre ( id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE game ( id INTEGER not null primary key, genre_id INTEGER default NULL, game_name TEXT default NULL, foreign key (genre_id) references genre(id) ); CREATE TABLE platform ( id INTEGER not null primary key, platform_name TEXT default NULL ); CREATE TABLE publisher ( id INTEGER not null primary key, publisher_name TEXT default NULL ); CREATE TABLE game_publisher ( id INTEGER not null primary key, game_id INTEGER default NULL, publisher_id INTEGER default NULL, foreign key (game_id) references game(id), foreign key (publisher_id) references publisher(id) ); CREATE TABLE game_platform ( id INTEGER not null primary key, game_publisher_id INTEGER default NULL, platform_id INTEGER default NULL, release_year INTEGER default NULL, foreign key (game_publisher_id) references game_publisher(id), foreign key (platform_id) references platform(id) ); CREATE TABLE region ( id INTEGER not null primary key, region_name TEXT default NULL ); CREATE TABLE region_sales ( region_id INTEGER default NULL, game_platform_id INTEGER default NULL, num_sales REAL default NULL, foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id) );
language_corpus
What is the second word in the pair of words number 1 and 8968?
Pair is a relationship of two words: w1st and w2nd, where w1st is word id of the first word and w2nd is a word id of the second word; w1st = 1; w2nd = 8968;
SELECT word FROM words WHERE wid = 8968
CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT, lang TEXT UNIQUE, locale TEXT UNIQUE, pages INTEGER DEFAULT 0, -- total pages in this language words INTEGER DEFAULT 0); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT, lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE, page INTEGER DEFAULT NULL, -- wikipedia page id revision INTEGER DEFAULT NULL, -- wikipedia revision page id title TEXT, words INTEGER DEFAULT 0, -- number of different words in this page UNIQUE(lid,page,title)); CREATE TRIGGER ins_page AFTER INSERT ON pages FOR EACH ROW BEGIN UPDATE langs SET pages=pages+1 WHERE lid=NEW.lid; END; CREATE TRIGGER del_page AFTER DELETE ON pages FOR EACH ROW BEGIN UPDATE langs SET pages=pages-1 WHERE lid=OLD.lid; END; CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT, word TEXT UNIQUE, occurrences INTEGER DEFAULT 0); CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE, wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE, occurrences INTEGER, -- repetitions of this word in this language PRIMARY KEY(lid,wid)) WITHOUT ROWID; CREATE TRIGGER ins_lang_word AFTER INSERT ON langs_words FOR EACH ROW BEGIN UPDATE langs SET words=words+1 WHERE lid=NEW.lid; END; CREATE TRIGGER del_lang_word AFTER DELETE ON langs_words FOR EACH ROW BEGIN UPDATE langs SET words=words-1 WHERE lid=OLD.lid; END; CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE, wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE, occurrences INTEGER DEFAULT 0, -- times this word appears into this page PRIMARY KEY(pid,wid)) WITHOUT ROWID; CREATE TRIGGER ins_page_word AFTER INSERT ON pages_words FOR EACH ROW BEGIN UPDATE pages SET words=words+1 WHERE pid=NEW.pid; END; CREATE TRIGGER del_page_word AFTER DELETE ON pages_words FOR EACH ROW BEGIN UPDATE pages SET words=words-1 WHERE pid=OLD.pid; END; CREATE TABLE biwords(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE, w1st INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE, w2nd INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE, occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page PRIMARY KEY(lid,w1st,w2nd)) WITHOUT ROWID;
soccer_2016
How many matches have Mumbai Indians won?
Mumbai Indians refers to Team_Name = 'Mumbai Indians'; won refers to Match_Winner
SELECT SUM(CASE WHEN T2.Team_Name = 'Mumbai Indians' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner
CREATE TABLE Batting_Style ( Batting_Id INTEGER primary key, Batting_hand TEXT ); CREATE TABLE Bowling_Style ( Bowling_Id INTEGER primary key, Bowling_skill TEXT ); CREATE TABLE City ( City_Id INTEGER primary key, City_Name TEXT, Country_id INTEGER ); CREATE TABLE Country ( Country_Id INTEGER primary key, Country_Name TEXT, foreign key (Country_Id) references Country(Country_Id) ); CREATE TABLE Extra_Type ( Extra_Id INTEGER primary key, Extra_Name TEXT ); CREATE TABLE Extra_Runs ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Extra_Type_Id INTEGER, Extra_Runs INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Extra_Type_Id) references Extra_Type(Extra_Id) ); CREATE TABLE Out_Type ( Out_Id INTEGER primary key, Out_Name TEXT ); CREATE TABLE Outcome ( Outcome_Id INTEGER primary key, Outcome_Type TEXT ); CREATE TABLE Player ( Player_Id INTEGER primary key, Player_Name TEXT, DOB DATE, Batting_hand INTEGER, Bowling_skill INTEGER, Country_Name INTEGER, foreign key (Batting_hand) references Batting_Style(Batting_Id), foreign key (Bowling_skill) references Bowling_Style(Bowling_Id), foreign key (Country_Name) references Country(Country_Id) ); CREATE TABLE Rolee ( Role_Id INTEGER primary key, Role_Desc TEXT ); CREATE TABLE Season ( Season_Id INTEGER primary key, Man_of_the_Series INTEGER, Orange_Cap INTEGER, Purple_Cap INTEGER, Season_Year INTEGER ); CREATE TABLE Team ( Team_Id INTEGER primary key, Team_Name TEXT ); CREATE TABLE Toss_Decision ( Toss_Id INTEGER primary key, Toss_Name TEXT ); CREATE TABLE Umpire ( Umpire_Id INTEGER primary key, Umpire_Name TEXT, Umpire_Country INTEGER, foreign key (Umpire_Country) references Country(Country_Id) ); CREATE TABLE Venue ( Venue_Id INTEGER primary key, Venue_Name TEXT, City_Id INTEGER, foreign key (City_Id) references City(City_Id) ); CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT ); CREATE TABLE Match ( Match_Id INTEGER primary key, Team_1 INTEGER, Team_2 INTEGER, Match_Date DATE, Season_Id INTEGER, Venue_Id INTEGER, Toss_Winner INTEGER, Toss_Decide INTEGER, Win_Type INTEGER, Win_Margin INTEGER, Outcome_type INTEGER, Match_Winner INTEGER, Man_of_the_Match INTEGER, foreign key (Team_1) references Team(Team_Id), foreign key (Team_2) references Team(Team_Id), foreign key (Season_Id) references Season(Season_Id), foreign key (Venue_Id) references Venue(Venue_Id), foreign key (Toss_Winner) references Team(Team_Id), foreign key (Toss_Decide) references Toss_Decision(Toss_Id), foreign key (Win_Type) references Win_By(Win_Id), foreign key (Outcome_type) references Out_Type(Out_Id), foreign key (Match_Winner) references Team(Team_Id), foreign key (Man_of_the_Match) references Player(Player_Id) ); CREATE TABLE Ball_by_Ball ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Innings_No INTEGER, Team_Batting INTEGER, Team_Bowling INTEGER, Striker_Batting_Position INTEGER, Striker INTEGER, Non_Striker INTEGER, Bowler INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id) ); CREATE TABLE Batsman_Scored ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Runs_Scored INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id) ); CREATE TABLE Player_Match ( Match_Id INTEGER, Player_Id INTEGER, Role_Id INTEGER, Team_Id INTEGER, primary key (Match_Id, Player_Id, Role_Id), foreign key (Match_Id) references Match(Match_Id), foreign key (Player_Id) references Player(Player_Id), foreign key (Team_Id) references Team(Team_Id), foreign key (Role_Id) references Rolee(Role_Id) ); CREATE TABLE Wicket_Taken ( Match_Id INTEGER, Over_Id INTEGER, Ball_Id INTEGER, Player_Out INTEGER, Kind_Out INTEGER, Fielders INTEGER, Innings_No INTEGER, primary key (Match_Id, Over_Id, Ball_Id, Innings_No), foreign key (Match_Id) references Match(Match_Id), foreign key (Player_Out) references Player(Player_Id), foreign key (Kind_Out) references Out_Type(Out_Id), foreign key (Fielders) references Player(Player_Id) );
public_review_platform
List at least 5 active business ID that are good for groups and dancing.
"Good for Groups" and "Good for Dancing" are attribute_name; active business refers to active = true'
SELECT T2.business_id FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T2.attribute_value LIKE 'TRUE' AND T1.attribute_name LIKE 'Good for Dancing' AND T1.attribute_name LIKE 'Good for Groups' LIMIT 5
CREATE TABLE Attributes ( attribute_id INTEGER constraint Attributes_pk primary key, attribute_name TEXT ); CREATE TABLE Categories ( category_id INTEGER constraint Categories_pk primary key, category_name TEXT ); CREATE TABLE Compliments ( compliment_id INTEGER constraint Compliments_pk primary key, compliment_type TEXT ); CREATE TABLE Days ( day_id INTEGER constraint Days_pk primary key, day_of_week TEXT ); CREATE TABLE Years ( year_id INTEGER constraint Years_pk primary key, actual_year INTEGER ); CREATE TABLE IF NOT EXISTS "Business_Attributes" ( attribute_id INTEGER constraint Business_Attributes_Attributes_attribute_id_fk references Attributes, business_id INTEGER constraint Business_Attributes_Business_business_id_fk references Business, attribute_value TEXT, constraint Business_Attributes_pk primary key (attribute_id, business_id) ); CREATE TABLE IF NOT EXISTS "Business_Categories" ( business_id INTEGER constraint Business_Categories_Business_business_id_fk references Business, category_id INTEGER constraint Business_Categories_Categories_category_id_fk references Categories, constraint Business_Categories_pk primary key (business_id, category_id) ); CREATE TABLE IF NOT EXISTS "Business_Hours" ( business_id INTEGER constraint Business_Hours_Business_business_id_fk references Business, day_id INTEGER constraint Business_Hours_Days_day_id_fk references Days, opening_time TEXT, closing_time TEXT, constraint Business_Hours_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Checkins" ( business_id INTEGER constraint Checkins_Business_business_id_fk references Business, day_id INTEGER constraint Checkins_Days_day_id_fk references Days, label_time_0 TEXT, label_time_1 TEXT, label_time_2 TEXT, label_time_3 TEXT, label_time_4 TEXT, label_time_5 TEXT, label_time_6 TEXT, label_time_7 TEXT, label_time_8 TEXT, label_time_9 TEXT, label_time_10 TEXT, label_time_11 TEXT, label_time_12 TEXT, label_time_13 TEXT, label_time_14 TEXT, label_time_15 TEXT, label_time_16 TEXT, label_time_17 TEXT, label_time_18 TEXT, label_time_19 TEXT, label_time_20 TEXT, label_time_21 TEXT, label_time_22 TEXT, label_time_23 TEXT, constraint Checkins_pk primary key (business_id, day_id) ); CREATE TABLE IF NOT EXISTS "Elite" ( user_id INTEGER constraint Elite_Users_user_id_fk references Users, year_id INTEGER constraint Elite_Years_year_id_fk references Years, constraint Elite_pk primary key (user_id, year_id) ); CREATE TABLE IF NOT EXISTS "Reviews" ( business_id INTEGER constraint Reviews_Business_business_id_fk references Business, user_id INTEGER constraint Reviews_Users_user_id_fk references Users, review_stars INTEGER, review_votes_funny TEXT, review_votes_useful TEXT, review_votes_cool TEXT, review_length TEXT, constraint Reviews_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Tips" ( business_id INTEGER constraint Tips_Business_business_id_fk references Business, user_id INTEGER constraint Tips_Users_user_id_fk references Users, likes INTEGER, tip_length TEXT, constraint Tips_pk primary key (business_id, user_id) ); CREATE TABLE IF NOT EXISTS "Users_Compliments" ( compliment_id INTEGER constraint Users_Compliments_Compliments_compliment_id_fk references Compliments, user_id INTEGER constraint Users_Compliments_Users_user_id_fk references Users, number_of_compliments TEXT, constraint Users_Compliments_pk primary key (compliment_id, user_id) ); CREATE TABLE IF NOT EXISTS "Business" ( business_id INTEGER constraint Business_pk primary key, active TEXT, city TEXT, state TEXT, stars REAL, review_count TEXT ); CREATE TABLE IF NOT EXISTS "Users" ( user_id INTEGER constraint Users_pk primary key, user_yelping_since_year INTEGER, user_average_stars TEXT, user_votes_funny TEXT, user_votes_useful TEXT, user_votes_cool TEXT, user_review_count TEXT, user_fans TEXT );
sales
Sum up the number sales ids handled by employees called Morningstar, Heather and Dean.
SUM = ADD(SUM(SalesID WHERE FirstName = 'Morningstar'), SUM(SalesID WHERE FirstName = 'Heather'), SUM(SalesID WHERE FirstName = 'Dean'));
SELECT SUM(IIF(T2.FirstName = 'Morningstar', 1, 0)) + SUM(IIF(T2.FirstName = 'Heather', 1, 0)) + SUM(IIF(T2.FirstName = 'Dean', 1, 0)) AS num FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID
CREATE TABLE Customers ( CustomerID INTEGER not null primary key, FirstName TEXT not null, MiddleInitial TEXT null, LastName TEXT not null ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, FirstName TEXT not null, MiddleInitial TEXT null, LastName TEXT not null ); CREATE TABLE Products ( ProductID INTEGER not null primary key, Name TEXT not null, Price REAL null ); CREATE TABLE Sales ( SalesID INTEGER not null primary key, SalesPersonID INTEGER not null, CustomerID INTEGER not null, ProductID INTEGER not null, Quantity INTEGER not null, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade );
retail_world
What is the contact name and phone number of the customer who has made the most total payment on the order to date?
most total payment = Max(Multiply(Quantity, UnitPrice, Subtract(1, Discount)))
SELECT T1.ContactName, T1.Phone FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID GROUP BY T2.OrderID, T1.ContactName, T1.Phone ORDER BY SUM(T3.UnitPrice * T3.Quantity * (1 - T3.Discount)) DESC LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
codebase_comments
Which method has the summary "Write a command to the log"?
SELECT Name FROM Method WHERE Summary = 'Write a command to the log'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "Method" ( Id INTEGER not null primary key autoincrement, Name TEXT, FullComment TEXT, Summary TEXT, ApiCalls TEXT, CommentIsXml INTEGER, SampledAt INTEGER, SolutionId INTEGER, Lang TEXT, NameTokenized TEXT ); CREATE TABLE IF NOT EXISTS "MethodParameter" ( Id INTEGER not null primary key autoincrement, MethodId TEXT, Type TEXT, Name TEXT ); CREATE TABLE Repo ( Id INTEGER not null primary key autoincrement, Url TEXT, Stars INTEGER, Forks INTEGER, Watchers INTEGER, ProcessedTime INTEGER ); CREATE TABLE Solution ( Id INTEGER not null primary key autoincrement, RepoId INTEGER, Path TEXT, ProcessedTime INTEGER, WasCompiled INTEGER );
shakespeare
How many comedies did Shakespeare create?
comedies refers to GenreType = 'Comedy'
SELECT COUNT(id) FROM works WHERE GenreType = 'Comedy'
CREATE TABLE IF NOT EXISTS "chapters" ( id INTEGER primary key autoincrement, Act INTEGER not null, Scene INTEGER not null, Description TEXT not null, work_id INTEGER not null references works ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "characters" ( id INTEGER primary key autoincrement, CharName TEXT not null, Abbrev TEXT not null, Description TEXT not null ); CREATE TABLE IF NOT EXISTS "paragraphs" ( id INTEGER primary key autoincrement, ParagraphNum INTEGER not null, PlainText TEXT not null, character_id INTEGER not null references characters, chapter_id INTEGER default 0 not null references chapters ); CREATE TABLE IF NOT EXISTS "works" ( id INTEGER primary key autoincrement, Title TEXT not null, LongTitle TEXT not null, Date INTEGER not null, GenreType TEXT not null );
mondial_geo
What is the name of the country with the smallest population, and what is its gross domestic product?
GDP refers to gross domestic product
SELECT T1.Name, T2.GDP FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country ORDER BY T1.Population ASC LIMIT 1
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
professional_basketball
From 1950 to 1970, how many coaches who received more than 1 award?
from 1950 to 1970 refers to year between 1950 and 1970; more than 3 awards refers to count(award) > 3
SELECT COUNT(coachID) FROM awards_coaches WHERE year BETWEEN 1950 AND 1970 GROUP BY coachID HAVING COUNT(coachID) > 1
CREATE TABLE awards_players ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT null, note TEXT null, pos TEXT null, primary key (playerID, year, award), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE coaches ( coachID TEXT not null, year INTEGER not null, tmID TEXT not null, lgID TEXT null, stint INTEGER not null, won INTEGER null, lost INTEGER null, post_wins INTEGER null, post_losses INTEGER null, primary key (coachID, year, tmID, stint), foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE draft ( id INTEGER default 0 not null primary key, draftYear INTEGER null, draftRound INTEGER null, draftSelection INTEGER null, draftOverall INTEGER null, tmID TEXT null, firstName TEXT null, lastName TEXT null, suffixName TEXT null, playerID TEXT null, draftFrom TEXT null, lgID TEXT null, foreign key (tmID, draftYear) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE player_allstar ( playerID TEXT not null, last_name TEXT null, first_name TEXT null, season_id INTEGER not null, conference TEXT null, league_id TEXT null, games_played INTEGER null, minutes INTEGER null, points INTEGER null, o_rebounds INTEGER null, d_rebounds INTEGER null, rebounds INTEGER null, assists INTEGER null, steals INTEGER null, blocks INTEGER null, turnovers INTEGER null, personal_fouls INTEGER null, fg_attempted INTEGER null, fg_made INTEGER null, ft_attempted INTEGER null, ft_made INTEGER null, three_attempted INTEGER null, three_made INTEGER null, primary key (playerID, season_id), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE players ( playerID TEXT not null primary key, useFirst TEXT null, firstName TEXT null, middleName TEXT null, lastName TEXT null, nameGiven TEXT null, fullGivenName TEXT null, nameSuffix TEXT null, nameNick TEXT null, pos TEXT null, firstseason INTEGER null, lastseason INTEGER null, height REAL null, weight INTEGER null, college TEXT null, collegeOther TEXT null, birthDate DATE null, birthCity TEXT null, birthState TEXT null, birthCountry TEXT null, highSchool TEXT null, hsCity TEXT null, hsState TEXT null, hsCountry TEXT null, deathDate DATE null, race TEXT null ); CREATE TABLE teams ( year INTEGER not null, lgID TEXT null, tmID TEXT not null, franchID TEXT null, confID TEXT null, divID TEXT null, `rank` INTEGER null, confRank INTEGER null, playoff TEXT null, name TEXT null, o_fgm INTEGER null, -- o_fga int null, o_ftm INTEGER null, -- o_fta int null, -- o_3pm int null, -- o_3pa int null, -- o_oreb int null, -- o_dreb int null, -- o_reb int null, -- o_asts int null, -- o_pf int null, -- o_stl int null, -- o_to int null, -- o_blk int null, o_pts INTEGER null, -- d_fgm int null, -- d_fga int null, -- d_ftm int null, -- d_fta int null, -- d_3pm int null, -- d_3pa int null, -- d_oreb int null, -- d_dreb int null, -- d_reb int null, -- d_asts int null, -- d_pf int null, -- d_stl int null, -- d_to int null, -- d_blk int null, d_pts INTEGER null, -- o_tmRebound int null, -- d_tmRebound int null, homeWon INTEGER null, homeLost INTEGER null, awayWon INTEGER null, awayLost INTEGER null, -- neutWon int null, -- neutLoss int null, -- confWon int null, -- confLoss int null, -- divWon int null, -- divLoss int null, -- pace int null, won INTEGER null, lost INTEGER null, games INTEGER null, -- min int null, arena TEXT null, -- attendance int null, -- bbtmID varchar(255) null, primary key (year, tmID) ); CREATE TABLE IF NOT EXISTS "awards_coaches" ( id INTEGER primary key autoincrement, year INTEGER, coachID TEXT, award TEXT, lgID TEXT, note TEXT, foreign key (coachID, year) references coaches (coachID, year) on update cascade on delete cascade ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "players_teams" ( id INTEGER primary key autoincrement, playerID TEXT not null references players on update cascade on delete cascade, year INTEGER, stint INTEGER, tmID TEXT, lgID TEXT, GP INTEGER, GS INTEGER, minutes INTEGER, points INTEGER, oRebounds INTEGER, dRebounds INTEGER, rebounds INTEGER, assists INTEGER, steals INTEGER, blocks INTEGER, turnovers INTEGER, PF INTEGER, fgAttempted INTEGER, fgMade INTEGER, ftAttempted INTEGER, ftMade INTEGER, threeAttempted INTEGER, threeMade INTEGER, PostGP INTEGER, PostGS INTEGER, PostMinutes INTEGER, PostPoints INTEGER, PostoRebounds INTEGER, PostdRebounds INTEGER, PostRebounds INTEGER, PostAssists INTEGER, PostSteals INTEGER, PostBlocks INTEGER, PostTurnovers INTEGER, PostPF INTEGER, PostfgAttempted INTEGER, PostfgMade INTEGER, PostftAttempted INTEGER, PostftMade INTEGER, PostthreeAttempted INTEGER, PostthreeMade INTEGER, note TEXT, foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "series_post" ( id INTEGER primary key autoincrement, year INTEGER, round TEXT, series TEXT, tmIDWinner TEXT, lgIDWinner TEXT, tmIDLoser TEXT, lgIDLoser TEXT, W INTEGER, L INTEGER, foreign key (tmIDWinner, year) references teams (tmID, year) on update cascade on delete cascade, foreign key (tmIDLoser, year) references teams (tmID, year) on update cascade on delete cascade );
movielens
What horror movies have a running time of at least 2? Please list movie IDs.
Higher value of running time means running time is longer
SELECT T1.movieid FROM movies2directors AS T1 INNER JOIN movies AS T2 ON T1.movieid = T2.movieid WHERE T2.runningtime >= 2 AND T1.genre = 'Horror'
CREATE TABLE users ( userid INTEGER default 0 not null primary key, age TEXT not null, u_gender TEXT not null, occupation TEXT not null ); CREATE TABLE IF NOT EXISTS "directors" ( directorid INTEGER not null primary key, d_quality INTEGER not null, avg_revenue INTEGER not null ); CREATE INDEX avg_revenue on directors (avg_revenue); CREATE INDEX d_quality on directors (d_quality); CREATE TABLE IF NOT EXISTS "actors" ( actorid INTEGER not null primary key, a_gender TEXT not null, a_quality INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies" ( movieid INTEGER default 0 not null primary key, year INTEGER not null, isEnglish TEXT not null, country TEXT not null, runningtime INTEGER not null ); CREATE TABLE IF NOT EXISTS "movies2actors" ( movieid INTEGER not null references movies on update cascade on delete cascade, actorid INTEGER not null references actors on update cascade on delete cascade, cast_num INTEGER not null, primary key (movieid, actorid) ); CREATE TABLE IF NOT EXISTS "movies2directors" ( movieid INTEGER not null references movies on update cascade on delete cascade, directorid INTEGER not null references directors on update cascade on delete cascade, genre TEXT not null, primary key (movieid, directorid) ); CREATE TABLE IF NOT EXISTS "u2base" ( userid INTEGER default 0 not null references users on update cascade on delete cascade, movieid INTEGER not null references movies on update cascade on delete cascade, rating TEXT not null, primary key (userid, movieid) );
retails
What are the total quantities of the items ordered by customer 101660 on 10/5/1995?
total quantity refers to sum(l_quantity); customer 101660 refers to o_custkey = 101660; on 10/5/1995 refers to o_orderdate = '1995-10-05'
SELECT SUM(T2.l_quantity) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_orderdate = '1995-10-05' AND T1.o_custkey = 101660
CREATE TABLE `customer` ( `c_custkey` INTEGER NOT NULL, `c_mktsegment` TEXT DEFAULT NULL, `c_nationkey` INTEGER DEFAULT NULL, `c_name` TEXT DEFAULT NULL, `c_address` TEXT DEFAULT NULL, `c_phone` TEXT DEFAULT NULL, `c_acctbal` REAL DEFAULT NULL, `c_comment` TEXT DEFAULT NULL, PRIMARY KEY (`c_custkey`), FOREIGN KEY (`c_nationkey`) REFERENCES `nation` (`n_nationkey`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE lineitem ( l_shipdate DATE null, l_orderkey INTEGER not null, l_discount REAL not null, l_extendedprice REAL not null, l_suppkey INTEGER not null, l_quantity INTEGER not null, l_returnflag TEXT null, l_partkey INTEGER not null, l_linestatus TEXT null, l_tax REAL not null, l_commitdate DATE null, l_receiptdate DATE null, l_shipmode TEXT null, l_linenumber INTEGER not null, l_shipinstruct TEXT null, l_comment TEXT null, primary key (l_orderkey, l_linenumber), foreign key (l_orderkey) references orders (o_orderkey) on update cascade on delete cascade, foreign key (l_partkey, l_suppkey) references partsupp (ps_partkey, ps_suppkey) on update cascade on delete cascade ); CREATE TABLE nation ( n_nationkey INTEGER not null primary key, n_name TEXT null, n_regionkey INTEGER null, n_comment TEXT null, foreign key (n_regionkey) references region (r_regionkey) on update cascade on delete cascade ); CREATE TABLE orders ( o_orderdate DATE null, o_orderkey INTEGER not null primary key, o_custkey INTEGER not null, o_orderpriority TEXT null, o_shippriority INTEGER null, o_clerk TEXT null, o_orderstatus TEXT null, o_totalprice REAL null, o_comment TEXT null, foreign key (o_custkey) references customer (c_custkey) on update cascade on delete cascade ); CREATE TABLE part ( p_partkey INTEGER not null primary key, p_type TEXT null, p_size INTEGER null, p_brand TEXT null, p_name TEXT null, p_container TEXT null, p_mfgr TEXT null, p_retailprice REAL null, p_comment TEXT null ); CREATE TABLE partsupp ( ps_partkey INTEGER not null, ps_suppkey INTEGER not null, ps_supplycost REAL not null, ps_availqty INTEGER null, ps_comment TEXT null, primary key (ps_partkey, ps_suppkey), foreign key (ps_partkey) references part (p_partkey) on update cascade on delete cascade, foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade ); CREATE TABLE region ( r_regionkey INTEGER not null primary key, r_name TEXT null, r_comment TEXT null ); CREATE TABLE supplier ( s_suppkey INTEGER not null primary key, s_nationkey INTEGER null, s_comment TEXT null, s_name TEXT null, s_address TEXT null, s_phone TEXT null, s_acctbal REAL null, foreign key (s_nationkey) references nation (n_nationkey) );
professional_basketball
Which winning team in the 1947 playoff quarterfinals managed to score 3,513 defensive points that same year?
team refers to tmID; quarterfinal refers to round = 'QF'; score 3,513 defensive points refers to d_pts > = 3513
SELECT T2.tmID FROM series_post AS T1 INNER JOIN teams AS T2 ON T1.tmIDWinner = T2.tmID WHERE T1.year = 1947 AND T1.round = 'QF' AND T2.d_pts = 3513
CREATE TABLE awards_players ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT null, note TEXT null, pos TEXT null, primary key (playerID, year, award), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE coaches ( coachID TEXT not null, year INTEGER not null, tmID TEXT not null, lgID TEXT null, stint INTEGER not null, won INTEGER null, lost INTEGER null, post_wins INTEGER null, post_losses INTEGER null, primary key (coachID, year, tmID, stint), foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE draft ( id INTEGER default 0 not null primary key, draftYear INTEGER null, draftRound INTEGER null, draftSelection INTEGER null, draftOverall INTEGER null, tmID TEXT null, firstName TEXT null, lastName TEXT null, suffixName TEXT null, playerID TEXT null, draftFrom TEXT null, lgID TEXT null, foreign key (tmID, draftYear) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE player_allstar ( playerID TEXT not null, last_name TEXT null, first_name TEXT null, season_id INTEGER not null, conference TEXT null, league_id TEXT null, games_played INTEGER null, minutes INTEGER null, points INTEGER null, o_rebounds INTEGER null, d_rebounds INTEGER null, rebounds INTEGER null, assists INTEGER null, steals INTEGER null, blocks INTEGER null, turnovers INTEGER null, personal_fouls INTEGER null, fg_attempted INTEGER null, fg_made INTEGER null, ft_attempted INTEGER null, ft_made INTEGER null, three_attempted INTEGER null, three_made INTEGER null, primary key (playerID, season_id), foreign key (playerID) references players (playerID) on update cascade on delete cascade ); CREATE TABLE players ( playerID TEXT not null primary key, useFirst TEXT null, firstName TEXT null, middleName TEXT null, lastName TEXT null, nameGiven TEXT null, fullGivenName TEXT null, nameSuffix TEXT null, nameNick TEXT null, pos TEXT null, firstseason INTEGER null, lastseason INTEGER null, height REAL null, weight INTEGER null, college TEXT null, collegeOther TEXT null, birthDate DATE null, birthCity TEXT null, birthState TEXT null, birthCountry TEXT null, highSchool TEXT null, hsCity TEXT null, hsState TEXT null, hsCountry TEXT null, deathDate DATE null, race TEXT null ); CREATE TABLE teams ( year INTEGER not null, lgID TEXT null, tmID TEXT not null, franchID TEXT null, confID TEXT null, divID TEXT null, `rank` INTEGER null, confRank INTEGER null, playoff TEXT null, name TEXT null, o_fgm INTEGER null, -- o_fga int null, o_ftm INTEGER null, -- o_fta int null, -- o_3pm int null, -- o_3pa int null, -- o_oreb int null, -- o_dreb int null, -- o_reb int null, -- o_asts int null, -- o_pf int null, -- o_stl int null, -- o_to int null, -- o_blk int null, o_pts INTEGER null, -- d_fgm int null, -- d_fga int null, -- d_ftm int null, -- d_fta int null, -- d_3pm int null, -- d_3pa int null, -- d_oreb int null, -- d_dreb int null, -- d_reb int null, -- d_asts int null, -- d_pf int null, -- d_stl int null, -- d_to int null, -- d_blk int null, d_pts INTEGER null, -- o_tmRebound int null, -- d_tmRebound int null, homeWon INTEGER null, homeLost INTEGER null, awayWon INTEGER null, awayLost INTEGER null, -- neutWon int null, -- neutLoss int null, -- confWon int null, -- confLoss int null, -- divWon int null, -- divLoss int null, -- pace int null, won INTEGER null, lost INTEGER null, games INTEGER null, -- min int null, arena TEXT null, -- attendance int null, -- bbtmID varchar(255) null, primary key (year, tmID) ); CREATE TABLE IF NOT EXISTS "awards_coaches" ( id INTEGER primary key autoincrement, year INTEGER, coachID TEXT, award TEXT, lgID TEXT, note TEXT, foreign key (coachID, year) references coaches (coachID, year) on update cascade on delete cascade ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "players_teams" ( id INTEGER primary key autoincrement, playerID TEXT not null references players on update cascade on delete cascade, year INTEGER, stint INTEGER, tmID TEXT, lgID TEXT, GP INTEGER, GS INTEGER, minutes INTEGER, points INTEGER, oRebounds INTEGER, dRebounds INTEGER, rebounds INTEGER, assists INTEGER, steals INTEGER, blocks INTEGER, turnovers INTEGER, PF INTEGER, fgAttempted INTEGER, fgMade INTEGER, ftAttempted INTEGER, ftMade INTEGER, threeAttempted INTEGER, threeMade INTEGER, PostGP INTEGER, PostGS INTEGER, PostMinutes INTEGER, PostPoints INTEGER, PostoRebounds INTEGER, PostdRebounds INTEGER, PostRebounds INTEGER, PostAssists INTEGER, PostSteals INTEGER, PostBlocks INTEGER, PostTurnovers INTEGER, PostPF INTEGER, PostfgAttempted INTEGER, PostfgMade INTEGER, PostftAttempted INTEGER, PostftMade INTEGER, PostthreeAttempted INTEGER, PostthreeMade INTEGER, note TEXT, foreign key (tmID, year) references teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "series_post" ( id INTEGER primary key autoincrement, year INTEGER, round TEXT, series TEXT, tmIDWinner TEXT, lgIDWinner TEXT, tmIDLoser TEXT, lgIDLoser TEXT, W INTEGER, L INTEGER, foreign key (tmIDWinner, year) references teams (tmID, year) on update cascade on delete cascade, foreign key (tmIDLoser, year) references teams (tmID, year) on update cascade on delete cascade );
superstore
Who is the customer from the East region that purchased the order with the highest profit?
highest profit refers to MAX(profit); Region = 'East'
SELECT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Region = 'East' ORDER BY T1.Profit DESC LIMIT 1
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TEXT, "Product Name" TEXT, Category TEXT, "Sub-Category" TEXT, Region TEXT, primary key ("Product ID", Region) ); CREATE TABLE central_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE east_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE south_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE west_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) );
authors
What is the homepage address for paper "Energy-efficiency bounds for noise-tolerant dynamic circuits"?
"Energy-efficiency bounds for noise-tolerant dynamic circuits" is the Title of paper
SELECT T2.HomePage FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Title = 'Energy-efficiency bounds for noise-tolerant dynamic circuits'
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE IF NOT EXISTS "Journal" ( Id INTEGER constraint Journal_pk primary key, ShortName TEXT, FullName TEXT, HomePage TEXT ); CREATE TABLE Paper ( Id INTEGER primary key, Title TEXT, Year INTEGER, ConferenceId INTEGER, JournalId INTEGER, Keyword TEXT, foreign key (ConferenceId) references Conference(Id), foreign key (JournalId) references Journal(Id) ); CREATE TABLE PaperAuthor ( PaperId INTEGER, AuthorId INTEGER, Name TEXT, Affiliation TEXT, foreign key (PaperId) references Paper(Id), foreign key (AuthorId) references Author(Id) );
retail_world
Please list the names of all the products whose supplier is in Japan.
names of the products refers to ProductName; Japan refers to Country = 'Japan';
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Japan'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, Description TEXT ); CREATE TABLE Customers ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT ); CREATE TABLE Employees ( EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, LastName TEXT, FirstName TEXT, BirthDate DATE, Photo TEXT, Notes TEXT ); CREATE TABLE Shippers( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, Phone TEXT ); CREATE TABLE Suppliers( SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, SupplierName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, Country TEXT, Phone TEXT ); CREATE TABLE Products( ProductID INTEGER PRIMARY KEY AUTOINCREMENT, ProductName TEXT, SupplierID INTEGER, CategoryID INTEGER, Unit TEXT, Price REAL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID) ); CREATE TABLE Orders( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, EmployeeID INTEGER, OrderDate DATETIME, ShipperID INTEGER, FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID) ); CREATE TABLE OrderDetails( OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, OrderID INTEGER, ProductID INTEGER, Quantity INTEGER, FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), FOREIGN KEY (ProductID) REFERENCES Products (ProductID) );
cookbook
Among the recipes whose source is the National Potato Board, which recipe has the highest calories?
the National Potato Board is a source; the highest calories refers to MAX(calories)
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.source = 'National Potato Board' ORDER BY T2.calories DESC LIMIT 1
CREATE TABLE Ingredient ( ingredient_id INTEGER primary key, category TEXT, name TEXT, plural TEXT ); CREATE TABLE Recipe ( recipe_id INTEGER primary key, title TEXT, subtitle TEXT, servings INTEGER, yield_unit TEXT, prep_min INTEGER, cook_min INTEGER, stnd_min INTEGER, source TEXT, intro TEXT, directions TEXT ); CREATE TABLE Nutrition ( recipe_id INTEGER primary key, protein REAL, carbo REAL, alcohol REAL, total_fat REAL, sat_fat REAL, cholestrl REAL, sodium REAL, iron REAL, vitamin_c REAL, vitamin_a REAL, fiber REAL, pcnt_cal_carb REAL, pcnt_cal_fat REAL, pcnt_cal_prot REAL, calories REAL, foreign key (recipe_id) references Recipe(recipe_id) ); CREATE TABLE Quantity ( quantity_id INTEGER primary key, recipe_id INTEGER, ingredient_id INTEGER, max_qty REAL, min_qty REAL, unit TEXT, preparation TEXT, optional TEXT, foreign key (recipe_id) references Recipe(recipe_id), foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id) );
airline
What is the airport description of the airport code A11?
SELECT Description FROM Airports WHERE Code = 'A11'
CREATE TABLE IF NOT EXISTS "Air Carriers" ( Code INTEGER primary key, Description TEXT ); CREATE TABLE Airports ( Code TEXT primary key, Description TEXT ); CREATE TABLE Airlines ( FL_DATE TEXT, OP_CARRIER_AIRLINE_ID INTEGER, TAIL_NUM TEXT, OP_CARRIER_FL_NUM INTEGER, ORIGIN_AIRPORT_ID INTEGER, ORIGIN_AIRPORT_SEQ_ID INTEGER, ORIGIN_CITY_MARKET_ID INTEGER, ORIGIN TEXT, DEST_AIRPORT_ID INTEGER, DEST_AIRPORT_SEQ_ID INTEGER, DEST_CITY_MARKET_ID INTEGER, DEST TEXT, CRS_DEP_TIME INTEGER, DEP_TIME INTEGER, DEP_DELAY INTEGER, DEP_DELAY_NEW INTEGER, ARR_TIME INTEGER, ARR_DELAY INTEGER, ARR_DELAY_NEW INTEGER, CANCELLED INTEGER, CANCELLATION_CODE TEXT, CRS_ELAPSED_TIME INTEGER, ACTUAL_ELAPSED_TIME INTEGER, CARRIER_DELAY INTEGER, WEATHER_DELAY INTEGER, NAS_DELAY INTEGER, SECURITY_DELAY INTEGER, LATE_AIRCRAFT_DELAY INTEGER, FOREIGN KEY (ORIGIN) REFERENCES Airports(Code), FOREIGN KEY (DEST) REFERENCES Airports(Code), FOREIGN KEY (OP_CARRIER_AIRLINE_ID) REFERENCES "Air Carriers"(Code) );
movies_4
Among the zero-budget movie titles, which one has made the highest revenue?
zero-budget refers to budget = 0; highest revenue refers to max(revenue)
SELECT title FROM movie WHERE budget = 0 ORDER BY revenue DESC LIMIT 1
CREATE TABLE country ( country_id INTEGER not null primary key, country_iso_code TEXT default NULL, country_name TEXT default NULL ); CREATE TABLE department ( department_id INTEGER not null primary key, department_name TEXT default NULL ); CREATE TABLE gender ( gender_id INTEGER not null primary key, gender TEXT default NULL ); CREATE TABLE genre ( genre_id INTEGER not null primary key, genre_name TEXT default NULL ); CREATE TABLE keyword ( keyword_id INTEGER not null primary key, keyword_name TEXT default NULL ); CREATE TABLE language ( language_id INTEGER not null primary key, language_code TEXT default NULL, language_name TEXT default NULL ); CREATE TABLE language_role ( role_id INTEGER not null primary key, language_role TEXT default NULL ); CREATE TABLE movie ( movie_id INTEGER not null primary key, title TEXT default NULL, budget INTEGER default NULL, homepage TEXT default NULL, overview TEXT default NULL, popularity REAL default NULL, release_date DATE default NULL, revenue INTEGER default NULL, runtime INTEGER default NULL, movie_status TEXT default NULL, tagline TEXT default NULL, vote_average REAL default NULL, vote_count INTEGER default NULL ); CREATE TABLE movie_genres ( movie_id INTEGER default NULL, genre_id INTEGER default NULL, foreign key (genre_id) references genre(genre_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_languages ( movie_id INTEGER default NULL, language_id INTEGER default NULL, language_role_id INTEGER default NULL, foreign key (language_id) references language(language_id), foreign key (movie_id) references movie(movie_id), foreign key (language_role_id) references language_role(role_id) ); CREATE TABLE person ( person_id INTEGER not null primary key, person_name TEXT default NULL ); CREATE TABLE movie_crew ( movie_id INTEGER default NULL, person_id INTEGER default NULL, department_id INTEGER default NULL, job TEXT default NULL, foreign key (department_id) references department(department_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE production_company ( company_id INTEGER not null primary key, company_name TEXT default NULL ); CREATE TABLE production_country ( movie_id INTEGER default NULL, country_id INTEGER default NULL, foreign key (country_id) references country(country_id), foreign key (movie_id) references movie(movie_id) ); CREATE TABLE movie_cast ( movie_id INTEGER default NULL, person_id INTEGER default NULL, character_name TEXT default NULL, gender_id INTEGER default NULL, cast_order INTEGER default NULL, foreign key (gender_id) references gender(gender_id), foreign key (movie_id) references movie(movie_id), foreign key (person_id) references person(person_id) ); CREATE TABLE IF NOT EXISTS "movie_keywords" ( movie_id INTEGER default NULL references movie, keyword_id INTEGER default NULL references keyword ); CREATE TABLE IF NOT EXISTS "movie_company" ( movie_id INTEGER default NULL references movie, company_id INTEGER default NULL references production_company );
simpson_episodes
Describe name, birth country, role in episode and age in 2022 of the oldest crew member..
age in 2022 refers to SUBTRACT(2022, substr(birthdate, 0, 5)); oldest refers to MIN(birthdate)
SELECT T1.name, T1.birth_place, T2.role, 2022 - CAST(SUBSTR(T1.birthdate, 1, 4) AS int) AS age FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T1.birthdate IS NOT NULL ORDER BY T1.birthdate LIMIT 1;
CREATE TABLE IF NOT EXISTS "Episode" ( episode_id TEXT constraint Episode_pk primary key, season INTEGER, episode INTEGER, number_in_series INTEGER, title TEXT, summary TEXT, air_date TEXT, episode_image TEXT, rating REAL, votes INTEGER ); CREATE TABLE Person ( name TEXT constraint Person_pk primary key, birthdate TEXT, birth_name TEXT, birth_place TEXT, birth_region TEXT, birth_country TEXT, height_meters REAL, nickname TEXT ); CREATE TABLE Award ( award_id INTEGER primary key, organization TEXT, year INTEGER, award_category TEXT, award TEXT, person TEXT, role TEXT, episode_id TEXT, season TEXT, song TEXT, result TEXT, foreign key (person) references Person(name), foreign key (episode_id) references Episode(episode_id) ); CREATE TABLE Character_Award ( award_id INTEGER, character TEXT, foreign key (award_id) references Award(award_id) ); CREATE TABLE Credit ( episode_id TEXT, category TEXT, person TEXT, role TEXT, credited TEXT, foreign key (episode_id) references Episode(episode_id), foreign key (person) references Person(name) ); CREATE TABLE Keyword ( episode_id TEXT, keyword TEXT, primary key (episode_id, keyword), foreign key (episode_id) references Episode(episode_id) ); CREATE TABLE Vote ( episode_id TEXT, stars INTEGER, votes INTEGER, percent REAL, foreign key (episode_id) references Episode(episode_id) );
works_cycles
What is the company's profit on the product that was rated second-highest by David?
profit on net on a single product = SUBTRACT(ListPrice, StandardCost); second highest rating refers to Rating = 4; David is the ReviewerName;
SELECT T2.ListPrice - T2.StandardCost FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ReviewerName = 'David' ORDER BY T1.Rating DESC LIMIT 1
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Culture ( CultureID TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Currency ( CurrencyCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE CountryRegionCurrency ( CountryRegionCode TEXT not null, CurrencyCode TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (CountryRegionCode, CurrencyCode), foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode), foreign key (CurrencyCode) references Currency(CurrencyCode) ); CREATE TABLE Person ( BusinessEntityID INTEGER not null primary key, PersonType TEXT not null, NameStyle INTEGER default 0 not null, Title TEXT, FirstName TEXT not null, MiddleName TEXT, LastName TEXT not null, Suffix TEXT, EmailPromotion INTEGER default 0 not null, AdditionalContactInfo TEXT, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE BusinessEntityContact ( BusinessEntityID INTEGER not null, PersonID INTEGER not null, ContactTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, PersonID, ContactTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (ContactTypeID) references ContactType(ContactTypeID), foreign key (PersonID) references Person(BusinessEntityID) ); CREATE TABLE EmailAddress ( BusinessEntityID INTEGER not null, EmailAddressID INTEGER, EmailAddress TEXT, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, primary key (EmailAddressID, BusinessEntityID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Employee ( BusinessEntityID INTEGER not null primary key, NationalIDNumber TEXT not null unique, LoginID TEXT not null unique, OrganizationNode TEXT, OrganizationLevel INTEGER, JobTitle TEXT not null, BirthDate DATE not null, MaritalStatus TEXT not null, Gender TEXT not null, HireDate DATE not null, SalariedFlag INTEGER default 1 not null, VacationHours INTEGER default 0 not null, SickLeaveHours INTEGER default 0 not null, CurrentFlag INTEGER default 1 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE Password ( BusinessEntityID INTEGER not null primary key, PasswordHash TEXT not null, PasswordSalt TEXT not null, rowguid TEXT not null, ModifiedDate DATETIME default current_timestamp not null, foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE PersonCreditCard ( BusinessEntityID INTEGER not null, CreditCardID INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, CreditCardID), foreign key (CreditCardID) references CreditCard(CreditCardID), foreign key (BusinessEntityID) references Person(BusinessEntityID) ); CREATE TABLE ProductCategory ( ProductCategoryID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductDescription ( ProductDescriptionID INTEGER primary key autoincrement, Description TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModel ( ProductModelID INTEGER primary key autoincrement, Name TEXT not null unique, CatalogDescription TEXT, Instructions TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductModelProductDescriptionCulture ( ProductModelID INTEGER not null, ProductDescriptionID INTEGER not null, CultureID TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductModelID, ProductDescriptionID, CultureID), foreign key (ProductModelID) references ProductModel(ProductModelID), foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID), foreign key (CultureID) references Culture(CultureID) ); CREATE TABLE ProductPhoto ( ProductPhotoID INTEGER primary key autoincrement, ThumbNailPhoto BLOB, ThumbnailPhotoFileName TEXT, LargePhoto BLOB, LargePhotoFileName TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductSubcategory ( ProductSubcategoryID INTEGER primary key autoincrement, ProductCategoryID INTEGER not null, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID) ); CREATE TABLE SalesReason ( SalesReasonID INTEGER primary key autoincrement, Name TEXT not null, ReasonType TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SalesTerritory ( TerritoryID INTEGER primary key autoincrement, Name TEXT not null unique, CountryRegionCode TEXT not null, "Group" TEXT not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, CostYTD REAL default 0.0000 not null, CostLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode) ); CREATE TABLE SalesPerson ( BusinessEntityID INTEGER not null primary key, TerritoryID INTEGER, SalesQuota REAL, Bonus REAL default 0.0000 not null, CommissionPct REAL default 0.0000 not null, SalesYTD REAL default 0.0000 not null, SalesLastYear REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references Employee(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE SalesPersonQuotaHistory ( BusinessEntityID INTEGER not null, QuotaDate DATETIME not null, SalesQuota REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, QuotaDate), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesTerritoryHistory ( BusinessEntityID INTEGER not null, TerritoryID INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (BusinessEntityID, StartDate, TerritoryID), foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID) ); CREATE TABLE ScrapReason ( ScrapReasonID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE Shift ( ShiftID INTEGER primary key autoincrement, Name TEXT not null unique, StartTime TEXT not null, EndTime TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StartTime, EndTime) ); CREATE TABLE ShipMethod ( ShipMethodID INTEGER primary key autoincrement, Name TEXT not null unique, ShipBase REAL default 0.0000 not null, ShipRate REAL default 0.0000 not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE SpecialOffer ( SpecialOfferID INTEGER primary key autoincrement, Description TEXT not null, DiscountPct REAL default 0.0000 not null, Type TEXT not null, Category TEXT not null, StartDate DATETIME not null, EndDate DATETIME not null, MinQty INTEGER default 0 not null, MaxQty INTEGER, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE BusinessEntityAddress ( BusinessEntityID INTEGER not null, AddressID INTEGER not null, AddressTypeID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, AddressID, AddressTypeID), foreign key (AddressID) references Address(AddressID), foreign key (AddressTypeID) references AddressType(AddressTypeID), foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE SalesTaxRate ( SalesTaxRateID INTEGER primary key autoincrement, StateProvinceID INTEGER not null, TaxType INTEGER not null, TaxRate REAL default 0.0000 not null, Name TEXT not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceID, TaxType), foreign key (StateProvinceID) references StateProvince(StateProvinceID) ); CREATE TABLE Store ( BusinessEntityID INTEGER not null primary key, Name TEXT not null, SalesPersonID INTEGER, Demographics TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID), foreign key (SalesPersonID) references SalesPerson(BusinessEntityID) ); CREATE TABLE SalesOrderHeaderSalesReason ( SalesOrderID INTEGER not null, SalesReasonID INTEGER not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SalesOrderID, SalesReasonID), foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SalesReasonID) references SalesReason(SalesReasonID) ); CREATE TABLE TransactionHistoryArchive ( TransactionID INTEGER not null primary key, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE UnitMeasure ( UnitMeasureCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE ProductCostHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, StandardCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ProductDocument ( ProductID INTEGER not null, DocumentNode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, DocumentNode), foreign key (ProductID) references Product(ProductID), foreign key (DocumentNode) references Document(DocumentNode) ); CREATE TABLE ProductInventory ( ProductID INTEGER not null, LocationID INTEGER not null, Shelf TEXT not null, Bin INTEGER not null, Quantity INTEGER default 0 not null, rowguid TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, LocationID), foreign key (ProductID) references Product(ProductID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE ProductProductPhoto ( ProductID INTEGER not null, ProductPhotoID INTEGER not null, "Primary" INTEGER default 0 not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, ProductPhotoID), foreign key (ProductID) references Product(ProductID), foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID) ); CREATE TABLE ProductReview ( ProductReviewID INTEGER primary key autoincrement, ProductID INTEGER not null, ReviewerName TEXT not null, ReviewDate DATETIME default CURRENT_TIMESTAMP not null, EmailAddress TEXT not null, Rating INTEGER not null, Comments TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE ShoppingCartItem ( ShoppingCartItemID INTEGER primary key autoincrement, ShoppingCartID TEXT not null, Quantity INTEGER default 1 not null, ProductID INTEGER not null, DateCreated DATETIME default CURRENT_TIMESTAMP not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SpecialOfferProduct ( SpecialOfferID INTEGER not null, ProductID INTEGER not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (SpecialOfferID, ProductID), foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE SalesOrderDetail ( SalesOrderID INTEGER not null, SalesOrderDetailID INTEGER primary key autoincrement, CarrierTrackingNumber TEXT, OrderQty INTEGER not null, ProductID INTEGER not null, SpecialOfferID INTEGER not null, UnitPrice REAL not null, UnitPriceDiscount REAL default 0.0000 not null, LineTotal REAL not null, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID), foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID) ); CREATE TABLE TransactionHistory ( TransactionID INTEGER primary key autoincrement, ProductID INTEGER not null, ReferenceOrderID INTEGER not null, ReferenceOrderLineID INTEGER default 0 not null, TransactionDate DATETIME default CURRENT_TIMESTAMP not null, TransactionType TEXT not null, Quantity INTEGER not null, ActualCost REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID) ); CREATE TABLE Vendor ( BusinessEntityID INTEGER not null primary key, AccountNumber TEXT not null unique, Name TEXT not null, CreditRating INTEGER not null, PreferredVendorStatus INTEGER default 1 not null, ActiveFlag INTEGER default 1 not null, PurchasingWebServiceURL TEXT, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID) ); CREATE TABLE ProductVendor ( ProductID INTEGER not null, BusinessEntityID INTEGER not null, AverageLeadTime INTEGER not null, StandardPrice REAL not null, LastReceiptCost REAL, LastReceiptDate DATETIME, MinOrderQty INTEGER not null, MaxOrderQty INTEGER not null, OnOrderQty INTEGER, UnitMeasureCode TEXT not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, BusinessEntityID), foreign key (ProductID) references Product(ProductID), foreign key (BusinessEntityID) references Vendor(BusinessEntityID), foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode) ); CREATE TABLE PurchaseOrderHeader ( PurchaseOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, Status INTEGER default 1 not null, EmployeeID INTEGER not null, VendorID INTEGER not null, ShipMethodID INTEGER not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, ShipDate DATETIME, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (EmployeeID) references Employee(BusinessEntityID), foreign key (VendorID) references Vendor(BusinessEntityID), foreign key (ShipMethodID) references ShipMethod(ShipMethodID) ); CREATE TABLE PurchaseOrderDetail ( PurchaseOrderID INTEGER not null, PurchaseOrderDetailID INTEGER primary key autoincrement, DueDate DATETIME not null, OrderQty INTEGER not null, ProductID INTEGER not null, UnitPrice REAL not null, LineTotal REAL not null, ReceivedQty REAL not null, RejectedQty REAL not null, StockedQty REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE WorkOrder ( WorkOrderID INTEGER primary key autoincrement, ProductID INTEGER not null, OrderQty INTEGER not null, StockedQty INTEGER not null, ScrappedQty INTEGER not null, StartDate DATETIME not null, EndDate DATETIME, DueDate DATETIME not null, ScrapReasonID INTEGER, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, foreign key (ProductID) references Product(ProductID), foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID) ); CREATE TABLE WorkOrderRouting ( WorkOrderID INTEGER not null, ProductID INTEGER not null, OperationSequence INTEGER not null, LocationID INTEGER not null, ScheduledStartDate DATETIME not null, ScheduledEndDate DATETIME not null, ActualStartDate DATETIME, ActualEndDate DATETIME, ActualResourceHrs REAL, PlannedCost REAL not null, ActualCost REAL, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (WorkOrderID, ProductID, OperationSequence), foreign key (WorkOrderID) references WorkOrder(WorkOrderID), foreign key (LocationID) references Location(LocationID) ); CREATE TABLE Customer ( CustomerID INTEGER primary key, PersonID INTEGER, StoreID INTEGER, TerritoryID INTEGER, AccountNumber TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, foreign key (PersonID) references Person(BusinessEntityID), foreign key (TerritoryID) references SalesTerritory(TerritoryID), foreign key (StoreID) references Store(BusinessEntityID) ); CREATE TABLE ProductListPriceHistory ( ProductID INTEGER not null, StartDate DATE not null, EndDate DATE, ListPrice REAL not null, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, primary key (ProductID, StartDate), foreign key (ProductID) references Product(ProductID) ); CREATE TABLE IF NOT EXISTS "Address" ( AddressID INTEGER primary key autoincrement, AddressLine1 TEXT not null, AddressLine2 TEXT, City TEXT not null, StateProvinceID INTEGER not null references StateProvince, PostalCode TEXT not null, SpatialLocation TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode) ); CREATE TABLE IF NOT EXISTS "AddressType" ( AddressTypeID INTEGER primary key autoincrement, Name TEXT not null unique, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "BillOfMaterials" ( BillOfMaterialsID INTEGER primary key autoincrement, ProductAssemblyID INTEGER references Product, ComponentID INTEGER not null references Product, StartDate DATETIME default current_timestamp not null, EndDate DATETIME, UnitMeasureCode TEXT not null references UnitMeasure, BOMLevel INTEGER not null, PerAssemblyQty REAL default 1.00 not null, ModifiedDate DATETIME default current_timestamp not null, unique (ProductAssemblyID, ComponentID, StartDate) ); CREATE TABLE IF NOT EXISTS "BusinessEntity" ( BusinessEntityID INTEGER primary key autoincrement, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "ContactType" ( ContactTypeID INTEGER primary key autoincrement, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "CurrencyRate" ( CurrencyRateID INTEGER primary key autoincrement, CurrencyRateDate DATETIME not null, FromCurrencyCode TEXT not null references Currency, ToCurrencyCode TEXT not null references Currency, AverageRate REAL not null, EndOfDayRate REAL not null, ModifiedDate DATETIME default current_timestamp not null, unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode) ); CREATE TABLE IF NOT EXISTS "Department" ( DepartmentID INTEGER primary key autoincrement, Name TEXT not null unique, GroupName TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory" ( BusinessEntityID INTEGER not null references Employee, DepartmentID INTEGER not null references Department, ShiftID INTEGER not null references Shift, StartDate DATE not null, EndDate DATE, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID) ); CREATE TABLE IF NOT EXISTS "EmployeePayHistory" ( BusinessEntityID INTEGER not null references Employee, RateChangeDate DATETIME not null, Rate REAL not null, PayFrequency INTEGER not null, ModifiedDate DATETIME default current_timestamp not null, primary key (BusinessEntityID, RateChangeDate) ); CREATE TABLE IF NOT EXISTS "JobCandidate" ( JobCandidateID INTEGER primary key autoincrement, BusinessEntityID INTEGER references Employee, Resume TEXT, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Location" ( LocationID INTEGER primary key autoincrement, Name TEXT not null unique, CostRate REAL default 0.0000 not null, Availability REAL default 0.00 not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "PhoneNumberType" ( PhoneNumberTypeID INTEGER primary key autoincrement, Name TEXT not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Product" ( ProductID INTEGER primary key autoincrement, Name TEXT not null unique, ProductNumber TEXT not null unique, MakeFlag INTEGER default 1 not null, FinishedGoodsFlag INTEGER default 1 not null, Color TEXT, SafetyStockLevel INTEGER not null, ReorderPoint INTEGER not null, StandardCost REAL not null, ListPrice REAL not null, Size TEXT, SizeUnitMeasureCode TEXT references UnitMeasure, WeightUnitMeasureCode TEXT references UnitMeasure, Weight REAL, DaysToManufacture INTEGER not null, ProductLine TEXT, Class TEXT, Style TEXT, ProductSubcategoryID INTEGER references ProductSubcategory, ProductModelID INTEGER references ProductModel, SellStartDate DATETIME not null, SellEndDate DATETIME, DiscontinuedDate DATETIME, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "Document" ( DocumentNode TEXT not null primary key, DocumentLevel INTEGER, Title TEXT not null, Owner INTEGER not null references Employee, FolderFlag INTEGER default 0 not null, FileName TEXT not null, FileExtension TEXT not null, Revision TEXT not null, ChangeNumber INTEGER default 0 not null, Status INTEGER not null, DocumentSummary TEXT, Document BLOB, rowguid TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null, unique (DocumentLevel, DocumentNode) ); CREATE TABLE IF NOT EXISTS "StateProvince" ( StateProvinceID INTEGER primary key autoincrement, StateProvinceCode TEXT not null, CountryRegionCode TEXT not null references CountryRegion, IsOnlyStateProvinceFlag INTEGER default 1 not null, Name TEXT not null unique, TerritoryID INTEGER not null references SalesTerritory, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, unique (StateProvinceCode, CountryRegionCode) ); CREATE TABLE IF NOT EXISTS "CreditCard" ( CreditCardID INTEGER primary key autoincrement, CardType TEXT not null, CardNumber TEXT not null unique, ExpMonth INTEGER not null, ExpYear INTEGER not null, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE IF NOT EXISTS "SalesOrderHeader" ( SalesOrderID INTEGER primary key autoincrement, RevisionNumber INTEGER default 0 not null, OrderDate DATETIME default CURRENT_TIMESTAMP not null, DueDate DATETIME not null, ShipDate DATETIME, Status INTEGER default 1 not null, OnlineOrderFlag INTEGER default 1 not null, SalesOrderNumber TEXT not null unique, PurchaseOrderNumber TEXT, AccountNumber TEXT, CustomerID INTEGER not null references Customer, SalesPersonID INTEGER references SalesPerson, TerritoryID INTEGER references SalesTerritory, BillToAddressID INTEGER not null references Address, ShipToAddressID INTEGER not null references Address, ShipMethodID INTEGER not null references Address, CreditCardID INTEGER references CreditCard, CreditCardApprovalCode TEXT, CurrencyRateID INTEGER references CurrencyRate, SubTotal REAL default 0.0000 not null, TaxAmt REAL default 0.0000 not null, Freight REAL default 0.0000 not null, TotalDue REAL not null, Comment TEXT, rowguid TEXT not null unique, ModifiedDate DATETIME default CURRENT_TIMESTAMP not null );
donor
How many projects have their resources provided by the vendor Lakeshore Learning Materials and are created by a teacher with a doctor degree?
Lakeshore Learning Materials is vendor_name;  teacher with a doctor degree refers to teacher_prefix = 'Dr.';
SELECT COUNT(T1.projectid) FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.vendor_name = 'Lakeshore Learning Materials' AND T2.teacher_prefix = 'Dr.'
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "essays" ( projectid TEXT, teacher_acctid TEXT, title TEXT, short_description TEXT, need_statement TEXT, essay TEXT ); CREATE TABLE IF NOT EXISTS "projects" ( projectid TEXT not null primary key, teacher_acctid TEXT, schoolid TEXT, school_ncesid TEXT, school_latitude REAL, school_longitude REAL, school_city TEXT, school_state TEXT, school_zip INTEGER, school_metro TEXT, school_district TEXT, school_county TEXT, school_charter TEXT, school_magnet TEXT, school_year_round TEXT, school_nlns TEXT, school_kipp TEXT, school_charter_ready_promise TEXT, teacher_prefix TEXT, teacher_teach_for_america TEXT, teacher_ny_teaching_fellow TEXT, primary_focus_subject TEXT, primary_focus_area TEXT, secondary_focus_subject TEXT, secondary_focus_area TEXT, resource_type TEXT, poverty_level TEXT, grade_level TEXT, fulfillment_labor_materials REAL, total_price_excluding_optional_support REAL, total_price_including_optional_support REAL, students_reached INTEGER, eligible_double_your_impact_match TEXT, eligible_almost_home_match TEXT, date_posted DATE ); CREATE TABLE donations ( donationid TEXT not null primary key, projectid TEXT, donor_acctid TEXT, donor_city TEXT, donor_state TEXT, donor_zip TEXT, is_teacher_acct TEXT, donation_timestamp DATETIME, donation_to_project REAL, donation_optional_support REAL, donation_total REAL, dollar_amount TEXT, donation_included_optional_support TEXT, payment_method TEXT, payment_included_acct_credit TEXT, payment_included_campaign_gift_card TEXT, payment_included_web_purchased_gift_card TEXT, payment_was_promo_matched TEXT, via_giving_page TEXT, for_honoree TEXT, donation_message TEXT, foreign key (projectid) references projects(projectid) ); CREATE TABLE resources ( resourceid TEXT not null primary key, projectid TEXT, vendorid INTEGER, vendor_name TEXT, project_resource_type TEXT, item_name TEXT, item_number TEXT, item_unit_price REAL, item_quantity INTEGER, foreign key (projectid) references projects(projectid) );
superstore
Calculate the difference between the total sales in the East superstore and the total sales in the West superstore.
East superstore refers to Region = 'East'; West superstore refers to Region = 'West'; difference = subtract(sum(Sales) when Region = 'East', sum(Sales) when Region = 'West')
SELECT SUM(T1.Sales) - SUM(T2.Sales) AS difference FROM east_superstore AS T1 INNER JOIN west_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID`
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TEXT, "Product Name" TEXT, Category TEXT, "Sub-Category" TEXT, Region TEXT, primary key ("Product ID", Region) ); CREATE TABLE central_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE east_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE south_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) ); CREATE TABLE west_superstore ( "Row ID" INTEGER primary key, "Order ID" TEXT, "Order Date" DATE, "Ship Date" DATE, "Ship Mode" TEXT, "Customer ID" TEXT, Region TEXT, "Product ID" TEXT, Sales REAL, Quantity INTEGER, Discount REAL, Profit REAL, foreign key ("Customer ID", Region) references people("Customer ID",Region), foreign key ("Product ID", Region) references product("Product ID",Region) );
mondial_geo
Among countries with more than 400,000 GDP, state its capital and population.
SELECT T1.Capital, T1.Population FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country WHERE T2.GDP > 400000
CREATE TABLE IF NOT EXISTS "borders" ( Country1 TEXT default '' not null constraint borders_ibfk_1 references country, Country2 TEXT default '' not null constraint borders_ibfk_2 references country, Length REAL, primary key (Country1, Country2) ); CREATE TABLE IF NOT EXISTS "city" ( Name TEXT default '' not null, Country TEXT default '' not null constraint city_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, Population INTEGER, Longitude REAL, Latitude REAL, primary key (Name, Province), constraint city_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "continent" ( Name TEXT default '' not null primary key, Area REAL ); CREATE TABLE IF NOT EXISTS "country" ( Name TEXT not null constraint ix_county_Name unique, Code TEXT default '' not null primary key, Capital TEXT, Province TEXT, Area REAL, Population INTEGER ); CREATE TABLE IF NOT EXISTS "desert" ( Name TEXT default '' not null primary key, Area REAL, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "economy" ( Country TEXT default '' not null primary key constraint economy_ibfk_1 references country on update cascade on delete cascade, GDP REAL, Agriculture REAL, Service REAL, Industry REAL, Inflation REAL ); CREATE TABLE IF NOT EXISTS "encompasses" ( Country TEXT not null constraint encompasses_ibfk_1 references country on update cascade on delete cascade, Continent TEXT not null constraint encompasses_ibfk_2 references continent on update cascade on delete cascade, Percentage REAL, primary key (Country, Continent) ); CREATE TABLE IF NOT EXISTS "ethnicGroup" ( Country TEXT default '' not null constraint ethnicGroup_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "geo_desert" ( Desert TEXT default '' not null constraint geo_desert_ibfk_3 references desert on update cascade on delete cascade, Country TEXT default '' not null constraint geo_desert_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Desert), constraint geo_desert_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_estuary" ( River TEXT default '' not null constraint geo_estuary_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_estuary_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_estuary_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_island" ( Island TEXT default '' not null constraint geo_island_ibfk_3 references island on update cascade on delete cascade, Country TEXT default '' not null constraint geo_island_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Island), constraint geo_island_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_lake" ( Lake TEXT default '' not null constraint geo_lake_ibfk_3 references lake on update cascade on delete cascade, Country TEXT default '' not null constraint geo_lake_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Lake), constraint geo_lake_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_mountain" ( Mountain TEXT default '' not null constraint geo_mountain_ibfk_3 references mountain on update cascade on delete cascade, Country TEXT default '' not null constraint geo_mountain_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Mountain), constraint geo_mountain_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_river" ( River TEXT default '' not null constraint geo_river_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_river_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_river_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_sea" ( Sea TEXT default '' not null constraint geo_sea_ibfk_3 references sea on update cascade on delete cascade, Country TEXT default '' not null constraint geo_sea_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, Sea), constraint geo_sea_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "geo_source" ( River TEXT default '' not null constraint geo_source_ibfk_3 references river on update cascade on delete cascade, Country TEXT default '' not null constraint geo_source_ibfk_1 references country on update cascade on delete cascade, Province TEXT default '' not null, primary key (Province, Country, River), constraint geo_source_ibfk_2 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "island" ( Name TEXT default '' not null primary key, Islands TEXT, Area REAL, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "islandIn" ( Island TEXT constraint islandIn_ibfk_4 references island on update cascade on delete cascade, Sea TEXT constraint islandIn_ibfk_3 references sea on update cascade on delete cascade, Lake TEXT constraint islandIn_ibfk_1 references lake on update cascade on delete cascade, River TEXT constraint islandIn_ibfk_2 references river on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "isMember" ( Country TEXT default '' not null constraint isMember_ibfk_1 references country on update cascade on delete cascade, Organization TEXT default '' not null constraint isMember_ibfk_2 references organization on update cascade on delete cascade, Type TEXT default 'member', primary key (Country, Organization) ); CREATE TABLE IF NOT EXISTS "lake" ( Name TEXT default '' not null primary key, Area REAL, Depth REAL, Altitude REAL, Type TEXT, River TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "language" ( Country TEXT default '' not null constraint language_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "located" ( City TEXT, Province TEXT, Country TEXT constraint located_ibfk_1 references country on update cascade on delete cascade, River TEXT constraint located_ibfk_3 references river on update cascade on delete cascade, Lake TEXT constraint located_ibfk_4 references lake on update cascade on delete cascade, Sea TEXT constraint located_ibfk_5 references sea on update cascade on delete cascade, constraint located_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint located_ibfk_6 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "locatedOn" ( City TEXT default '' not null, Province TEXT default '' not null, Country TEXT default '' not null constraint locatedOn_ibfk_1 references country on update cascade on delete cascade, Island TEXT default '' not null constraint locatedOn_ibfk_2 references island on update cascade on delete cascade, primary key (City, Province, Country, Island), constraint locatedOn_ibfk_3 foreign key (City, Province) references city on update cascade on delete cascade, constraint locatedOn_ibfk_4 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "mergesWith" ( Sea1 TEXT default '' not null constraint mergesWith_ibfk_1 references sea on update cascade on delete cascade, Sea2 TEXT default '' not null constraint mergesWith_ibfk_2 references sea on update cascade on delete cascade, primary key (Sea1, Sea2) ); CREATE TABLE IF NOT EXISTS "mountain" ( Name TEXT default '' not null primary key, Mountains TEXT, Height REAL, Type TEXT, Longitude REAL, Latitude REAL ); CREATE TABLE IF NOT EXISTS "mountainOnIsland" ( Mountain TEXT default '' not null constraint mountainOnIsland_ibfk_2 references mountain on update cascade on delete cascade, Island TEXT default '' not null constraint mountainOnIsland_ibfk_1 references island on update cascade on delete cascade, primary key (Mountain, Island) ); CREATE TABLE IF NOT EXISTS "organization" ( Abbreviation TEXT not null primary key, Name TEXT not null constraint ix_organization_OrgNameUnique unique, City TEXT, Country TEXT constraint organization_ibfk_1 references country on update cascade on delete cascade, Province TEXT, Established DATE, constraint organization_ibfk_2 foreign key (City, Province) references city on update cascade on delete cascade, constraint organization_ibfk_3 foreign key (Province, Country) references province on update cascade on delete cascade ); CREATE TABLE IF NOT EXISTS "politics" ( Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, Government TEXT ); CREATE TABLE IF NOT EXISTS "population" ( Country TEXT default '' not null primary key constraint population_ibfk_1 references country on update cascade on delete cascade, Population_Growth REAL, Infant_Mortality REAL ); CREATE TABLE IF NOT EXISTS "province" ( Name TEXT not null, Country TEXT not null constraint province_ibfk_1 references country on update cascade on delete cascade, Population INTEGER, Area REAL, Capital TEXT, CapProv TEXT, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "religion" ( Country TEXT default '' not null constraint religion_ibfk_1 references country on update cascade on delete cascade, Name TEXT default '' not null, Percentage REAL, primary key (Name, Country) ); CREATE TABLE IF NOT EXISTS "river" ( Name TEXT default '' not null primary key, River TEXT, Lake TEXT constraint river_ibfk_1 references lake on update cascade on delete cascade, Sea TEXT, Length REAL, SourceLongitude REAL, SourceLatitude REAL, Mountains TEXT, SourceAltitude REAL, EstuaryLongitude REAL, EstuaryLatitude REAL ); CREATE TABLE IF NOT EXISTS "sea" ( Name TEXT default '' not null primary key, Depth REAL ); CREATE TABLE IF NOT EXISTS "target" ( Country TEXT not null primary key constraint target_Country_fkey references country on update cascade on delete cascade, Target TEXT );
human_resources
What is the max salary for 'Tracy Coulter' if he/she stays on his/her position?
Tracy Coulter is the full name of an employee; full name = firstname, lastname
SELECT T2.maxsalary FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.firstname = 'Tracy' AND T1.lastname = 'Coulter'
CREATE TABLE location ( locationID INTEGER constraint location_pk primary key, locationcity TEXT, address TEXT, state TEXT, zipcode INTEGER, officephone TEXT ); CREATE TABLE position ( positionID INTEGER constraint position_pk primary key, positiontitle TEXT, educationrequired TEXT, minsalary TEXT, maxsalary TEXT ); CREATE TABLE employee ( ssn TEXT primary key, lastname TEXT, firstname TEXT, hiredate TEXT, salary TEXT, gender TEXT, performance TEXT, positionID INTEGER, locationID INTEGER, foreign key (locationID) references location(locationID), foreign key (positionID) references position(positionID) );
hockey
State the nick name of the tallest player? If the player had left NHL, mention the last season he was with NHL.
nick name refers to nameNick; tallest player refers to MAX(height); had left NHL refers to lastNHL
SELECT nameNick, lastNHL FROM Master ORDER BY height DESC LIMIT 1
CREATE TABLE AwardsMisc ( name TEXT not null primary key, ID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT ); CREATE TABLE HOF ( year INTEGER, hofID TEXT not null primary key, name TEXT, category TEXT ); CREATE TABLE Teams ( year INTEGER not null, lgID TEXT, tmID TEXT not null, franchID TEXT, confID TEXT, divID TEXT, rank INTEGER, playoff TEXT, G INTEGER, W INTEGER, L INTEGER, T INTEGER, OTL TEXT, Pts INTEGER, SoW TEXT, SoL TEXT, GF INTEGER, GA INTEGER, name TEXT, PIM TEXT, BenchMinor TEXT, PPG TEXT, PPC TEXT, SHA TEXT, PKG TEXT, PKC TEXT, SHF TEXT, primary key (year, tmID) ); CREATE TABLE Coaches ( coachID TEXT not null, year INTEGER not null, tmID TEXT not null, lgID TEXT, stint INTEGER not null, notes TEXT, g INTEGER, w INTEGER, l INTEGER, t INTEGER, postg TEXT, postw TEXT, postl TEXT, postt TEXT, primary key (coachID, year, tmID, stint), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE AwardsCoaches ( coachID TEXT, award TEXT, year INTEGER, lgID TEXT, note TEXT, foreign key (coachID) references Coaches (coachID) ); CREATE TABLE Master ( playerID TEXT, coachID TEXT, hofID TEXT, firstName TEXT, lastName TEXT not null, nameNote TEXT, nameGiven TEXT, nameNick TEXT, height TEXT, weight TEXT, shootCatch TEXT, legendsID TEXT, ihdbID TEXT, hrefID TEXT, firstNHL TEXT, lastNHL TEXT, firstWHA TEXT, lastWHA TEXT, pos TEXT, birthYear TEXT, birthMon TEXT, birthDay TEXT, birthCountry TEXT, birthState TEXT, birthCity TEXT, deathYear TEXT, deathMon TEXT, deathDay TEXT, deathCountry TEXT, deathState TEXT, deathCity TEXT, foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade ); CREATE TABLE AwardsPlayers ( playerID TEXT not null, award TEXT not null, year INTEGER not null, lgID TEXT, note TEXT, pos TEXT, primary key (playerID, award, year), foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE CombinedShutouts ( year INTEGER, month INTEGER, date INTEGER, tmID TEXT, oppID TEXT, "R/P" TEXT, IDgoalie1 TEXT, IDgoalie2 TEXT, foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE Goalies ( playerID TEXT not null, year INTEGER not null, stint INTEGER not null, tmID TEXT, lgID TEXT, GP TEXT, Min TEXT, W TEXT, L TEXT, "T/OL" TEXT, ENG TEXT, SHO TEXT, GA TEXT, SA TEXT, PostGP TEXT, PostMin TEXT, PostW TEXT, PostL TEXT, PostT TEXT, PostENG TEXT, PostSHO TEXT, PostGA TEXT, PostSA TEXT, primary key (playerID, year, stint), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE GoaliesSC ( playerID TEXT not null, year INTEGER not null, tmID TEXT, lgID TEXT, GP INTEGER, Min INTEGER, W INTEGER, L INTEGER, T INTEGER, SHO INTEGER, GA INTEGER, primary key (playerID, year), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE GoaliesShootout ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, W INTEGER, L INTEGER, SA INTEGER, GA INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE Scoring ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, lgID TEXT, pos TEXT, GP INTEGER, G INTEGER, A INTEGER, Pts INTEGER, PIM INTEGER, "+/-" TEXT, PPG TEXT, PPA TEXT, SHG TEXT, SHA TEXT, GWG TEXT, GTG TEXT, SOG TEXT, PostGP TEXT, PostG TEXT, PostA TEXT, PostPts TEXT, PostPIM TEXT, "Post+/-" TEXT, PostPPG TEXT, PostPPA TEXT, PostSHG TEXT, PostSHA TEXT, PostGWG TEXT, PostSOG TEXT, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringSC ( playerID TEXT, year INTEGER, tmID TEXT, lgID TEXT, pos TEXT, GP INTEGER, G INTEGER, A INTEGER, Pts INTEGER, PIM INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringShootout ( playerID TEXT, year INTEGER, stint INTEGER, tmID TEXT, S INTEGER, G INTEGER, GDG INTEGER, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE ScoringSup ( playerID TEXT, year INTEGER, PPA TEXT, SHA TEXT, foreign key (playerID) references Master (playerID) on update cascade on delete cascade ); CREATE TABLE SeriesPost ( year INTEGER, round TEXT, series TEXT, tmIDWinner TEXT, lgIDWinner TEXT, tmIDLoser TEXT, lgIDLoser TEXT, W INTEGER, L INTEGER, T INTEGER, GoalsWinner INTEGER, GoalsLoser INTEGER, note TEXT, foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamSplits ( year INTEGER not null, lgID TEXT, tmID TEXT not null, hW INTEGER, hL INTEGER, hT INTEGER, hOTL TEXT, rW INTEGER, rL INTEGER, rT INTEGER, rOTL TEXT, SepW TEXT, SepL TEXT, SepT TEXT, SepOL TEXT, OctW TEXT, OctL TEXT, OctT TEXT, OctOL TEXT, NovW TEXT, NovL TEXT, NovT TEXT, NovOL TEXT, DecW TEXT, DecL TEXT, DecT TEXT, DecOL TEXT, JanW INTEGER, JanL INTEGER, JanT INTEGER, JanOL TEXT, FebW INTEGER, FebL INTEGER, FebT INTEGER, FebOL TEXT, MarW TEXT, MarL TEXT, MarT TEXT, MarOL TEXT, AprW TEXT, AprL TEXT, AprT TEXT, AprOL TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamVsTeam ( year INTEGER not null, lgID TEXT, tmID TEXT not null, oppID TEXT not null, W INTEGER, L INTEGER, T INTEGER, OTL TEXT, primary key (year, tmID, oppID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE TeamsHalf ( year INTEGER not null, lgID TEXT, tmID TEXT not null, half INTEGER not null, rank INTEGER, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, primary key (year, tmID, half), foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade ); CREATE TABLE TeamsPost ( year INTEGER not null, lgID TEXT, tmID TEXT not null, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, PIM TEXT, BenchMinor TEXT, PPG TEXT, PPC TEXT, SHA TEXT, PKG TEXT, PKC TEXT, SHF TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE TeamsSC ( year INTEGER not null, lgID TEXT, tmID TEXT not null, G INTEGER, W INTEGER, L INTEGER, T INTEGER, GF INTEGER, GA INTEGER, PIM TEXT, primary key (year, tmID), foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade ); CREATE TABLE abbrev ( Type TEXT not null, Code TEXT not null, Fullname TEXT, primary key (Type, Code) );
movie_3
How many films in English are for adults only?
English is a name of a language; for adults only refers to rating = 'NC-17'
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T2.name = 'English' AND T1.rating = 'NC-17'
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );
olympics
In which cities were the 1976 winter and summer games held?
cities refer to city_name; 1976 winter and summer games refer to games_name IN ('1976 Winter', '1976 Summer');
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_name IN ('1976 Summer', '1976 Winter')
CREATE TABLE city ( id INTEGER not null primary key, city_name TEXT default NULL ); CREATE TABLE games ( id INTEGER not null primary key, games_year INTEGER default NULL, games_name TEXT default NULL, season TEXT default NULL ); CREATE TABLE games_city ( games_id INTEGER default NULL, city_id INTEGER default NULL, foreign key (city_id) references city(id), foreign key (games_id) references games(id) ); CREATE TABLE medal ( id INTEGER not null primary key, medal_name TEXT default NULL ); CREATE TABLE noc_region ( id INTEGER not null primary key, noc TEXT default NULL, region_name TEXT default NULL ); CREATE TABLE person ( id INTEGER not null primary key, full_name TEXT default NULL, gender TEXT default NULL, height INTEGER default NULL, weight INTEGER default NULL ); CREATE TABLE games_competitor ( id INTEGER not null primary key, games_id INTEGER default NULL, person_id INTEGER default NULL, age INTEGER default NULL, foreign key (games_id) references games(id), foreign key (person_id) references person(id) ); CREATE TABLE person_region ( person_id INTEGER default NULL, region_id INTEGER default NULL, foreign key (person_id) references person(id), foreign key (region_id) references noc_region(id) ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL ); CREATE TABLE event ( id INTEGER not null primary key, sport_id INTEGER default NULL, event_name TEXT default NULL, foreign key (sport_id) references sport(id) ); CREATE TABLE competitor_event ( event_id INTEGER default NULL, competitor_id INTEGER default NULL, medal_id INTEGER default NULL, foreign key (competitor_id) references games_competitor(id), foreign key (event_id) references event(id), foreign key (medal_id) references medal(id) );
movie_3
Tell the special features of the film Uprising Uptown.
"UPRISING UPTOWN" is the title of film
SELECT special_features FROM film WHERE title = 'UPRISING UPTOWN'
CREATE TABLE film_text ( film_id INTEGER not null primary key, title TEXT not null, description TEXT null ); CREATE TABLE IF NOT EXISTS "actor" ( actor_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE IF NOT EXISTS "address" ( address_id INTEGER primary key autoincrement, address TEXT not null, address2 TEXT, district TEXT not null, city_id INTEGER not null references city on update cascade, postal_code TEXT, phone TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "category" ( category_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "city" ( city_id INTEGER primary key autoincrement, city TEXT not null, country_id INTEGER not null references country on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "country" ( country_id INTEGER primary key autoincrement, country TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "customer" ( customer_id INTEGER primary key autoincrement, store_id INTEGER not null references store on update cascade, first_name TEXT not null, last_name TEXT not null, email TEXT, address_id INTEGER not null references address on update cascade, active INTEGER default 1 not null, create_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film" ( film_id INTEGER primary key autoincrement, title TEXT not null, description TEXT, release_year TEXT, language_id INTEGER not null references language on update cascade, original_language_id INTEGER references language on update cascade, rental_duration INTEGER default 3 not null, rental_rate REAL default 4.99 not null, length INTEGER, replacement_cost REAL default 19.99 not null, rating TEXT default 'G', special_features TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "film_actor" ( actor_id INTEGER not null references actor on update cascade, film_id INTEGER not null references film on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (actor_id, film_id) ); CREATE TABLE IF NOT EXISTS "film_category" ( film_id INTEGER not null references film on update cascade, category_id INTEGER not null references category on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, primary key (film_id, category_id) ); CREATE TABLE IF NOT EXISTS "inventory" ( inventory_id INTEGER primary key autoincrement, film_id INTEGER not null references film on update cascade, store_id INTEGER not null references store on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "language" ( language_id INTEGER primary key autoincrement, name TEXT not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "payment" ( payment_id INTEGER primary key autoincrement, customer_id INTEGER not null references customer on update cascade, staff_id INTEGER not null references staff on update cascade, rental_id INTEGER references rental on update cascade on delete set null, amount REAL not null, payment_date DATETIME not null, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "rental" ( rental_id INTEGER primary key autoincrement, rental_date DATETIME not null, inventory_id INTEGER not null references inventory on update cascade, customer_id INTEGER not null references customer on update cascade, return_date DATETIME, staff_id INTEGER not null references staff on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null, unique (rental_date, inventory_id, customer_id) ); CREATE TABLE IF NOT EXISTS "staff" ( staff_id INTEGER primary key autoincrement, first_name TEXT not null, last_name TEXT not null, address_id INTEGER not null references address on update cascade, picture BLOB, email TEXT, store_id INTEGER not null references store on update cascade, active INTEGER default 1 not null, username TEXT not null, password TEXT, last_update DATETIME default CURRENT_TIMESTAMP not null ); CREATE TABLE IF NOT EXISTS "store" ( store_id INTEGER primary key autoincrement, manager_staff_id INTEGER not null unique references staff on update cascade, address_id INTEGER not null references address on update cascade, last_update DATETIME default CURRENT_TIMESTAMP not null );