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 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: sold in 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014'; percentage = DIVIDE(MULTIPLY(SUM(BreweryName = 'AJ Stephans Beverages'), 1.0), COUNT(RootBeerID)) WHERE SUBSTR(TransactionDate, 1, 4) = '2014'; AJ Stephans Beverages refers to BreweryName = 'AJ Stephans Beverages';

Question: Among all the root beers sold in 2014, what is the percentage of the root beers produced by the brewery AJ Stephans Beverages?

assistant: SELECT CAST(COUNT(CASE WHEN T3.BreweryName = 'AJ Stephans Beverages' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2014%'
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_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
);
CREATE TABLE `Ref_Colors` (
`color_code` VARCHAR(15) PRIMARY KEY,
`color_description` VARCHAR(80)
);
CREATE TABLE `Ref_Product_Categories` (
`product_category_code` VARCHAR(15) PRIMARY KEY,
`product_category_description` VARCHAR(80),
`unit_of_measure` VARCHAR(20)
);

Question: What is the unit of measurement of product named "cumin"?

assistant: SELECT t2.unit_of_measure FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code = t2.product_category_code WHERE t1.product_name = "cumin"
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 Attributes (
  attribute_id integer PRIMARY KEY,
  attribute_name text
);
CREATE TABLE Categories (
  category_id integer PRIMARY KEY,
  category_name text
);
CREATE TABLE Compliments (
  compliment_id integer PRIMARY KEY,
  compliment_type text
);
CREATE TABLE Days (
  day_id integer PRIMARY KEY,
  day_of_week text
);
CREATE TABLE Years (
  year_id integer PRIMARY KEY,
  actual_year integer
);
CREATE TABLE Business_Attributes (
  attribute_id integer PRIMARY KEY,
  business_id integer PRIMARY KEY,
  attribute_value text
);
CREATE TABLE Business_Categories (
  business_id integer PRIMARY KEY,
  category_id integer PRIMARY KEY
);
CREATE TABLE Business_Hours (
  business_id integer PRIMARY KEY,
  day_id integer PRIMARY KEY,
  opening_time text,
  closing_time text
);
CREATE TABLE Checkins (
  business_id integer PRIMARY KEY,
  day_id integer PRIMARY KEY,
  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
);
CREATE TABLE Elite (
  user_id integer PRIMARY KEY,
  year_id integer PRIMARY KEY
);
CREATE TABLE Reviews (
  business_id integer PRIMARY KEY,
  user_id integer PRIMARY KEY,
  review_stars integer,
  review_votes_funny text,
  review_votes_useful text,
  review_votes_cool text,
  review_length text
);
CREATE TABLE Tips (
  business_id integer PRIMARY KEY,
  user_id integer PRIMARY KEY,
  likes integer,
  tip_length text
);
CREATE TABLE Users_Compliments (
  compliment_id integer PRIMARY KEY,
  user_id integer PRIMARY KEY,
  number_of_compliments text
);
CREATE TABLE Business (
  business_id integer PRIMARY KEY,
  active text,
  city text,
  state text,
  stars real,
  review_count text
);
CREATE TABLE Users (
  user_id integer 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
);

Hint: businesses that still open refers to active = 'true'; business received an uber rating on the funny vote refers to review_votes_funny = 'Uber'

Question: How many reviews of businesses that are still open received an uber rating on the funny vote?

assistant: SELECT COUNT(T1.business_id) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T2.review_votes_funny = 'Uber' AND T1.active = 'true'
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 Method (
  Id integer PRIMARY KEY,
  Name text,
  FullComment text,
  Summary text,
  ApiCalls text,
  CommentIsXml integer,
  SampledAt integer,
  SolutionId integer,
  Lang text,
  NameTokenized text
);
CREATE TABLE MethodParameter (
  Id integer PRIMARY KEY,
  MethodId text,
  Type text,
  Name text
);
CREATE TABLE Repo (
  Id integer PRIMARY KEY,
  Url text,
  Stars integer,
  Forks integer,
  Watchers integer,
  ProcessedTime integer
);
CREATE TABLE Solution (
  Id integer PRIMARY KEY,
  RepoId integer,
  Path text,
  ProcessedTime integer,
  WasCompiled integer
);

Hint: solution path refers to Path; method refers to Name; Name = 'Mosa.Platform.x86.Instructions.IMul.EmitLegacy';

Question: Show the solution path for the method "Mosa.Platform.x86.Instructions.IMul.EmitLegacy"?

assistant: SELECT T1.Path FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.Name = 'Mosa.Platform.x86.Instructions.IMul.EmitLegacy'
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_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);


CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);

Question: What is the name of the staff that is in charge of the attraction named "US museum"?

assistant: SELECT T1.Name FROM STAFF AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T2.Name = "US museum"
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;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "department" (
"Department_ID" int,
"Name" text,
"Creation" text,
"Ranking" int,
"Budget_in_Billions" real,
"Num_Employees" real,
PRIMARY KEY ("Department_ID")
);

Question: List the name, born state and age of the heads of departments ordered by age.

assistant: SELECT name , born_state , age FROM head ORDER BY age
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 all_star (
    player_id TEXT,
    year INTEGER,
    game_num INTEGER,
    game_id TEXT,
    team_id TEXT,
    league_id TEXT,
    gp NUMERIC,
    starting_pos NUMERIC,
    foreign key (player_id) references player(player_id)
);

Question: How many times did Boston Red Stockings lose in 2009 postseason?

assistant: SELECT count(*) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_loser = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 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:
CREATE TABLE Person (
  name varchar(20) PRIMARY KEY,
  age INTEGER,
  city TEXT,
  gender TEXT,
  job TEXT
);

CREATE TABLE PersonFriend (
  name varchar(20),
  friend varchar(20),
  year INTEGER,
  FOREIGN KEY (name) REFERENCES Person(name),
  FOREIGN KEY (friend) REFERENCES Person(name)
);

Question: What are the names of everybody who has exactly one friend?

assistant: SELECT name FROM PersonFriend GROUP BY name 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:
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: It's Winter' is movie_title;

Question: Please list the id of the director of the movie "It's Winter".

assistant: SELECT director_id FROM movies WHERE movie_title = 'It''s Winter'
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 ATT_CLASSES (
  ATT_CLASS_ID integer PRIMARY KEY,
  ATT_CLASS text
);
CREATE TABLE OBJ_CLASSES (
  OBJ_CLASS_ID integer PRIMARY KEY,
  OBJ_CLASS text
);
CREATE TABLE IMG_OBJ (
  IMG_ID integer PRIMARY KEY,
  OBJ_SAMPLE_ID integer PRIMARY KEY,
  OBJ_CLASS_ID integer,
  X integer,
  Y integer,
  W integer,
  H integer
);
CREATE TABLE IMG_OBJ_ATT (
  IMG_ID integer PRIMARY KEY,
  ATT_CLASS_ID integer PRIMARY KEY,
  OBJ_SAMPLE_ID integer PRIMARY KEY
);
CREATE TABLE PRED_CLASSES (
  PRED_CLASS_ID integer PRIMARY KEY,
  PRED_CLASS text
);
CREATE TABLE IMG_REL (
  IMG_ID integer PRIMARY KEY,
  PRED_CLASS_ID integer PRIMARY KEY,
  OBJ1_SAMPLE_ID integer PRIMARY KEY,
  OBJ2_SAMPLE_ID integer PRIMARY KEY
);
-- foreign keys: IMG_OBJ.OBJ_CLASS_ID -> OBJ_CLASSES.OBJ_CLASS_ID; IMG_OBJ_ATT.IMG_ID -> IMG_OBJ.IMG_ID; IMG_OBJ_ATT.OBJ_SAMPLE_ID -> IMG_OBJ.OBJ_SAMPLE_ID; IMG_OBJ_ATT.ATT_CLASS_ID -> ATT_CLASSES.ATT_CLASS_ID; IMG_REL.IMG_ID -> IMG_OBJ.IMG_ID; IMG_REL.OBJ2_SAMPLE_ID -> IMG_OBJ.OBJ_SAMPLE_ID; IMG_REL.IMG_ID -> IMG_OBJ.IMG_ID; IMG_REL.OBJ1_SAMPLE_ID -> IMG_OBJ.OBJ_SAMPLE_ID; IMG_REL.PRED_CLASS_ID -> PRED_CLASSES.PRED_CLASS_ID

Hint: objects that have multiple relations refers to OBJ1_SAMPLE_ID ! = OBJ2_SAMPLE_ID; captions for the prediction class ids are "on" refers to PRED_CLASS = 'on'

Question: Among the objects that have multiple relations, how many images whose captions for the prediction class ids are "on"?

assistant: SELECT COUNT(T2.PRED_CLASS_ID) FROM IMG_REL AS T1 INNER JOIN PRED_CLASSES AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T1.OBJ1_SAMPLE_ID != T1.OBJ2_SAMPLE_ID AND T2.PRED_CLASS = 'on'
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 characters (
  movie_title text PRIMARY KEY,
  release_date text,
  hero text,
  villian text,
  song text
);
CREATE TABLE director (
  name text PRIMARY KEY,
  director text
);
CREATE TABLE movies_total_gross (
  movie_title text PRIMARY KEY,
  release_date text PRIMARY KEY,
  genre text,
  MPAA_rating text,
  total_gross text,
  inflation_adjusted_gross text
);
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 voice-actors (
  character text PRIMARY KEY,
  voice-actor text,
  movie text
);
-- foreign keys: characters.hero -> voice-actors.character; director.name -> characters.movie_title; movies_total_gross.movie_title -> characters.movie_title; voice-actors.movie -> characters.movie_title

Hint: FALSE;

Question: Who is the hero character of the movie whose total gross was $222,527,828?

assistant: SELECT T1.hero FROM characters AS T1 INNER JOIN movies_total_gross AS T2 ON T2.movie_title = T1.movie_title WHERE T2.total_gross = '$222,527,828'
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 Faculty (
       FacID 	       INTEGER PRIMARY KEY,
       Lname		VARCHAR(15),
       Fname		VARCHAR(15),
       Rank		VARCHAR(15),
       Sex		VARCHAR(1),
       Phone		INTEGER,
       Room		VARCHAR(5),
       Building		VARCHAR(13)
);

create table Department (
       DNO   		INTEGER PRIMARY KEY,
       Division		VARCHAR(2),
       DName		VARCHAR(25),
       Room		VARCHAR(5),
       Building		VARCHAR(13),
       DPhone		INTEGER
);

create table Member_of (
       FacID 	       INTEGER,
       DNO	       INTEGER,
       Appt_Type       VARCHAR(15),
       FOREIGN KEY(FacID) REFERENCES Faculty(FacID),
       FOREIGN KEY(DNO) REFERENCES Department(DNO)
);

create table Course (
       CID   	    	VARCHAR(7) PRIMARY KEY,
       CName		VARCHAR(40),
       Credits		INTEGER,
       Instructor	INTEGER,
       Days		VARCHAR(5),
       Hours		VARCHAR(11),
       DNO		INTEGER,
       FOREIGN KEY(Instructor) REFERENCES Faculty(FacID),
       FOREIGN KEY(DNO) REFERENCES Department(DNO)
);

create table Minor_in (
       StuID 	      INTEGER,
       DNO		INTEGER,
       FOREIGN KEY(StuID) REFERENCES Student(StuID),
       FOREIGN KEY(DNO) REFERENCES Department(DNO)
);

create table Enrolled_in (
       StuID 		 INTEGER,
       CID		VARCHAR(7),
       Grade		VARCHAR(2),
       FOREIGN KEY(StuID) REFERENCES Student(StuID),
       FOREIGN KEY(CID) REFERENCES Course(CID),
       FOREIGN KEY(Grade) REFERENCES Gradeconversion(lettergrade)
);

create table Gradeconversion (
       lettergrade	     VARCHAR(2) PRIMARY KEY,
       gradepoint	     FLOAT
);

Question: Find the name of the department that has the fewest members.

assistant: SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MEMBER_OF AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY count(*) 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 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: "O my poor brother! and so perchance may he be." refers to  PlainText = 'O my poor brother! and so perchance may he be.'

Question: Give the character's ID of the character that said the paragraph "O my poor brother! and so perchance may he be."

assistant: SELECT character_id FROM paragraphs WHERE PlainText = 'O my poor brother! and so perchance may he be.'
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: longest movie title refers to MAX(LENGTH(movie_title)); when it was released refers to movie_release_year;

Question: What is the name of the longest movie title? When was it released?

assistant: SELECT movie_title, movie_release_year FROM movies ORDER BY LENGTH(movie_popularity) 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 ATT_CLASSES (
  ATT_CLASS_ID integer PRIMARY KEY,
  ATT_CLASS text
);
CREATE TABLE OBJ_CLASSES (
  OBJ_CLASS_ID integer PRIMARY KEY,
  OBJ_CLASS text
);
CREATE TABLE IMG_OBJ (
  IMG_ID integer PRIMARY KEY,
  OBJ_SAMPLE_ID integer PRIMARY KEY,
  OBJ_CLASS_ID integer,
  X integer,
  Y integer,
  W integer,
  H integer
);
CREATE TABLE IMG_OBJ_ATT (
  IMG_ID integer PRIMARY KEY,
  ATT_CLASS_ID integer PRIMARY KEY,
  OBJ_SAMPLE_ID integer PRIMARY KEY
);
CREATE TABLE PRED_CLASSES (
  PRED_CLASS_ID integer PRIMARY KEY,
  PRED_CLASS text
);
CREATE TABLE IMG_REL (
  IMG_ID integer PRIMARY KEY,
  PRED_CLASS_ID integer PRIMARY KEY,
  OBJ1_SAMPLE_ID integer PRIMARY KEY,
  OBJ2_SAMPLE_ID integer PRIMARY KEY
);
-- foreign keys: IMG_OBJ.OBJ_CLASS_ID -> OBJ_CLASSES.OBJ_CLASS_ID; IMG_OBJ_ATT.IMG_ID -> IMG_OBJ.IMG_ID; IMG_OBJ_ATT.OBJ_SAMPLE_ID -> IMG_OBJ.OBJ_SAMPLE_ID; IMG_OBJ_ATT.ATT_CLASS_ID -> ATT_CLASSES.ATT_CLASS_ID; IMG_REL.IMG_ID -> IMG_OBJ.IMG_ID; IMG_REL.OBJ2_SAMPLE_ID -> IMG_OBJ.OBJ_SAMPLE_ID; IMG_REL.IMG_ID -> IMG_OBJ.IMG_ID; IMG_REL.OBJ1_SAMPLE_ID -> IMG_OBJ.OBJ_SAMPLE_ID; IMG_REL.PRED_CLASS_ID -> PRED_CLASSES.PRED_CLASS_ID

Hint: ID of all images refer to IMG_ID; if two objects (OBJ1_SAMPLE_ID,
OBJ2_SAMPLE_ID) has
multiple PRED_CLASS_ID, it
means these two objects
have multiple relations;

Question: List the ID of all images with objects that have multiple relations.

assistant: SELECT IMG_ID FROM IMG_REL GROUP BY PRED_CLASS_ID HAVING COUNT(DISTINCT OBJ1_SAMPLE_ID) != 0 AND COUNT(DISTINCT OBJ2_SAMPLE_ID) != 0