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:
CREATE TABLE country (
  id integer PRIMARY KEY,
  country_name text
);
CREATE TABLE ranking_system (
  id integer PRIMARY KEY,
  system_name text
);
CREATE TABLE ranking_criteria (
  id integer PRIMARY KEY,
  ranking_system_id integer,
  criteria_name text
);
CREATE TABLE university (
  id integer PRIMARY KEY,
  country_id integer,
  university_name text
);
CREATE TABLE university_ranking_year (
  university_id integer,
  ranking_criteria_id integer,
  year integer,
  score integer
);
CREATE TABLE university_year (
  university_id integer,
  year integer,
  num_students integer,
  student_staff_ratio real,
  pct_international_students integer,
  pct_female_students integer
);
-- foreign keys: ranking_criteria.ranking_system_id -> ranking_system.id; university.country_id -> country.id; university_ranking_year.university_id -> university.id; university_ranking_year.ranking_criteria_id -> ranking_criteria.id; university_year.university_id -> university.id

Hint: had the lowest number of students refers to MIN(num_students)

Question: Give the year where a university had the lowest number of students.

assistant: SELECT year FROM university_year ORDER BY num_students 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 incidents (
  case_number text PRIMARY KEY,
  date date,
  location text,
  subject_statuses text,
  subject_weapon text,
  subjects text,
  subject_count integer,
  officers text
);
CREATE TABLE officers (
  case_number text,
  race text,
  gender text,
  last_name text,
  first_name text,
  full_name text
);
CREATE TABLE subjects (
  case_number text,
  race text,
  gender text,
  last_name text,
  first_name text,
  full_name text
);
-- foreign keys: officers.case_number -> incidents.case_number; subjects.case_number -> incidents.case_number

Hint: number of cases refers to count(case_number); with Vehicle as subject weapon refers to subject_weapon = 'Vehicle'; year 2007 refers to date between '2007-01-01' and '2007-12-31'; year 2008 refers to date between '2008-01-01' and '2008-12-31'

Question: Did the number of cases with Vehicle as subject weapon increase or decrease from year 2007 to 2008. State the difference.

assistant: SELECT SUM(IIF(STRFTIME('%Y', date) = '2007', 1, 0)) - SUM(IIF(STRFTIME('%Y', date) = '2008', 1, 0)) FROM incidents WHERE subject_weapon = 'Vehicle'
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 actor (
  ActorID integer PRIMARY KEY,
  Name text,
  Date of Birth date,
  Birth City text,
  Birth Country text,
  Height (Inches) integer,
  Biography text,
  Gender text,
  Ethnicity text,
  NetWorth text
);
CREATE TABLE movie (
  MovieID integer PRIMARY KEY,
  Title text,
  MPAA Rating text,
  Budget integer,
  Gross integer,
  Release Date text,
  Genre text,
  Runtime integer,
  Rating real,
  Rating Count integer,
  Summary text
);
CREATE TABLE characters (
  MovieID integer PRIMARY KEY,
  ActorID integer PRIMARY KEY,
  Character Name text,
  creditOrder integer,
  pay text,
  screentime text
);
-- foreign keys: characters.MovieID -> movie.MovieID; characters.ActorID -> actor.ActorID

Hint: "Michael Moscovitz" refers to Character Name = 'Michael Moscovitz'

Question: Give the biography of the actor who played "Michael Moscovitz".

assistant: SELECT T2.Biography FROM characters AS T1 INNER JOIN actor AS T2 ON T1.ActorID = T2.ActorID WHERE T1.`Character Name` = 'Michael Moscovitz'
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,
  First text,
  Last text,
  StreetAddress text,
  City text,
  State text,
  ZipCode integer,
  Email text,
  PhoneNumber text,
  FirstPurchaseDate date,
  SubscribedToEmailList text,
  Gender text
);
CREATE TABLE geolocation (
  LocationID integer PRIMARY KEY,
  Latitude real,
  Longitude real
);
CREATE TABLE location (
  LocationID integer PRIMARY KEY,
  LocationName text,
  StreetAddress text,
  City text,
  State text,
  ZipCode integer
);
CREATE TABLE rootbeerbrand (
  BrandID integer PRIMARY KEY,
  BrandName text,
  FirstBrewedYear integer,
  BreweryName text,
  City text,
  State text,
  Country text,
  Description text,
  CaneSugar text,
  CornSyrup text,
  Honey text,
  ArtificialSweetener text,
  Caffeinated text,
  Alcoholic text,
  AvailableInCans text,
  AvailableInBottles text,
  AvailableInKegs text,
  Website text,
  FacebookPage text,
  Twitter text,
  WholesaleCost real,
  CurrentRetailPrice real
);
CREATE TABLE rootbeer (
  RootBeerID integer PRIMARY KEY,
  BrandID integer,
  ContainerType text,
  LocationID integer,
  PurchaseDate date
);
CREATE TABLE rootbeerreview (
  CustomerID integer PRIMARY KEY,
  BrandID integer PRIMARY KEY,
  StarRating integer,
  ReviewDate date,
  Review text
);
CREATE TABLE transaction (
  TransactionID integer PRIMARY KEY,
  CreditCardNumber integer,
  CustomerID integer,
  TransactionDate date,
  CreditCardType text,
  LocationID integer,
  RootBeerID integer,
  PurchasePrice real
);
-- foreign keys: geolocation.LocationID -> location.LocationID; location.LocationID -> geolocation.LocationID; rootbeer.BrandID -> rootbeerbrand.BrandID; rootbeer.LocationID -> location.LocationID; rootbeer.LocationID -> geolocation.LocationID; rootbeerreview.BrandID -> rootbeerbrand.BrandID; rootbeerreview.CustomerID -> customers.CustomerID; transaction.RootBeerID -> rootbeer.RootBeerID; transaction.LocationID -> location.LocationID; transaction.CustomerID -> customers.CustomerID

Hint: 5-star rating refers to StarRating = 5; in 2013 refers to ReviewDate LIKE '2013%'; unit profit available to wholesalers = SUBTRACT(CurrentRetailPrice, WholesaleCost);

Question: List down the brand names of root beer that gained a 5-star rating from a customer's review in 2013. Calculate the unit profit available to wholesalers for each brand.

assistant: SELECT T1.BrandName, T1.CurrentRetailPrice - T1.WholesaleCost AS result FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2013-01-01' AND '2013-12-31'
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 film_text (
  film_id integer PRIMARY KEY,
  title text,
  description text
);
CREATE TABLE actor (
  actor_id integer PRIMARY KEY,
  first_name text,
  last_name text,
  last_update datetime
);
CREATE TABLE address (
  address_id integer PRIMARY KEY,
  address text,
  address2 text,
  district text,
  city_id integer,
  postal_code text,
  phone text,
  last_update datetime
);
CREATE TABLE category (
  category_id integer PRIMARY KEY,
  name text,
  last_update datetime
);
CREATE TABLE city (
  city_id integer PRIMARY KEY,
  city text,
  country_id integer,
  last_update datetime
);
CREATE TABLE country (
  country_id integer PRIMARY KEY,
  country text,
  last_update datetime
);
CREATE TABLE customer (
  customer_id integer PRIMARY KEY,
  store_id integer,
  first_name text,
  last_name text,
  email text,
  address_id integer,
  active integer,
  create_date datetime,
  last_update datetime
);
CREATE TABLE film (
  film_id integer PRIMARY KEY,
  title text,
  description text,
  release_year text,
  language_id integer,
  original_language_id integer,
  rental_duration integer,
  rental_rate real,
  length integer,
  replacement_cost real,
  rating text,
  special_features text,
  last_update datetime
);
CREATE TABLE film_actor (
  actor_id integer PRIMARY KEY,
  film_id integer PRIMARY KEY,
  last_update datetime
);
CREATE TABLE film_category (
  film_id integer PRIMARY KEY,
  category_id integer PRIMARY KEY,
  last_update datetime
);
CREATE TABLE inventory (
  inventory_id integer PRIMARY KEY,
  film_id integer,
  store_id integer,
  last_update datetime
);
CREATE TABLE language (
  language_id integer PRIMARY KEY,
  name text,
  last_update datetime
);
CREATE TABLE payment (
  payment_id integer PRIMARY KEY,
  customer_id integer,
  staff_id integer,
  rental_id integer,
  amount real,
  payment_date datetime,
  last_update datetime
);
CREATE TABLE rental (
  rental_id integer PRIMARY KEY,
  rental_date datetime,
  inventory_id integer,
  customer_id integer,
  return_date datetime,
  staff_id integer,
  last_update datetime
);
CREATE TABLE staff (
  staff_id integer PRIMARY KEY,
  first_name text,
  last_name text,
  address_id integer,
  picture blob,
  email text,
  store_id integer,
  active integer,
  username text,
  password text,
  last_update datetime
);
CREATE TABLE store (
  store_id integer PRIMARY KEY,
  manager_staff_id integer,
  address_id integer,
  last_update datetime
);

Hint: full name refers to first_name, last_name; customer who rented the most film refers to Max(count(rental_id))

Question: Please give the full name of the customer that have rented the most films.

assistant: SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, COUNT(T2.rental_id) AS num FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ) 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:
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
);
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 keys: PlayerInfo.weight -> weight_info.weight_id; PlayerInfo.height -> height_info.height_id; SeasonStatus.ELITEID -> PlayerInfo.ELITEID

Hint: 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';

Question: How tall is the player from Yale University who picked up 28 penalty minutes in the 2005-2006 season?

assistant: 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
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 `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_name` VARCHAR(80),
`customer_details` VARCHAR(255)
);
CREATE TABLE `Invoices` (
`invoice_number` INTEGER PRIMARY KEY,
`invoice_date` DATETIME,
`invoice_details` VARCHAR(255)
);

CREATE TABLE `Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`order_status` VARCHAR(10) NOT NULL,
`date_order_placed` DATETIME NOT NULL,
`order_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`product_name` VARCHAR(80),
`product_details` VARCHAR(255)
);

CREATE TABLE `Order_Items` (
`order_item_id` INTEGER PRIMARY KEY,
`product_id` INTEGER NOT NULL,
`order_id` INTEGER NOT NULL,
`order_item_status` VARCHAR(10) NOT NULL,
`order_item_details` VARCHAR(255),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` ),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` )
);

CREATE TABLE `Shipments` (
`shipment_id` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`invoice_number` INTEGER NOT NULL,
`shipment_tracking_number` VARCHAR(80),
`shipment_date` DATETIME,
`other_shipment_details` VARCHAR(255),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` ),
FOREIGN KEY (`invoice_number` ) REFERENCES `Invoices`(`invoice_number` )
);

CREATE TABLE `Shipment_Items` (
`shipment_id` INTEGER NOT NULL,
`order_item_id` INTEGER NOT NULL,
FOREIGN KEY (`order_item_id` ) REFERENCES `Order_Items`(`order_item_id` ),
FOREIGN KEY (`shipment_id` ) REFERENCES `Shipments`(`shipment_id` )
);

Question: Give me a list of distinct product ids from orders placed between 1975-01-01 and 1976-01-01?

assistant: SELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= "1975-01-01" AND T1.date_order_placed <= "1976-01-01"
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 "mountain" (
"Mountain_ID" int,
"Name" text,
"Height" real,
"Prominence" real,
"Range" text,
"Country" text,
PRIMARY KEY ("Mountain_ID")
);

CREATE TABLE "climber" (
"Climber_ID" int,
"Name" text,
"Country" text,
"Time" text,
"Points" real,
"Mountain_ID" int,
PRIMARY KEY ("Climber_ID"),
FOREIGN KEY ("Mountain_ID") REFERENCES "mountain"("Mountain_ID")
);

Question: What are the names of mountains in ascending alphabetical order?

assistant: SELECT Name FROM mountain ORDER BY Name ASC
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:
--data definition

create table genre(
	g_name varchar2(20) not null,
	rating varchar2(10),
	most_popular_in varchar2(50),
	primary key(g_name)
);

create table artist(
	artist_name varchar2(50) not null,
	country varchar2(20),
	gender varchar2(20),
	preferred_genre varchar2(50),
	constraint a_name primary key(artist_name),
	foreign key(preferred_genre) references genre(g_name) ON DELETE CASCADE
);

create table files(
	f_id number(10) not null,
	artist_name varchar2(50),
	file_size varchar2(20),
	duration varchar2(20),
	formats varchar2(20),
	primary key(f_id),
	foreign key(artist_name) references artist(artist_name) ON DELETE CASCADE
);


create table song(
	song_name varchar2(50),
	artist_name varchar2(50),
	country varchar2(20),
	f_id number(10),
    	genre_is varchar2(20),
	rating number(10) check(rating>0 and rating<11),
	languages varchar2(20),
	releasedate Date, 
	resolution number(10) not null,
	constraint s_name primary key(song_name),
	foreign key(artist_name) references artist(artist_name) ON DELETE CASCADE,
	foreign key(f_id) references files(f_id) ON DELETE CASCADE,
	foreign key(genre_is) references genre(g_name) ON DELETE CASCADE
);


--insertion of attributes in the table

Question: What are the maximum duration and resolution of songs grouped and ordered by languages?

assistant: SELECT max(T1.duration) , max(T2.resolution) , T2.languages FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id GROUP BY T2.languages ORDER BY T2.languages
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 location (
  locationID integer PRIMARY KEY,
  locationcity text,
  address text,
  state text,
  zipcode integer,
  officephone text
);
CREATE TABLE position (
  positionID integer 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 keys: employee.positionID -> position.positionID; employee.locationID -> location.locationID

Hint: Sandy Adams is the fullname of an employee; full name = firstname, lastname;

Question: What is the office phone number of the location at which Sandy Adams works?

assistant: SELECT T2.officephone FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID WHERE T1.lastname = 'Adams' AND T1.firstname = 'Sandy'
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 chapters (
  id integer PRIMARY KEY,
  Act integer,
  Scene integer,
  Description text,
  work_id integer
);
CREATE TABLE characters (
  id integer PRIMARY KEY,
  CharName text,
  Abbrev text,
  Description text
);
CREATE TABLE paragraphs (
  id integer PRIMARY KEY,
  ParagraphNum integer,
  PlainText text,
  character_id integer,
  chapter_id integer
);
CREATE TABLE works (
  id integer PRIMARY KEY,
  Title text,
  LongTitle text,
  Date integer,
  GenreType text
);

Hint: Tragedy refers to GenreType = 'Tragedy'

Question: How many of the works of Shakespeare are Tragedy?

assistant: SELECT COUNT(id) FROM works WHERE GenreType = 'Tragedy'
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 "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
);

CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
);

Question: What are the names, locations, and years of opening for tracks with seating higher than average?

assistant: SELECT name , LOCATION , year_opened FROM track WHERE seating > (SELECT avg(seating) FROM track)
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 essays (
  projectid text,
  teacher_acctid text,
  title text,
  short_description text,
  need_statement text,
  essay text
);
CREATE TABLE projects (
  projectid text 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 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
);
CREATE TABLE resources (
  resourceid text 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 keys: donations.projectid -> projects.projectid; resources.projectid -> projects.projectid

Hint: urban area refers to school_metro = 'urban'; books resources refers to project_resource_type = 'Books'

Question: How many schools in urban area requested for books resources?

assistant: SELECT COUNT(T2.schoolid) FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T2.resource_type = 'Books' AND T2.school_metro = 'urban'