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 Categories (
  CategoryID integer PRIMARY KEY,
  CategoryName text,
  Description text
);
CREATE TABLE Customers (
  CustomerID integer PRIMARY KEY,
  CustomerName text,
  ContactName text,
  Address text,
  City text,
  PostalCode text,
  Country text
);
CREATE TABLE Employees (
  EmployeeID integer PRIMARY KEY,
  LastName text,
  FirstName text,
  BirthDate date,
  Photo text,
  Notes text
);
CREATE TABLE Shippers (
  ShipperID integer PRIMARY KEY,
  ShipperName text,
  Phone text
);
CREATE TABLE Suppliers (
  SupplierID integer PRIMARY KEY,
  SupplierName text,
  ContactName text,
  Address text,
  City text,
  PostalCode text,
  Country text,
  Phone text
);
CREATE TABLE Products (
  ProductID integer PRIMARY KEY,
  ProductName text,
  SupplierID integer,
  CategoryID integer,
  Unit text,
  Price real
);
CREATE TABLE Orders (
  OrderID integer PRIMARY KEY,
  CustomerID integer,
  EmployeeID integer,
  OrderDate datetime,
  ShipperID integer
);
CREATE TABLE OrderDetails (
  OrderDetailID integer PRIMARY KEY,
  OrderID integer,
  ProductID integer,
  Quantity integer
);
-- foreign keys: Products.SupplierID -> Suppliers.SupplierID; Products.CategoryID -> Categories.CategoryID; Orders.ShipperID -> Shippers.ShipperID; Orders.CustomerID -> Customers.CustomerID; Orders.EmployeeID -> Employees.EmployeeID; OrderDetails.ProductID -> Products.ProductID; OrderDetails.OrderID -> Orders.OrderID

Hint: the largest quantity of "Manjimup Dried Apples" refers to MAX(Quantity) where ProductName = 'Manjimup Dried Apples';

Question: What is the largest quantity of "Manjimup Dried Apples" for an order?

assistant: SELECT T2.Quantity FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T2.ProductID = T1.ProductID WHERE T1.ProductName = 'Manjimup Dried Apples' ORDER BY T2.Quantity 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 Customers (
Customer_ID INTEGER NOT NULL,
Customer_Details VARCHAR(255) NOT NULL,
PRIMARY KEY (Customer_ID)
);

Question: Which claims had exactly one settlement? For each, tell me the the date the claim was made, the date it was settled and the amount settled.

assistant: SELECT T1.claim_id , T1.date_claim_made , T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id GROUP BY T1.claim_id HAVING count(*) = 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 Ref_Payment_Methods (
payment_method_code CHAR(10) NOT NULL,
payment_method_description VARCHAR(80),
PRIMARY KEY (payment_method_code),
UNIQUE (payment_method_code)
);

Question: List the email addresses of the drama workshop groups located in Alaska state.

assistant: SELECT T2.Store_Email_Address FROM Addresses AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Address_ID = T2.Address_ID WHERE T1.State_County = "Alaska"
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 playstore (
  App text,
  Category text,
  Rating real,
  Reviews integer,
  Size text,
  Installs text,
  Type text,
  Price text,
  Content Rating text,
  Genres text
);
CREATE TABLE user_reviews (
  App text,
  Translated_Review text,
  Sentiment text,
  Sentiment_Polarity text,
  Sentiment_Subjectivity text
);
-- foreign keys: user_reviews.App -> playstore.App

Hint: Dragon Ball Legends is the app; users who dislikes the app refers to Sentiment_Polarity<-0.5;

Question: What is the rating of Dragon Ball Legends and how many users dislike this App?

assistant: SELECT T1.Rating, COUNT(T2.Sentiment_Polarity) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Dragon Ball Legends' AND CAST(Sentiment_Polarity AS INTEGER) < -0.5
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 langs (
  lid integer PRIMARY KEY,
  lang text,
  locale text,
  pages integer,
  words integer
);
CREATE TABLE pages (
  pid integer PRIMARY KEY,
  lid integer,
  page integer,
  revision integer,
  title text,
  words integer
);
CREATE TABLE words (
  wid integer PRIMARY KEY,
  word text,
  occurrences integer
);
CREATE TABLE langs_words (
  lid integer PRIMARY KEY,
  wid integer PRIMARY KEY,
  occurrences integer
);
CREATE TABLE pages_words (
  pid integer PRIMARY KEY,
  wid integer PRIMARY KEY,
  occurrences integer
);
CREATE TABLE biwords (
  lid integer PRIMARY KEY,
  w1st integer PRIMARY KEY,
  w2nd integer PRIMARY KEY,
  occurrences integer
);
-- foreign keys: pages.lid -> langs.lid; langs_words.wid -> words.wid; langs_words.lid -> langs.lid; pages_words.wid -> words.wid; pages_words.pid -> pages.pid; biwords.w2nd -> words.wid; biwords.w1st -> words.wid; biwords.lid -> langs.lid

Hint: lid = 1 means it's Catalan language; over 4000 different words means words > 4000; Wikipedia pages refers to pid

Question: How many Wikipedia pages with over 4000 different words are there on the Catalan language?

assistant: SELECT COUNT(lid) FROM pages WHERE lid = 1 AND words > 4000
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 "airport" (
"id" int,
"City" text,
"Country" text,
"IATA" text,
"ICAO" text,
"name" text,
primary key("id")
);


CREATE TABLE "operate_company" (
"id" int,
"name" text,
"Type" text,
"Principal_activities" text,
"Incorporated_in" text,
"Group_Equity_Shareholding" real,
primary key ("id")
);

CREATE TABLE "flight" (
"id" int,
"Vehicle_Flight_number" text,
"Date" text,
"Pilot" text,
"Velocity" real,
"Altitude" real,
"airport_id" int,
"company_id" int,
primary key ("id"),
foreign key ("airport_id") references `airport`("id"),
foreign key ("company_id") references `operate_company`("id")
);

Question: What is the velocity of the pilot named 'Thompson'?

assistant: SELECT avg(velocity) FROM flight WHERE pilot = 'Thompson'
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 `Products` (
`product_id` INTEGER PRIMARY KEY,
`product_name` VARCHAR(20),
`product_price` DECIMAL(19,4),
`product_description` VARCHAR(255)
);

Question: Find the number of customers in total.

assistant: SELECT count(*) FROM customers
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 genre (
  id integer PRIMARY KEY,
  genre_name text
);
CREATE TABLE game (
  id integer PRIMARY KEY,
  genre_id integer,
  game_name text
);
CREATE TABLE platform (
  id integer PRIMARY KEY,
  platform_name text
);
CREATE TABLE publisher (
  id integer PRIMARY KEY,
  publisher_name text
);
CREATE TABLE game_publisher (
  id integer PRIMARY KEY,
  game_id integer,
  publisher_id integer
);
CREATE TABLE game_platform (
  id integer PRIMARY KEY,
  game_publisher_id integer,
  platform_id integer,
  release_year integer
);
CREATE TABLE region (
  id integer PRIMARY KEY,
  region_name text
);
CREATE TABLE region_sales (
  region_id integer,
  game_platform_id integer,
  num_sales real
);
-- foreign keys: game.genre_id -> genre.id; game_publisher.publisher_id -> publisher.id; game_publisher.game_id -> game.id; game_platform.platform_id -> platform.id; game_platform.game_publisher_id -> game_publisher.id; region_sales.region_id -> region.id; region_sales.game_platform_id -> game_platform.id

Hint: year refers to release_year; the most number of releases refers to max(count(game_id))

Question: Which year has the most number of PC games releases?

assistant: SELECT T.release_year FROM ( SELECT T2.release_year, COUNT(DISTINCT T3.game_id) FROM platform AS T1 INNER JOIN game_platform AS T2 ON T1.id = T2.platform_id INNER JOIN game_publisher AS T3 ON T2.game_publisher_id = T3.id WHERE T1.platform_name = 'PC' GROUP BY T2.release_year ORDER BY COUNT(DISTINCT T3.game_id) DESC LIMIT 1 ) t
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 lists (
  user_id integer,
  list_id integer 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 movies (
  movie_id integer 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 ratings_users (
  user_id integer,
  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 PRIMARY KEY,
  list_id integer PRIMARY KEY,
  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
);
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 keys: lists.user_id -> lists_users.user_id; ratings_users.user_id -> lists_users.user_id; lists_users.user_id -> lists.user_id; lists_users.list_id -> lists.list_id; ratings.user_id -> ratings_users.user_id; ratings.user_id -> lists_users.user_id; ratings.movie_id -> movies.movie_id

Hint: the list "Vladimir Vladimirovich Nabokov" refers to list_title = 'Vladimir Vladimirovich Nabokov'; portrait picture refers to user_avatar_image_url

Question: Show the portrait picture of the user who created the list "Vladimir Vladimirovich Nabokov".

assistant: SELECT T1.user_avatar_image_url FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_title LIKE 'Vladimir Vladimirovich Nabokov'
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 NOT NULL,
Customer_Details VARCHAR(255) NOT NULL,
PRIMARY KEY (Customer_ID)
);

Question: List the date the claim was made, the date it was settled and the amount settled for all the claims which had exactly one settlement.

assistant: SELECT T1.claim_id , T1.date_claim_made , T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id GROUP BY T1.claim_id HAVING count(*) = 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=OFF;
BEGIN TRANSACTION;
CREATE TABLE station (
    id INTEGER PRIMARY KEY,
    name TEXT,
    lat NUMERIC,
    long NUMERIC,
    dock_count INTEGER,
    city TEXT,
    installation_date TEXT);

Question: For each station, find its latitude and the minimum duration of trips that ended at the station.

assistant: SELECT T1.name , T1.lat , min(T2.duration) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.end_station_id GROUP BY T2.end_station_id
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 Classification (
  GeneID text PRIMARY KEY,
  Localization text
);
CREATE TABLE Genes (
  GeneID text,
  Essential text,
  Class text,
  Complex text,
  Phenotype text,
  Motif text,
  Chromosome integer,
  Function text,
  Localization text
);
CREATE TABLE Interactions (
  GeneID1 text PRIMARY KEY,
  GeneID2 text PRIMARY KEY,
  Type text,
  Expression_Corr real
);
-- foreign keys: Genes.GeneID -> Classification.GeneID; Interactions.GeneID2 -> Classification.GeneID; Interactions.GeneID1 -> Classification.GeneID

Question: For the pairs of genes with one having 8 chromosomes and the other having 6 chromosomes, what is the highest expression correlation score?

assistant: SELECT T2.Expression_Corr FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Chromosome = 6 OR T1.Chromosome = 8 ORDER BY T2.Expression_Corr 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 Author (
  Id integer PRIMARY KEY,
  Name text,
  Affiliation text
);
CREATE TABLE Conference (
  Id integer PRIMARY KEY,
  ShortName text,
  FullName text,
  HomePage text
);
CREATE TABLE Journal (
  Id integer 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
);
CREATE TABLE PaperAuthor (
  PaperId integer,
  AuthorId integer,
  Name text,
  Affiliation text
);
-- foreign keys: Paper.JournalId -> Journal.Id; Paper.ConferenceId -> Conference.Id; PaperAuthor.AuthorId -> Author.Id; PaperAuthor.PaperId -> Paper.Id

Hint: "Peter" is the name of author

Question: List down the author ID of authors with a name of "Peter".

assistant: SELECT AuthorId FROM PaperAuthor WHERE Name = 'Peter'
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 "storm" (
"Storm_ID" int,
"Name" text,
"Dates_active" text,
"Max_speed" int,
"Damage_millions_USD" real,
"Number_Deaths" int,
PRIMARY KEY ("Storm_ID")
);

Question: What are the names and damage in millions for storms, ordered by their max speeds descending?

assistant: SELECT name , damage_millions_USD FROM storm ORDER BY max_speed DESC
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 "captain" (
"Captain_ID" int,
"Name" text,
"Ship_ID" int,
"age" text,
"Class" text,
"Rank" text,
PRIMARY KEY ("Captain_ID"),
FOREIGN KEY ("Ship_ID") REFERENCES "Ship"("Ship_ID")
);

CREATE TABLE "Ship" (
"Ship_ID" int,
"Name" text,
"Type" text,
"Built_Year" real,
"Class" text,
"Flag" text,
PRIMARY KEY ("Ship_ID")
);

Question: Return the name of the youngest captain.

assistant: SELECT name FROM captain ORDER BY age 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 "list" ( 
	"LastName" TEXT, 
	"FirstName" TEXT, 
	"Grade" INTEGER, 
	"Classroom" INTEGER,
	PRIMARY KEY(LastName, FirstName)
);
CREATE TABLE "teachers" ( 
	"LastName" TEXT, 
	"FirstName" TEXT, 
	"Classroom" INTEGER,
	PRIMARY KEY(LastName, FirstName)
);

Question: For each classroom, show the classroom number and find how many students are using it.

assistant: SELECT classroom , count(*) FROM list GROUP BY classroom
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 `Attribute_Definitions` (
`attribute_id` INTEGER PRIMARY KEY,
`attribute_name` VARCHAR(30),
`attribute_data_type` VARCHAR(10)
);

Question: What are the attribute data types with more than 3 attribute definitions?

assistant: SELECT attribute_data_type FROM Attribute_Definitions GROUP BY attribute_data_type HAVING count(*) > 3
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 Student (
        StuID        INTEGER PRIMARY KEY,
        LName        VARCHAR(12),
        Fname        VARCHAR(12),
        Age      INTEGER,
        Sex      VARCHAR(1),
        Major        INTEGER,
        Advisor      INTEGER,
        city_code    VARCHAR(3)
 );

create table Video_Games (
       GameID           INTEGER PRIMARY KEY,
       GName            VARCHAR(40),
       GType            VARCHAR(40)
);

create table Plays_Games (
       StuID                INTEGER,
       GameID            INTEGER,
       Hours_Played      INTEGER,
       FOREIGN KEY(GameID) REFERENCES Video_Games(GameID),
       FOREIGN KEY(StuID) REFERENCES Student(StuID)
);

create table SportsInfo (
  StuID INTEGER,
  SportName VARCHAR(32),
  HoursPerWeek INTEGER,
  GamesPlayed INTEGER,
  OnScholarship VARCHAR(1),
  FOREIGN KEY(StuID) REFERENCES Student(StuID)
);

Question: Show ids of students who don't play video game.

assistant: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games
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 Episode (
  episode_id text 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 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
);
CREATE TABLE Character_Award (
  award_id integer,
  character text
);
CREATE TABLE Credit (
  episode_id text,
  category text,
  person text,
  role text,
  credited text
);
CREATE TABLE Keyword (
  episode_id text PRIMARY KEY,
  keyword text PRIMARY KEY
);
CREATE TABLE Vote (
  episode_id text,
  stars integer,
  votes integer,
  percent real
);
-- foreign keys: Award.episode_id -> Episode.episode_id; Award.person -> Person.name; Character_Award.award_id -> Award.award_id; Credit.person -> Person.name; Credit.episode_id -> Episode.episode_id; Keyword.episode_id -> Episode.episode_id; Vote.episode_id -> Episode.episode_id

Hint: won the award refers to result = 'Winner'; in 2009 refers to year = 2009

Question: List the award name and persons who won the award in 2009.

assistant: SELECT award, person FROM Award WHERE result = 'Winner' AND SUBSTR(year, 1, 4) = '2009';
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:
-- dbext:type=SQLITE:dbname=movie_rating.db

/* Delete the tables if they already exist */
drop table if exists Movie;
drop table if exists Reviewer;
drop table if exists Rating;

/* Create the schema for our tables */
create table Movie(
	mID int primary key, 
	title text, 
	year int, 
	director text
);
create table Reviewer(
	rID int primary key, 
	name text);

create table Rating(
	rID int, 
	mID int, 
	stars int, 
	ratingDate date,
	FOREIGN KEY (mID) references Movie(mID),
	FOREIGN KEY (rID) references Reviewer(rID)
);

/* Populate the tables with our data */

Question: What are the names of movies that get 3 star and 4 star?

assistant: SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 3 INTERSECT SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 4
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 Student (
        StuID        INTEGER PRIMARY KEY,
        LName        VARCHAR(12),
        Fname        VARCHAR(12),
        Age      INTEGER,
        Sex      VARCHAR(1),
        Major        INTEGER,
        Advisor      INTEGER,
        city_code    VARCHAR(3)
 );
 

create table Dorm (
       dormid		INTEGER,
       dorm_name	VARCHAR(20),
       student_capacity	INTEGER,
       gender			VARCHAR(1)
) ;

create table Dorm_amenity (
       amenid			INTEGER,
       amenity_name		VARCHAR(25)
) ;

create table Has_amenity (
       dormid			INTEGER,
       amenid				INTEGER,
	FOREIGN KEY (dormid) REFERENCES `Dorm`(dormid),
	FOREIGN KEY (amenid) REFERENCES `Dorm_amenity`(amenid)
);

create table Lives_in (
       stuid 	      INTEGER,
       dormid		INTEGER,
       room_number	INTEGER,
	FOREIGN KEY (stuid) REFERENCES `Student`(StuID),
        FOREIGN KEY (dormid) REFERENCES `Dorm`(dormid)
);

Question: Find the name of dorms which have both TV Lounge and Study Room as amenities.

assistant: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'