ajayk007/querysmith-spider-bird huggingface dataset:
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;

CREATE TABLE Apartment_Buildings (
building_id INTEGER NOT NULL,
building_short_name CHAR(15),
building_full_name VARCHAR(80),
building_description VARCHAR(255),
building_address VARCHAR(255),
building_manager VARCHAR(50),
building_phone VARCHAR(80),
PRIMARY KEY (building_id),
UNIQUE (building_id)
);

Question: Which guests have apartment bookings with status code "Confirmed"? Return their first names and last names.

assistant: SELECT T2.guest_first_name , T2.guest_last_name FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id = T2.guest_id WHERE T1.booking_status_code = "Confirmed"
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE Customers (
  CustomerID integer PRIMARY KEY,
  Customer Names text
);
CREATE TABLE Products (
  ProductID integer PRIMARY KEY,
  Product Name text
);
CREATE TABLE Regions (
  StateCode text PRIMARY KEY,
  State text,
  Region text
);
CREATE TABLE Sales Team (
  SalesTeamID integer PRIMARY KEY,
  Sales Team text,
  Region text
);
CREATE TABLE Store Locations (
  StoreID integer PRIMARY KEY,
  City Name text,
  County text,
  StateCode text,
  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 Sales Orders (
  OrderNumber text PRIMARY KEY,
  Sales Channel text,
  WarehouseCode text,
  ProcuredDate text,
  OrderDate text,
  ShipDate text,
  DeliveryDate text,
  CurrencyCode text,
  _SalesTeamID integer,
  _CustomerID integer,
  _StoreID integer,
  _ProductID integer,
  Order Quantity integer,
  Discount Applied real,
  Unit Price text,
  Unit Cost text
);
-- foreign keys: Store Locations.StateCode -> Regions.StateCode; Sales Orders._ProductID -> Products.ProductID; Sales Orders._StoreID -> Store Locations.StoreID; Sales Orders._CustomerID -> Customers.CustomerID; Sales Orders._SalesTeamID -> Sales Team.SalesTeamID

Hint: order have the highest unit cost refers to OrderNumber where MAX(Unit Cost);

Question: Which order have the highest unit cost?

assistant: SELECT OrderNumber FROM `Sales Orders` WHERE REPLACE(`Unit Cost`, ',', '') = ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Cost`, ',', '') DESC LIMIT 1 )
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;

CREATE TABLE "book_club" (
"book_club_id" int,
"Year" int,
"Author_or_Editor" text,
"Book_Title" text,
"Publisher" text,
"Category" text,
"Result" text,
PRIMARY KEY ("book_club_id")
);

Question: What are the titles and authors or editors that correspond to books made after 1989?

assistant: SELECT book_title , author_or_editor FROM book_club WHERE YEAR > 1989
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
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
);
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 keys: Nutrition.recipe_id -> Recipe.recipe_id; Quantity.recipe_id -> Nutrition.recipe_id; Quantity.ingredient_id -> Ingredient.ingredient_id; Quantity.recipe_id -> Recipe.recipe_id

Hint: turkey tenderloin refers to title

Question: How many calories does the turkey tenderloin bundles recipe have?

assistant: SELECT T2.calories FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Turkey Tenderloin Bundles'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
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
);
CREATE TABLE customer (
  customer_id integer PRIMARY KEY,
  first_name text,
  last_name text,
  email text
);
CREATE TABLE customer_address (
  customer_id integer PRIMARY KEY,
  address_id integer PRIMARY KEY,
  status_id integer
);
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
);
CREATE TABLE book_author (
  book_id integer PRIMARY KEY,
  author_id integer PRIMARY KEY
);
CREATE TABLE shipping_method (
  method_id integer PRIMARY KEY,
  method_name text,
  cost real
);
CREATE TABLE cust_order (
  order_id integer PRIMARY KEY,
  order_date datetime,
  customer_id integer,
  shipping_method_id integer,
  dest_address_id integer
);
CREATE TABLE order_history (
  history_id integer PRIMARY KEY,
  order_id integer,
  status_id integer,
  status_date datetime
);
CREATE TABLE order_line (
  line_id integer PRIMARY KEY,
  order_id integer,
  book_id integer,
  price real
);
-- foreign keys: address.country_id -> country.country_id; customer_address.customer_id -> customer.customer_id; customer_address.address_id -> address.address_id; book.publisher_id -> publisher.publisher_id; book.language_id -> book_language.language_id; book_author.book_id -> book.book_id; book_author.author_id -> author.author_id

Hint: "Ace Hardcover" is the publisher_name

Question: How many books were published by Ace Hardcover?

assistant: SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Ace Hardcover'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
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 keys: shipment.truck_id -> truck.truck_id; shipment.driver_id -> driver.driver_id; shipment.city_id -> city.city_id; shipment.cust_id -> customer.cust_id

Hint: weight of no more than 1000 pounds refers to weight < 1000; oldest truck refers to Min (model_year)

Question: How many shipments with weight of no more than 1,000 pounds were shipped by the oldest truck?

assistant: SELECT COUNT(*) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T2.weight < 1000 ORDER BY T1.model_year ASC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE authors (
  au_id text PRIMARY KEY,
  au_lname text,
  au_fname text,
  phone text,
  address text,
  city text,
  state text,
  zip text,
  contract text
);
CREATE TABLE jobs (
  job_id integer PRIMARY KEY,
  job_desc text,
  min_lvl integer,
  max_lvl integer
);
CREATE TABLE publishers (
  pub_id text PRIMARY KEY,
  pub_name text,
  city text,
  state text,
  country text
);
CREATE TABLE employee (
  emp_id text PRIMARY KEY,
  fname text,
  minit text,
  lname text,
  job_id integer,
  job_lvl integer,
  pub_id text,
  hire_date datetime
);
CREATE TABLE pub_info (
  pub_id text PRIMARY KEY,
  logo blob,
  pr_info text
);
CREATE TABLE stores (
  stor_id text PRIMARY KEY,
  stor_name text,
  stor_address text,
  city text,
  state text,
  zip text
);
CREATE TABLE discounts (
  discounttype text,
  stor_id text,
  lowqty integer,
  highqty integer,
  discount real
);
CREATE TABLE titles (
  title_id text PRIMARY KEY,
  title text,
  type text,
  pub_id text,
  price real,
  advance real,
  royalty integer,
  ytd_sales integer,
  notes text,
  pubdate datetime
);
CREATE TABLE roysched (
  title_id text,
  lorange integer,
  hirange integer,
  royalty integer
);
CREATE TABLE sales (
  stor_id text PRIMARY KEY,
  ord_num text PRIMARY KEY,
  ord_date datetime,
  qty integer,
  payterms text,
  title_id text PRIMARY KEY
);
CREATE TABLE titleauthor (
  au_id text PRIMARY KEY,
  title_id text PRIMARY KEY,
  au_ord integer,
  royaltyper integer
);
-- foreign keys: employee.pub_id -> publishers.pub_id; employee.job_id -> jobs.job_id; pub_info.pub_id -> publishers.pub_id; discounts.stor_id -> stores.stor_id; titles.pub_id -> publishers.pub_id; roysched.title_id -> titles.title_id; sales.title_id -> titles.title_id; sales.stor_id -> stores.stor_id; titleauthor.title_id -> titles.title_id; titleauthor.au_id -> authors.au_id

Hint: qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)

Question: What is the price of the book that sells the best?

assistant: SELECT T2.price FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id ORDER BY T1.qty DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
-- drop table flight cascade constraints;
-- drop table aircraft cascade constraints;
-- drop table employee cascade constraints;
-- drop table certificate cascade constraints;

create table flight(
	flno number(4,0) primary key,
	origin varchar2(20),
	destination varchar2(20),
	distance number(6,0),
	departure_date date,
	arrival_date date,
	price number(7,2),
    aid number(9,0),
    foreign key("aid") references `aircraft`("aid"));

create table aircraft(
	aid number(9,0) primary key,
	name varchar2(30),
	distance number(6,0));

create table employee(
	eid number(9,0) primary key,
	name varchar2(30),
	salary number(10,2));

create table certificate(
	eid number(9,0),
	aid number(9,0),
	primary key(eid,aid),
	foreign key("eid") references `employee`("eid"),
	foreign key("aid") references `aircraft`("aid"));

Question: What destination has the fewest number of flights?

assistant: SELECT destination FROM Flight GROUP BY destination ORDER BY count(*) LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE divisions (
  division text PRIMARY KEY,
  name text,
  country text
);
CREATE TABLE matchs (
  Div text,
  Date date,
  HomeTeam text,
  AwayTeam text,
  FTHG integer,
  FTAG integer,
  FTR text,
  season integer
);
-- foreign keys: matchs.Div -> divisions.division

Hint: FALSE;

Question: In which division was the match between Hibernian, the away team, and Hearts, the home team, played? To which country does this division belong?

assistant: SELECT DISTINCT T2.division,T2.country FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.HomeTeam = 'Hearts' AND T1.AwayTeam = 'Hibernian'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;

CREATE TABLE "driver" (
"Driver_ID" int,
"Name" text,
"Party" text,
"Home_city" text,
"Age" int,
PRIMARY KEY ("Driver_ID")
);

CREATE TABLE "school" (
"School_ID" int,
"Grade" text,
"School" text,
"Location" text,
"Type" text,
PRIMARY KEY ("School_ID")
);

Question: Show the home city with the most number of drivers.

assistant: SELECT home_city FROM driver GROUP BY home_city ORDER BY count(*) DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE people (
  Customer ID text PRIMARY KEY,
  Customer Name text,
  Segment text,
  Country text,
  City text,
  State text,
  Postal Code integer,
  Region text PRIMARY KEY
);
CREATE TABLE product (
  Product ID text PRIMARY KEY,
  Product Name text,
  Category text,
  Sub-Category text,
  Region text PRIMARY KEY
);
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
);
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
);
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
);
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 keys: central_superstore.Product ID -> product.Product ID; central_superstore.Region -> product.Region; central_superstore.Customer ID -> people.Customer ID; central_superstore.Region -> people.Region; east_superstore.Product ID -> product.Product ID; east_superstore.Region -> product.Region; east_superstore.Customer ID -> people.Customer ID; east_superstore.Region -> people.Region; south_superstore.Product ID -> product.Product ID; south_superstore.Region -> product.Region; south_superstore.Customer ID -> people.Customer ID; south_superstore.Region -> people.Region; west_superstore.Product ID -> product.Product ID; west_superstore.Region -> product.Region; west_superstore.Customer ID -> people.Customer ID; west_superstore.Region -> people.Region

Hint: Frank Olsen' is the "Customer Name"; Region = 'South'

Question: Provide the order ID of Frank Olsen of the South region.

assistant: SELECT T1.`Order ID` FROM south_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T2.Region = 'South' AND T2.`Customer Name` = 'Frank Olsen'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE station (
  id integer PRIMARY KEY,
  name text,
  lat real,
  long real,
  dock_count integer,
  city text,
  installation_date text
);
CREATE TABLE status (
  station_id integer,
  bikes_available integer,
  docks_available integer,
  time text
);
CREATE TABLE trip (
  id integer PRIMARY KEY,
  duration integer,
  start_date text,
  start_station_name text,
  start_station_id integer,
  end_date text,
  end_station_name text,
  end_station_id integer,
  bike_id integer,
  subscription_type text,
  zip_code integer
);
CREATE TABLE weather (
  date text,
  max_temperature_f integer,
  mean_temperature_f integer,
  min_temperature_f integer,
  max_dew_point_f integer,
  mean_dew_point_f integer,
  min_dew_point_f integer,
  max_humidity integer,
  mean_humidity integer,
  min_humidity integer,
  max_sea_level_pressure_inches real,
  mean_sea_level_pressure_inches real,
  min_sea_level_pressure_inches real,
  max_visibility_miles integer,
  mean_visibility_miles integer,
  min_visibility_miles integer,
  max_wind_Speed_mph integer,
  mean_wind_speed_mph integer,
  max_gust_speed_mph integer,
  precipitation_inches text,
  cloud_cover integer,
  events text,
  wind_dir_degrees integer,
  zip_code text
);

Hint: bike is borrowed from refers to start_station_id;

Question: In which city's station is a bike borrowed on trip ID4069?

assistant: SELECT T2.city FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.id = 4069
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE app_all (
  app_id integer PRIMARY KEY
);
CREATE TABLE app_events (
  event_id integer PRIMARY KEY,
  app_id integer PRIMARY KEY,
  is_installed integer,
  is_active integer
);
CREATE TABLE app_events_relevant (
  event_id integer PRIMARY KEY,
  app_id integer PRIMARY KEY,
  is_installed integer,
  is_active integer
);
CREATE TABLE app_labels (
  app_id integer,
  label_id integer
);
CREATE TABLE events (
  event_id integer PRIMARY KEY,
  device_id integer,
  timestamp datetime,
  longitude real,
  latitude real
);
CREATE TABLE events_relevant (
  event_id integer PRIMARY KEY,
  device_id integer,
  timestamp datetime,
  longitude real,
  latitude real
);
CREATE TABLE gender_age (
  device_id integer PRIMARY KEY,
  gender text,
  age integer,
  group text
);
CREATE TABLE gender_age_test (
  device_id integer PRIMARY KEY
);
CREATE TABLE gender_age_train (
  device_id integer PRIMARY KEY,
  gender text,
  age integer,
  group text
);
CREATE TABLE label_categories (
  label_id integer PRIMARY KEY,
  category text
);
CREATE TABLE phone_brand_device_model2 (
  device_id integer PRIMARY KEY,
  phone_brand text PRIMARY KEY,
  device_model text PRIMARY KEY
);
CREATE TABLE sample_submission (
  device_id integer PRIMARY KEY,
  F23- real,
  F24-26 real,
  F27-28 real,
  F29-32 real,
  F33-42 real,
  F43+ real,
  M22- real,
  M23-26 real,
  M27-28 real,
  M29-31 real,
  M32-38 real,
  M39+ real
);
-- foreign keys: app_events.event_id -> events.event_id; app_events_relevant.app_id -> app_all.app_id; app_events_relevant.event_id -> events_relevant.event_id; app_labels.app_id -> app_all.app_id; app_labels.label_id -> label_categories.label_id; events_relevant.device_id -> gender_age.device_id; gender_age.device_id -> phone_brand_device_model2.device_id

Hint: highest number of users refers to MAX(COUNT(app_id));

Question: Which category has the highest number of users?

assistant: SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;


CREATE TABLE "stadium" (
"id" int,
"name" text,
"Home_Games" int,
"Average_Attendance" real,
"Total_Attendance" real,
"Capacity_Percentage" real,
primary key ("id")
);

CREATE TABLE "game" (
"stadium_id" int,
"id" int,
"Season" int,
"Date" text,
"Home_team" text,
"Away_team" text,
"Score" text,
"Competition" text,
primary key ("id"),
foreign key ("stadium_id") references `stadium`("id")
);

CREATE TABLE "injury_accident" (
"game_id" int,
"id" int,
"Player" text,
"Injury" text,
"Number_of_matches" text,
"Source" text,
primary key ("id"),
foreign key ("game_id") references `game`("id")
);

Question: What are the player name, number of matches, and information source for players who do not suffer from injury of 'Knee problem'?

assistant: SELECT player , number_of_matches , SOURCE FROM injury_accident WHERE injury != 'Knee problem'