{"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store\n\nCREATE TABLE Manufacturers (\n Code INTEGER,\n Name VARCHAR(255) NOT NULL,\n Headquarter VARCHAR(255) NOT NULL,\n Founder VARCHAR(255) NOT NULL,\n Revenue REAL,\n PRIMARY KEY (Code) \n);\n\nCREATE TABLE Products (\n Code INTEGER,\n Name VARCHAR(255) NOT NULL ,\n Price DECIMAL NOT NULL ,\n Manufacturer INTEGER NOT NULL,\n PRIMARY KEY (Code), \n FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code)\n);\n\nQuestion: What are the names and revenues of the companies with the highest revenues in each headquarter city?"}, {"role": "assistant", "content": "SELECT name , max(revenue) , Headquarter FROM manufacturers GROUP BY Headquarter"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Roles` (\n`role_code` VARCHAR(15) PRIMARY KEY,\n`role_description` VARCHAR(80)\n);\n\nCREATE TABLE `Users` (\n`user_id` INTEGER PRIMARY KEY,\n`role_code` VARCHAR(15) NOT NULL,\n`user_name` VARCHAR(40),\n`user_login` VARCHAR(40),\n`password` VARCHAR(40),\nFOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )\n);\n\nQuestion: What are all the section titles of the document named \"David CV\"?"}, {"role": "assistant", "content": "SELECT t2.section_title FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code WHERE t1.document_name = \"David CV\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nHint: \"English\" is the name of language\n\nQuestion: How many films are in English?"}, {"role": "assistant", "content": "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'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE geographic (\n city text PRIMARY KEY,\n county text,\n region text\n);\nCREATE TABLE generalinfo (\n id_restaurant integer PRIMARY KEY,\n label text,\n food_type text,\n city text,\n review real\n);\nCREATE TABLE location (\n id_restaurant integer PRIMARY KEY,\n street_num integer,\n street_name text,\n city text\n);\n-- foreign keys: generalinfo.city -> geographic.city; location.id_restaurant -> generalinfo.id_restaurant; location.city -> geographic.city\n\nHint: Ocean St. refers to street_name = 'ocean st'; Santa Cruz refers to city = 'santa cruz'\n\nQuestion: Give the review of the restaurant located in Ocean St., Santa Cruz."}, {"role": "assistant", "content": "SELECT T2.review FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.city = 'santa cruz' AND T1.street_name = 'ocean st'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE langs (\n lid integer PRIMARY KEY,\n lang text,\n locale text,\n pages integer,\n words integer\n);\nCREATE TABLE pages (\n pid integer PRIMARY KEY,\n lid integer,\n page integer,\n revision integer,\n title text,\n words integer\n);\nCREATE TABLE words (\n wid integer PRIMARY KEY,\n word text,\n occurrences integer\n);\nCREATE TABLE langs_words (\n lid integer PRIMARY KEY,\n wid integer PRIMARY KEY,\n occurrences integer\n);\nCREATE TABLE pages_words (\n pid integer PRIMARY KEY,\n wid integer PRIMARY KEY,\n occurrences integer\n);\nCREATE TABLE biwords (\n lid integer PRIMARY KEY,\n w1st integer PRIMARY KEY,\n w2nd integer PRIMARY KEY,\n occurrences integer\n);\n-- 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\n\nHint: word id from 1 to 10 refers to wid BETWEEN 1 AND 10\n\nQuestion: List down the words with word id from 1 to 10 and write down a paired word for each of them."}, {"role": "assistant", "content": "SELECT T1.word AS W1, T3.word AS W2 FROM words AS T1 LEFT JOIN biwords AS T2 ON T1.wid = T2.w1st LEFT JOIN words AS T3 ON T3.wid = T2.w2nd WHERE T1.wid <= 10 GROUP BY T1.wid"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE customer (\n c_custkey integer PRIMARY KEY,\n c_mktsegment text,\n c_nationkey integer,\n c_name text,\n c_address text,\n c_phone text,\n c_acctbal real,\n c_comment text\n);\nCREATE TABLE lineitem (\n l_shipdate date,\n l_orderkey integer PRIMARY KEY,\n l_discount real,\n l_extendedprice real,\n l_suppkey integer,\n l_quantity integer,\n l_returnflag text,\n l_partkey integer,\n l_linestatus text,\n l_tax real,\n l_commitdate date,\n l_receiptdate date,\n l_shipmode text,\n l_linenumber integer PRIMARY KEY,\n l_shipinstruct text,\n l_comment text\n);\nCREATE TABLE nation (\n n_nationkey integer PRIMARY KEY,\n n_name text,\n n_regionkey integer,\n n_comment text\n);\nCREATE TABLE orders (\n o_orderdate date,\n o_orderkey integer PRIMARY KEY,\n o_custkey integer,\n o_orderpriority text,\n o_shippriority integer,\n o_clerk text,\n o_orderstatus text,\n o_totalprice real,\n o_comment text\n);\nCREATE TABLE part (\n p_partkey integer PRIMARY KEY,\n p_type text,\n p_size integer,\n p_brand text,\n p_name text,\n p_container text,\n p_mfgr text,\n p_retailprice real,\n p_comment text\n);\nCREATE TABLE partsupp (\n ps_partkey integer PRIMARY KEY,\n ps_suppkey integer PRIMARY KEY,\n ps_supplycost real,\n ps_availqty integer,\n ps_comment text\n);\nCREATE TABLE region (\n r_regionkey integer PRIMARY KEY,\n r_name text,\n r_comment text\n);\nCREATE TABLE supplier (\n s_suppkey integer PRIMARY KEY,\n s_nationkey integer,\n s_comment text,\n s_name text,\n s_address text,\n s_phone text,\n s_acctbal real\n);\n-- foreign keys: customer.c_nationkey -> nation.n_nationkey; lineitem.l_partkey -> partsupp.ps_partkey; lineitem.l_suppkey -> partsupp.ps_suppkey; lineitem.l_orderkey -> orders.o_orderkey; nation.n_regionkey -> region.r_regionkey; orders.o_custkey -> customer.c_custkey; partsupp.ps_suppkey -> supplier.s_suppkey; partsupp.ps_partkey -> part.p_partkey; supplier.s_nationkey -> nation.n_nationkey\n\nHint: orders with a total price between 200000 and 300000 refer to o_totalprice between 200000 and 300000;\n\nQuestion: List the order key of the orders with a total price between 200000 and 300000."}, {"role": "assistant", "content": "SELECT o_orderkey FROM orders WHERE o_totalprice BETWEEN 200000 AND 300000"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Country (\n CountryCode text PRIMARY KEY,\n ShortName text,\n TableName text,\n LongName text,\n Alpha2Code text,\n CurrencyUnit text,\n SpecialNotes text,\n Region text,\n IncomeGroup text,\n Wb2Code text,\n NationalAccountsBaseYear text,\n NationalAccountsReferenceYear text,\n SnaPriceValuation text,\n LendingCategory text,\n OtherGroups text,\n SystemOfNationalAccounts text,\n AlternativeConversionFactor text,\n PppSurveyYear text,\n BalanceOfPaymentsManualInUse text,\n ExternalDebtReportingStatus text,\n SystemOfTrade text,\n GovernmentAccountingConcept text,\n ImfDataDisseminationStandard text,\n LatestPopulationCensus text,\n LatestHouseholdSurvey text,\n SourceOfMostRecentIncomeAndExpenditureData text,\n VitalRegistrationComplete text,\n LatestAgriculturalCensus text,\n LatestIndustrialData integer,\n LatestTradeData integer,\n LatestWaterWithdrawalData integer\n);\nCREATE TABLE Series (\n SeriesCode text PRIMARY KEY,\n Topic text,\n IndicatorName text,\n ShortDefinition text,\n LongDefinition text,\n UnitOfMeasure text,\n Periodicity text,\n BasePeriod text,\n OtherNotes integer,\n AggregationMethod text,\n LimitationsAndExceptions text,\n NotesFromOriginalSource text,\n GeneralComments text,\n Source text,\n StatisticalConceptAndMethodology text,\n DevelopmentRelevance text,\n RelatedSourceLinks text,\n OtherWebLinks integer,\n RelatedIndicators integer,\n LicenseType text\n);\nCREATE TABLE CountryNotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Footnotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Indicators (\n CountryName text,\n CountryCode text PRIMARY KEY,\n IndicatorName text,\n IndicatorCode text PRIMARY KEY,\n Year integer PRIMARY KEY,\n Value integer\n);\nCREATE TABLE SeriesNotes (\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\n-- foreign keys: CountryNotes.Countrycode -> Country.CountryCode; CountryNotes.Seriescode -> Series.SeriesCode; Footnotes.Countrycode -> Country.CountryCode; Footnotes.Seriescode -> Series.SeriesCode; Indicators.CountryCode -> Country.CountryCode; SeriesNotes.Seriescode -> Series.SeriesCode\n\nHint: IndicatorName = 'Death rate, crude (per 1,000 people)'; the highest refers to MAX(Value); from 1960 to 1965 refers to Year between '1960' and '1965'; country refers to CountryName;\n\nQuestion: From 1960 to 1965, which country had the highest Death rate, crude (per 1,000 people)?"}, {"role": "assistant", "content": "SELECT CountryName FROM Indicators WHERE Year BETWEEN 1960 AND 1965 AND IndicatorName = 'Death rate, crude (per 1,000 people)' ORDER BY Value DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"musical\" (\n\"Musical_ID\" int,\n\"Name\" text,\n\"Year\" int,\n\"Award\" text,\n\"Category\" text,\n\"Nominee\" text,\n\"Result\" text,\nPRIMARY KEY (\"Musical_ID\")\n);\n\nCREATE TABLE \"actor\" (\n\"Actor_ID\" int,\n\"Name\" text,\n\"Musical_ID\" int,\n\"Character\" text,\n\"Duration\" text,\n\"age\" int,\nPRIMARY KEY (\"Actor_ID\"),\nFOREIGN KEY (\"Musical_ID\") REFERENCES \"actor\"(\"Actor_ID\")\n);\n\nQuestion: What are the names of actors ordered descending by the year in which their musical was awarded?"}, {"role": "assistant", "content": "SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID ORDER BY T2.Year DESC"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Premises` (\n`premise_id` INTEGER PRIMARY KEY,\n`premises_type` VARCHAR(15) NOT NULL,\n`premise_details` VARCHAR(255)\n);\n\nQuestion: Show the shipping charge and customer id for customer orders with order status Cancelled or Paid."}, {"role": "assistant", "content": "SELECT order_shipping_charges , customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' OR order_status_code = 'Paid'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE employee (\n employee_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address text,\n city text,\n state text,\n zip integer,\n phone text,\n title text,\n salary integer,\n supervisor integer\n);\nCREATE TABLE establishment (\n license_no integer PRIMARY KEY,\n dba_name text,\n aka_name text,\n facility_type text,\n risk_level integer,\n address text,\n city text,\n state text,\n zip integer,\n latitude real,\n longitude real,\n ward integer\n);\nCREATE TABLE inspection (\n inspection_id integer PRIMARY KEY,\n inspection_date date,\n inspection_type text,\n results text,\n employee_id integer,\n license_no integer,\n followup_to integer\n);\nCREATE TABLE inspection_point (\n point_id integer PRIMARY KEY,\n Description text,\n category text,\n code text,\n fine integer,\n point_level text\n);\nCREATE TABLE violation (\n inspection_id integer PRIMARY KEY,\n point_id integer PRIMARY KEY,\n fine integer,\n inspector_comment text\n);\n-- foreign keys: employee.supervisor -> employee.employee_id; inspection.followup_to -> inspection.inspection_id; inspection.license_no -> establishment.license_no; inspection.employee_id -> employee.employee_id; violation.point_id -> inspection_point.point_id; violation.inspection_id -> inspection.inspection_id\n\nHint: type refers to inspection_type; Riverwalk caf\u00e9 refers to facility_type = 'RIVERWALK CAFE'\n\nQuestion: List the types and results of the inspections done on Riverwalk caf\u00e9."}, {"role": "assistant", "content": "SELECT T2.inspection_type, T2.results FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.facility_type = 'RIVERWALK CAFE'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: fans and followers refers to user_fans; most likes of their comments refer to Max(likes)\n\nQuestion: What is the total number of fans or followers who received most likes of their comments in the business?"}, {"role": "assistant", "content": "SELECT COUNT(T1.user_fans) FROM Users AS T1 INNER JOIN Tips AS T2 ON T1.user_id = T2.user_id ORDER BY COUNT(T2.likes) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\n\ncreate table Club (\n ClubID INTEGER PRIMARY KEY,\n ClubName VARCHAR(40),\n ClubDesc VARCHAR(1024),\n ClubLocation VARCHAR(40)\n);\n\ncreate table Member_of_club (\n StuID INTEGER,\n ClubID INTEGER,\n Position VARCHAR(40),\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(ClubID) REFERENCES Club(ClubID)\n);\n\nQuestion: Which clubs have one or more members from the city with code \"HOU\"? Give me the names of the clubs."}, {"role": "assistant", "content": "SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = \"HOU\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE City (\n ID integer PRIMARY KEY,\n Name text,\n CountryCode text,\n District text,\n Population integer\n);\nCREATE TABLE Country (\n Code text PRIMARY KEY,\n Name text,\n Continent text,\n Region text,\n SurfaceArea real,\n IndepYear integer,\n Population integer,\n LifeExpectancy real,\n GNP real,\n GNPOld real,\n LocalName text,\n GovernmentForm text,\n HeadOfState text,\n Capital integer,\n Code2 text\n);\nCREATE TABLE CountryLanguage (\n CountryCode text PRIMARY KEY,\n Language text PRIMARY KEY,\n IsOfficial text,\n Percentage real\n);\n-- foreign keys: City.CountryCode -> Country.Code; CountryLanguage.CountryCode -> Country.Code\n\nHint: high life expectancy at birth refers to MAX(LifeExpectancy);\n\nQuestion: List all the cities in the country where there is high life expectancy at birth."}, {"role": "assistant", "content": "SELECT T2.Name FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode ORDER BY T1.LifeExpectancy DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Community_Area (\n community_area_no integer PRIMARY KEY,\n community_area_name text,\n side text,\n population text\n);\nCREATE TABLE District (\n district_no integer PRIMARY KEY,\n district_name text,\n address text,\n zip_code integer,\n commander text,\n email text,\n phone text,\n fax text,\n tty text,\n twitter text\n);\nCREATE TABLE FBI_Code (\n fbi_code_no text PRIMARY KEY,\n title text,\n description text,\n crime_against text\n);\nCREATE TABLE IUCR (\n iucr_no text PRIMARY KEY,\n primary_description text,\n secondary_description text,\n index_code text\n);\nCREATE TABLE Neighborhood (\n neighborhood_name text PRIMARY KEY,\n community_area_no integer\n);\nCREATE TABLE Ward (\n ward_no integer PRIMARY KEY,\n alderman_first_name text,\n alderman_last_name text,\n alderman_name_suffix text,\n ward_office_address text,\n ward_office_zip text,\n ward_email text,\n ward_office_phone text,\n ward_office_fax text,\n city_hall_office_room integer,\n city_hall_office_phone text,\n city_hall_office_fax text,\n Population integer\n);\nCREATE TABLE Crime (\n report_no integer PRIMARY KEY,\n case_number text,\n date text,\n block text,\n iucr_no text,\n location_description text,\n arrest text,\n domestic text,\n beat integer,\n district_no integer,\n ward_no integer,\n community_area_no integer,\n fbi_code_no text,\n latitude text,\n longitude text\n);\n-- foreign keys: Neighborhood.community_area_no -> Community_Area.community_area_no; Crime.fbi_code_no -> FBI_Code.fbi_code_no; Crime.community_area_no -> Community_Area.community_area_no; Crime.district_no -> District.district_no; Crime.iucr_no -> IUCR.iucr_no; Crime.ward_no -> Ward.ward_no\n\nHint: location refers to latitude, longitude; deceptive practice refers to primary_description = 'DECEPTIVE PRACTICE'; unlawful use of recorded sound refers to secondary_description = 'UNLAWFUL USE OF RECORDED SOUND'\n\nQuestion: Provide the occurrence date and location of the deceptive practice due to the unlawful use of recorded sound."}, {"role": "assistant", "content": "SELECT T2.date, T2.latitude, T2.longitude FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no WHERE T1.primary_description = 'DECEPTIVE PRACTICE' AND T1.secondary_description = 'UNLAWFUL USE OF RECORDED SOUND'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"race\" (\n\"Race_ID\" int,\n\"Name\" text,\n\"Class\" text,\n\"Date\" text,\n\"Track_ID\" text,\nPRIMARY KEY (\"Race_ID\"),\nFOREIGN KEY (\"Track_ID\") REFERENCES \"track\"(\"Track_ID\")\n);\n\nCREATE TABLE \"track\" (\n\"Track_ID\" int,\n\"Name\" text,\n\"Location\" text,\n\"Seating\" real,\n\"Year_Opened\" real,\nPRIMARY KEY (\"Track_ID\")\n);\n\nQuestion: Show names and seatings, ordered by seating for all tracks opened after 2000."}, {"role": "assistant", "content": "SELECT name , seating FROM track WHERE year_opened > 2000 ORDER BY seating"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Author (\n Id integer PRIMARY KEY,\n Name text,\n Affiliation text\n);\nCREATE TABLE Conference (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Journal (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Paper (\n Id integer PRIMARY KEY,\n Title text,\n Year integer,\n ConferenceId integer,\n JournalId integer,\n Keyword text\n);\nCREATE TABLE PaperAuthor (\n PaperId integer,\n AuthorId integer,\n Name text,\n Affiliation text\n);\n-- foreign keys: Paper.JournalId -> Journal.Id; Paper.ConferenceId -> Conference.Id; PaperAuthor.AuthorId -> Author.Id; PaperAuthor.PaperId -> Paper.Id\n\nHint: 'IEEE Transactions on Pattern Analysis and Machine Intelligence' is the FullName of journal; 2011 refers to Year = '2011'; name of the paper refers to Title of paper\n\nQuestion: What was the name of the paper that was published on \"IEEE Transactions on Pattern Analysis and Machine Intelligence\" in 2011?"}, {"role": "assistant", "content": "SELECT T2.Title FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T1.FullName = 'IEEE Transactions on Pattern Analysis and Machine Intelligence' AND T2.Year = 2011 AND T2.Title <> ''"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_iso_code text,\n country_name text\n);\nCREATE TABLE department (\n department_id integer PRIMARY KEY,\n department_name text\n);\nCREATE TABLE gender (\n gender_id integer PRIMARY KEY,\n gender text\n);\nCREATE TABLE genre (\n genre_id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE keyword (\n keyword_id integer PRIMARY KEY,\n keyword_name text\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE language_role (\n role_id integer PRIMARY KEY,\n language_role text\n);\nCREATE TABLE movie (\n movie_id integer PRIMARY KEY,\n title text,\n budget integer,\n homepage text,\n overview text,\n popularity real,\n release_date date,\n revenue integer,\n runtime integer,\n movie_status text,\n tagline text,\n vote_average real,\n vote_count integer\n);\nCREATE TABLE movie_genres (\n movie_id integer,\n genre_id integer\n);\nCREATE TABLE movie_languages (\n movie_id integer,\n language_id integer,\n language_role_id integer\n);\nCREATE TABLE person (\n person_id integer PRIMARY KEY,\n person_name text\n);\nCREATE TABLE movie_crew (\n movie_id integer,\n person_id integer,\n department_id integer,\n job text\n);\nCREATE TABLE production_company (\n company_id integer PRIMARY KEY,\n company_name text\n);\nCREATE TABLE production_country (\n movie_id integer,\n country_id integer\n);\nCREATE TABLE movie_cast (\n movie_id integer,\n person_id integer,\n character_name text,\n gender_id integer,\n cast_order integer\n);\nCREATE TABLE movie_keywords (\n movie_id integer,\n keyword_id integer\n);\nCREATE TABLE movie_company (\n movie_id integer,\n company_id integer\n);\n-- foreign keys: movie_genres.movie_id -> movie.movie_id; movie_genres.genre_id -> genre.genre_id; movie_languages.language_role_id -> language_role.role_id; movie_languages.movie_id -> movie.movie_id; movie_languages.language_id -> language.language_id; movie_crew.person_id -> person.person_id; movie_crew.movie_id -> movie.movie_id; movie_crew.department_id -> department.department_id; production_country.movie_id -> movie.movie_id; production_country.country_id -> country.country_id; movie_cast.person_id -> person.person_id; movie_cast.movie_id -> movie.movie_id; movie_cast.gender_id -> gender.gender_id\n\nHint: genre refers to genre_name; lowest revenue refers to min(revenue)\n\nQuestion: What is the genre of the movie title with the lowest revenue generated?"}, {"role": "assistant", "content": "SELECT T3.genre_name FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id ORDER BY T1.revenue LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"musical\" (\n\"Musical_ID\" int,\n\"Name\" text,\n\"Year\" int,\n\"Award\" text,\n\"Category\" text,\n\"Nominee\" text,\n\"Result\" text,\nPRIMARY KEY (\"Musical_ID\")\n);\n\nCREATE TABLE \"actor\" (\n\"Actor_ID\" int,\n\"Name\" text,\n\"Musical_ID\" int,\n\"Character\" text,\n\"Duration\" text,\n\"age\" int,\nPRIMARY KEY (\"Actor_ID\"),\nFOREIGN KEY (\"Musical_ID\") REFERENCES \"actor\"(\"Actor_ID\")\n);\n\nQuestion: Show names of actors and names of musicals they are in."}, {"role": "assistant", "content": "SELECT T1.Name , T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Customers (\ncustomer_id INTEGER NOT NULL,\ncustomer_details VARCHAR(255),\nPRIMARY KEY (customer_id)\n);\n\nQuestion: How many services has each resident requested? List the resident id, details, and the count in descending order of the count."}, {"role": "assistant", "content": "SELECT T1.resident_id , T1.other_details , count(*) FROM Residents AS T1 JOIN Residents_Services AS T2 ON T1.resident_id = T2.resident_id GROUP BY T1.resident_id ORDER BY count(*) DESC"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Allergy_Type (\n Allergy \t\t VARCHAR(20) PRIMARY KEY,\n AllergyType \t VARCHAR(20)\n);\n\ncreate table Has_Allergy (\n StuID \t\t INTEGER,\n Allergy \t\t VARCHAR(20),\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)\n);\n\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\nQuestion: Give the advisor with the most students."}, {"role": "assistant", "content": "SELECT advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`address_content` VARCHAR(80),\n`city` VARCHAR(50),\n`zip_postcode` VARCHAR(20),\n`state_province_county` VARCHAR(50),\n`country` VARCHAR(50),\n`other_address_details` VARCHAR(255)\n);\n\nQuestion: Find the city with post code 255."}, {"role": "assistant", "content": "SELECT city FROM addresses WHERE zip_postcode = 255"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE offices (\n officeCode text PRIMARY KEY,\n city text,\n phone text,\n addressLine1 text,\n addressLine2 text,\n state text,\n country text,\n postalCode text,\n territory text\n);\nCREATE TABLE employees (\n employeeNumber integer PRIMARY KEY,\n lastName text,\n firstName text,\n extension text,\n email text,\n officeCode text,\n reportsTo integer,\n jobTitle text\n);\nCREATE TABLE customers (\n customerNumber integer PRIMARY KEY,\n customerName text,\n contactLastName text,\n contactFirstName text,\n phone text,\n addressLine1 text,\n addressLine2 text,\n city text,\n state text,\n postalCode text,\n country text,\n salesRepEmployeeNumber integer,\n creditLimit real\n);\nCREATE TABLE orders (\n orderNumber integer PRIMARY KEY,\n orderDate date,\n requiredDate date,\n shippedDate date,\n status text,\n comments text,\n customerNumber integer\n);\nCREATE TABLE payments (\n customerNumber integer PRIMARY KEY,\n checkNumber text PRIMARY KEY,\n paymentDate date,\n amount real\n);\nCREATE TABLE productlines (\n productLine text PRIMARY KEY,\n textDescription text,\n htmlDescription text,\n image blob\n);\nCREATE TABLE products (\n productCode text PRIMARY KEY,\n productName text,\n productLine text,\n productScale text,\n productVendor text,\n productDescription text,\n quantityInStock integer,\n buyPrice real,\n MSRP real\n);\nCREATE TABLE orderdetails (\n orderNumber integer PRIMARY KEY,\n productCode text PRIMARY KEY,\n quantityOrdered integer,\n priceEach real,\n orderLineNumber integer\n);\n-- foreign keys: employees.reportsTo -> employees.employeeNumber; employees.officeCode -> offices.officeCode; customers.salesRepEmployeeNumber -> employees.employeeNumber; orders.customerNumber -> customers.customerNumber; payments.customerNumber -> customers.customerNumber; products.productLine -> productlines.productLine\n\nHint: staff of refers to reportsTO; San Francisco is a city;\n\nQuestion: State the email of those who are staff of Murphy Diane whose number is 1002 and living in San Francisco"}, {"role": "assistant", "content": "SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1002 AND T2.city = 'San Francisco'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: average ratings of 3 refer to user_average_stars = 3; kind of tip length they mostly left refers to tip_length where MAX(COUNT(user_id));\n\nQuestion: For users with average ratings of 3, what kind of tip length they mostly left?"}, {"role": "assistant", "content": "SELECT T2.tip_length FROM Users AS T1 INNER JOIN Tips AS T2 ON T1.user_id = T2.user_id WHERE T1.user_average_stars = 3 GROUP BY T2.tip_length ORDER BY COUNT(T2.tip_length) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE `Staff` (\n`staff_id` INTEGER PRIMARY KEY,\n`gender` VARCHAR(1),\n`first_name` VARCHAR(80),\n`last_name` VARCHAR(80),\n`email_address` VARCHAR(255),\n`phone_number` VARCHAR(80)\n);\n\nQuestion: How many distinct complaint type codes are there in the database?"}, {"role": "assistant", "content": "SELECT count(DISTINCT complaint_type_code) FROM complaints"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Episode (\n episode_id text PRIMARY KEY,\n season integer,\n episode integer,\n number_in_series integer,\n title text,\n summary text,\n air_date text,\n episode_image text,\n rating real,\n votes integer\n);\nCREATE TABLE Person (\n name text PRIMARY KEY,\n birthdate text,\n birth_name text,\n birth_place text,\n birth_region text,\n birth_country text,\n height_meters real,\n nickname text\n);\nCREATE TABLE Award (\n award_id integer PRIMARY KEY,\n organization text,\n year integer,\n award_category text,\n award text,\n person text,\n role text,\n episode_id text,\n season text,\n song text,\n result text\n);\nCREATE TABLE Character_Award (\n award_id integer,\n character text\n);\nCREATE TABLE Credit (\n episode_id text,\n category text,\n person text,\n role text,\n credited text\n);\nCREATE TABLE Keyword (\n episode_id text PRIMARY KEY,\n keyword text PRIMARY KEY\n);\nCREATE TABLE Vote (\n episode_id text,\n stars integer,\n votes integer,\n percent real\n);\n-- 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\n\nHint: average high = Divide(Sum(height_meters), Count(name))\n\nQuestion: Find the average height for each person."}, {"role": "assistant", "content": "SELECT AVG(height_meters) FROM Person;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE app_all (\n app_id integer PRIMARY KEY\n);\nCREATE TABLE app_events (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_events_relevant (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_labels (\n app_id integer,\n label_id integer\n);\nCREATE TABLE events (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE events_relevant (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE gender_age (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE gender_age_test (\n device_id integer PRIMARY KEY\n);\nCREATE TABLE gender_age_train (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE label_categories (\n label_id integer PRIMARY KEY,\n category text\n);\nCREATE TABLE phone_brand_device_model2 (\n device_id integer PRIMARY KEY,\n phone_brand text PRIMARY KEY,\n device_model text PRIMARY KEY\n);\nCREATE TABLE sample_submission (\n device_id integer PRIMARY KEY,\n F23- real,\n F24-26 real,\n F27-28 real,\n F29-32 real,\n F33-42 real,\n F43+ real,\n M22- real,\n M23-26 real,\n M27-28 real,\n M29-31 real,\n M32-38 real,\n M39+ real\n);\n-- 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\n\nHint: most common age group refers to MAX(COUNT(`group`));\n\nQuestion: What is the most common age group among all device users?"}, {"role": "assistant", "content": "SELECT T.num FROM ( SELECT `group`, COUNT(`group`) AS num FROM gender_age GROUP BY `group` ) T"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE businesses (\n business_id integer PRIMARY KEY,\n name text,\n address text,\n city text,\n postal_code text,\n latitude real,\n longitude real,\n phone_number integer,\n tax_code text,\n business_certificate integer,\n application_date date,\n owner_name text,\n owner_address text,\n owner_city text,\n owner_state text,\n owner_zip text\n);\nCREATE TABLE inspections (\n business_id integer,\n score integer,\n date date,\n type text\n);\nCREATE TABLE violations (\n business_id integer,\n date date,\n violation_type_id text,\n risk_category text,\n description text\n);\n-- foreign keys: inspections.business_id -> businesses.business_id; violations.business_id -> businesses.business_id\n\nHint: establishment has the same meaning as business; score of 90 or more refers to score \u2265 90; year(date) = 2015; ; met all required standards for 4 consecutive years refers to COUNT(year(date)) = 4 where score = 100;\n\nQuestion: What are the names of the establishments that met all the required standards for 4 consecutive years?"}, {"role": "assistant", "content": "SELECT DISTINCT T4.name FROM ( SELECT T3.name, T3.years, row_number() OVER (PARTITION BY T3.name ORDER BY T3.years) AS rowNumber FROM ( SELECT DISTINCT name, STRFTIME('%Y', `date`) AS years FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100 ) AS T3 ) AS T4 GROUP BY T4.name, date(T4.years || '-01-01', '-' || (T4.rowNumber - 1) || ' years') HAVING COUNT(T4.years) = 4"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE lists (\n user_id integer,\n list_id integer PRIMARY KEY,\n list_title text,\n list_movie_number integer,\n list_update_timestamp_utc text,\n list_creation_timestamp_utc text,\n list_followers integer,\n list_url text,\n list_comments integer,\n list_description text,\n list_cover_image_url text,\n list_first_image_url text,\n list_second_image_url text,\n list_third_image_url text\n);\nCREATE TABLE movies (\n movie_id integer PRIMARY KEY,\n movie_title text,\n movie_release_year integer,\n movie_url text,\n movie_title_language text,\n movie_popularity integer,\n movie_image_url text,\n director_id text,\n director_name text,\n director_url text\n);\nCREATE TABLE ratings_users (\n user_id integer,\n rating_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\nCREATE TABLE lists_users (\n user_id integer PRIMARY KEY,\n list_id integer PRIMARY KEY,\n list_update_date_utc text,\n list_creation_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial text,\n user_has_payment_method text\n);\nCREATE TABLE ratings (\n movie_id integer,\n rating_id integer,\n rating_url text,\n rating_score integer,\n rating_timestamp_utc text,\n critic text,\n critic_likes integer,\n critic_comments integer,\n user_id integer,\n user_trialist integer,\n user_subscriber integer,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\n-- 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\n\nHint: not been updated for the longest period of time refers to MIN(list_update_timestamp_utc); how long it has not been updated refers to SUBTRACT(CURRENT_TIMESTAMP, list_update_timestamp_utc)\n\nQuestion: Which title list has not been updated for the longest period of time? State how long it has not been updated?"}, {"role": "assistant", "content": "SELECT list_title , datetime(CURRENT_TIMESTAMP, 'localtime') - datetime(list_update_timestamp_utc) FROM lists ORDER BY list_update_timestamp_utc LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE location (\n LocationID integer PRIMARY KEY,\n Country text,\n State text,\n StateCode text,\n City text\n);\nCREATE TABLE user (\n UserID text PRIMARY KEY,\n Gender text\n);\nCREATE TABLE twitter (\n TweetID text PRIMARY KEY,\n Weekday text,\n Hour integer,\n Day integer,\n Lang text,\n IsReshare text,\n Reach integer,\n RetweetCount integer,\n Likes integer,\n Klout integer,\n Sentiment real,\n text text,\n LocationID integer,\n UserID text\n);\n-- foreign keys: twitter.UserID -> user.UserID; twitter.LocationID -> location.LocationID\n\nHint: tweet with the most likes refers to Max(Likes)\n\nQuestion: From which country is the tweet with the most likes posted?"}, {"role": "assistant", "content": "SELECT T2.Country FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID ORDER BY T1.Likes DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Country (\n CountryCode text PRIMARY KEY,\n ShortName text,\n TableName text,\n LongName text,\n Alpha2Code text,\n CurrencyUnit text,\n SpecialNotes text,\n Region text,\n IncomeGroup text,\n Wb2Code text,\n NationalAccountsBaseYear text,\n NationalAccountsReferenceYear text,\n SnaPriceValuation text,\n LendingCategory text,\n OtherGroups text,\n SystemOfNationalAccounts text,\n AlternativeConversionFactor text,\n PppSurveyYear text,\n BalanceOfPaymentsManualInUse text,\n ExternalDebtReportingStatus text,\n SystemOfTrade text,\n GovernmentAccountingConcept text,\n ImfDataDisseminationStandard text,\n LatestPopulationCensus text,\n LatestHouseholdSurvey text,\n SourceOfMostRecentIncomeAndExpenditureData text,\n VitalRegistrationComplete text,\n LatestAgriculturalCensus text,\n LatestIndustrialData integer,\n LatestTradeData integer,\n LatestWaterWithdrawalData integer\n);\nCREATE TABLE Series (\n SeriesCode text PRIMARY KEY,\n Topic text,\n IndicatorName text,\n ShortDefinition text,\n LongDefinition text,\n UnitOfMeasure text,\n Periodicity text,\n BasePeriod text,\n OtherNotes integer,\n AggregationMethod text,\n LimitationsAndExceptions text,\n NotesFromOriginalSource text,\n GeneralComments text,\n Source text,\n StatisticalConceptAndMethodology text,\n DevelopmentRelevance text,\n RelatedSourceLinks text,\n OtherWebLinks integer,\n RelatedIndicators integer,\n LicenseType text\n);\nCREATE TABLE CountryNotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Footnotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Indicators (\n CountryName text,\n CountryCode text PRIMARY KEY,\n IndicatorName text,\n IndicatorCode text PRIMARY KEY,\n Year integer PRIMARY KEY,\n Value integer\n);\nCREATE TABLE SeriesNotes (\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\n-- foreign keys: CountryNotes.Countrycode -> Country.CountryCode; CountryNotes.Seriescode -> Series.SeriesCode; Footnotes.Countrycode -> Country.CountryCode; Footnotes.Seriescode -> Series.SeriesCode; Indicators.CountryCode -> Country.CountryCode; SeriesNotes.Seriescode -> Series.SeriesCode\n\nHint: Latin American & Carribbean is the name of the region; poor countries refers to IncomeGroup = 'Low income';\n\nQuestion: List out the series code and country code of the poor countries that located in Latin American & Carribbean."}, {"role": "assistant", "content": "SELECT T2.SeriesCode, T2.CountryCode FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.Region = 'Latin America & Caribbean' AND t1.incomegroup = 'Low income'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE station (\n id integer PRIMARY KEY,\n name text,\n lat real,\n long real,\n dock_count integer,\n city text,\n installation_date text\n);\nCREATE TABLE status (\n station_id integer,\n bikes_available integer,\n docks_available integer,\n time text\n);\nCREATE TABLE trip (\n id integer PRIMARY KEY,\n duration integer,\n start_date text,\n start_station_name text,\n start_station_id integer,\n end_date text,\n end_station_name text,\n end_station_id integer,\n bike_id integer,\n subscription_type text,\n zip_code integer\n);\nCREATE TABLE weather (\n date text,\n max_temperature_f integer,\n mean_temperature_f integer,\n min_temperature_f integer,\n max_dew_point_f integer,\n mean_dew_point_f integer,\n min_dew_point_f integer,\n max_humidity integer,\n mean_humidity integer,\n min_humidity integer,\n max_sea_level_pressure_inches real,\n mean_sea_level_pressure_inches real,\n min_sea_level_pressure_inches real,\n max_visibility_miles integer,\n mean_visibility_miles integer,\n min_visibility_miles integer,\n max_wind_Speed_mph integer,\n mean_wind_speed_mph integer,\n max_gust_speed_mph integer,\n precipitation_inches text,\n cloud_cover integer,\n events text,\n wind_dir_degrees integer,\n zip_code text\n);\n\nHint: subscribers refers to subscription_type = 'subscribers'; ended their trip at refers to end_station_name; end_station_name = 'MLK Library'; number of docks a station have refers to dock_count;\n\nQuestion: How many subscribers have ended their trip at MLK Library and how many docks does that station have?"}, {"role": "assistant", "content": "SELECT COUNT(T1.id), T2.dock_count FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.end_station_name = 'MLK Library' AND T1.subscription_type = 'Subscriber' AND T2.dock_count = 19"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Ingredient (\n ingredient_id integer PRIMARY KEY,\n category text,\n name text,\n plural text\n);\nCREATE TABLE Recipe (\n recipe_id integer PRIMARY KEY,\n title text,\n subtitle text,\n servings integer,\n yield_unit text,\n prep_min integer,\n cook_min integer,\n stnd_min integer,\n source text,\n intro text,\n directions text\n);\nCREATE TABLE Nutrition (\n recipe_id integer PRIMARY KEY,\n protein real,\n carbo real,\n alcohol real,\n total_fat real,\n sat_fat real,\n cholestrl real,\n sodium real,\n iron real,\n vitamin_c real,\n vitamin_a real,\n fiber real,\n pcnt_cal_carb real,\n pcnt_cal_fat real,\n pcnt_cal_prot real,\n calories real\n);\nCREATE TABLE Quantity (\n quantity_id integer PRIMARY KEY,\n recipe_id integer,\n ingredient_id integer,\n max_qty real,\n min_qty real,\n unit text,\n preparation text,\n optional text\n);\n-- 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\n\nHint: cheese is a category; calories greater than 200 refers to calories > 200; calculation = MULTIPLY(DIVIDE(COUNT(calories > 200 THEN recipe_id), COUNT(recipe_id)), 100)\n\nQuestion: Among all recipes containing cheese, what is the percentage of recipes with calories greater than 200?"}, {"role": "assistant", "content": "SELECT CAST(SUM(CASE WHEN T4.calories > 200 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id INNER JOIN Nutrition AS T4 ON T4.recipe_id = T1.recipe_id WHERE T3.category = 'cheese'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Demog (\n GEOID integer PRIMARY KEY,\n INHABITANTS_K real,\n INCOME_K real,\n A_VAR1 real,\n A_VAR2 real,\n A_VAR3 real,\n A_VAR4 real,\n A_VAR5 real,\n A_VAR6 real,\n A_VAR7 real,\n A_VAR8 real,\n A_VAR9 real,\n A_VAR10 real,\n A_VAR11 real,\n A_VAR12 real,\n A_VAR13 real,\n A_VAR14 real,\n A_VAR15 real,\n A_VAR16 real,\n A_VAR17 real,\n A_VAR18 real\n);\nCREATE TABLE mailings3 (\n REFID integer PRIMARY KEY,\n REF_DATE datetime,\n RESPONSE text\n);\nCREATE TABLE Customers (\n ID integer PRIMARY KEY,\n SEX text,\n MARITAL_STATUS text,\n GEOID integer,\n EDUCATIONNUM integer,\n OCCUPATION text,\n age integer\n);\nCREATE TABLE Mailings1_2 (\n REFID integer PRIMARY KEY,\n REF_DATE datetime,\n RESPONSE text\n);\nCREATE TABLE Sales (\n EVENTID integer PRIMARY KEY,\n REFID integer,\n EVENT_DATE datetime,\n AMOUNT real\n);\n\nHint: reference ID refers to REFID;\n\nQuestion: List down the customer's reference ID with true response."}, {"role": "assistant", "content": "SELECT REFID FROM Mailings1_2 WHERE RESPONSE = 'true'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- phpMyAdmin SQL Dump\n-- version 4.0.10.7\n-- http://www.phpmyadmin.net\n--\n-- Host: localhost\n-- Generation Time: Mar 20, 2015 at 01:43 AM\n-- Server version: 5.5.34-cll-lve\n-- PHP Version: 5.4.23\n\n\n\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n/*!40101 SET NAMES utf8 */;\nCREATE TABLE IF NOT EXISTS `regions` (\n `REGION_ID` decimal(5,0) NOT NULL,\n `REGION_NAME` varchar(25) DEFAULT NULL,\n PRIMARY KEY (`REGION_ID`)\n);\n\n--\n-- Dumping data for table `regions`\n--\n\nQuestion: display the department name, city, and state province for each department."}, {"role": "assistant", "content": "SELECT T1.department_name , T2.city , T2.state_province FROM departments AS T1 JOIN locations AS T2 ON T2.location_id = T1.location_id"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE city (\n id integer PRIMARY KEY,\n city_name text\n);\nCREATE TABLE games (\n id integer PRIMARY KEY,\n games_year integer,\n games_name text,\n season text\n);\nCREATE TABLE games_city (\n games_id integer,\n city_id integer\n);\nCREATE TABLE medal (\n id integer PRIMARY KEY,\n medal_name text\n);\nCREATE TABLE noc_region (\n id integer PRIMARY KEY,\n noc text,\n region_name text\n);\nCREATE TABLE person (\n id integer PRIMARY KEY,\n full_name text,\n gender text,\n height integer,\n weight integer\n);\nCREATE TABLE games_competitor (\n id integer PRIMARY KEY,\n games_id integer,\n person_id integer,\n age integer\n);\nCREATE TABLE person_region (\n person_id integer,\n region_id integer\n);\nCREATE TABLE sport (\n id integer PRIMARY KEY,\n sport_name text\n);\nCREATE TABLE event (\n id integer PRIMARY KEY,\n sport_id integer,\n event_name text\n);\nCREATE TABLE competitor_event (\n event_id integer,\n competitor_id integer,\n medal_id integer\n);\n-- foreign keys: games_city.games_id -> games.id; games_city.city_id -> city.id; games_competitor.person_id -> person.id; games_competitor.games_id -> games.id; person_region.region_id -> noc_region.id; person_region.person_id -> person.id; event.sport_id -> sport.id; competitor_event.medal_id -> medal.id; competitor_event.event_id -> event.id; competitor_event.competitor_id -> games_competitor.id\n\nHint: Who is the youngest person refers to full_name where MIN(age);\n\nQuestion: Who is the youngest person who participated in the Olympics?"}, {"role": "assistant", "content": "SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id ORDER BY T2.age LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE all_prevalences (\n ITEM text PRIMARY KEY,\n POPULATION TYPE text,\n OCCURRENCES integer,\n POPULATION COUNT integer,\n PREVALENCE RATE real,\n PREVALENCE PERCENTAGE real\n);\nCREATE TABLE patients (\n patient text PRIMARY KEY,\n birthdate date,\n deathdate date,\n ssn text,\n drivers text,\n passport text,\n prefix text,\n first text,\n last text,\n suffix text,\n maiden text,\n marital text,\n race text,\n ethnicity text,\n gender text,\n birthplace text,\n address text\n);\nCREATE TABLE encounters (\n ID text PRIMARY KEY,\n DATE date,\n PATIENT text,\n CODE integer,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE allergies (\n START text,\n STOP text,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text\n);\nCREATE TABLE careplans (\n ID text,\n START date,\n STOP date,\n PATIENT text,\n ENCOUNTER text,\n CODE real,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE conditions (\n START date,\n STOP date,\n PATIENT text,\n ENCOUNTER text,\n CODE integer,\n DESCRIPTION text\n);\nCREATE TABLE immunizations (\n DATE date PRIMARY KEY,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text\n);\nCREATE TABLE medications (\n START date PRIMARY KEY,\n STOP date,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE observations (\n DATE date,\n PATIENT text,\n ENCOUNTER text,\n CODE text,\n DESCRIPTION text,\n VALUE real,\n UNITS text\n);\nCREATE TABLE procedures (\n DATE date,\n PATIENT text,\n ENCOUNTER text,\n CODE integer,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE claims (\n ID text PRIMARY KEY,\n PATIENT text,\n BILLABLEPERIOD date,\n ORGANIZATION text,\n ENCOUNTER text,\n DIAGNOSIS text,\n TOTAL integer\n);\n-- foreign keys: encounters.PATIENT -> patients.patient; allergies.PATIENT -> patients.patient; allergies.ENCOUNTER -> encounters.ID; careplans.PATIENT -> patients.patient; careplans.ENCOUNTER -> encounters.ID; conditions.DESCRIPTION -> all_prevalences.ITEM; conditions.PATIENT -> patients.patient; conditions.ENCOUNTER -> encounters.ID; immunizations.PATIENT -> patients.patient; immunizations.ENCOUNTER -> encounters.ID; medications.PATIENT -> patients.patient; medications.ENCOUNTER -> encounters.ID; observations.PATIENT -> patients.patient; observations.ENCOUNTER -> encounters.ID; procedures.PATIENT -> patients.patient; procedures.ENCOUNTER -> encounters.ID\n\nHint: age refers to SUBTRACT(strftime('%Y', deathdate), strftime('%Y', birthdate)); hypertension refers to conditions where DESCRIPTION = 'Hypertension';\n\nQuestion: What is the age of the patient with hypertension named Giovanni Russel?"}, {"role": "assistant", "content": "SELECT strftime('%Y', T2.deathdate) - strftime('%Y', T2.birthdate) AS age FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Giovanni' AND T2.last = 'Russel' AND T1.DESCRIPTION = 'Hypertension'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_iso_code text,\n country_name text\n);\nCREATE TABLE department (\n department_id integer PRIMARY KEY,\n department_name text\n);\nCREATE TABLE gender (\n gender_id integer PRIMARY KEY,\n gender text\n);\nCREATE TABLE genre (\n genre_id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE keyword (\n keyword_id integer PRIMARY KEY,\n keyword_name text\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE language_role (\n role_id integer PRIMARY KEY,\n language_role text\n);\nCREATE TABLE movie (\n movie_id integer PRIMARY KEY,\n title text,\n budget integer,\n homepage text,\n overview text,\n popularity real,\n release_date date,\n revenue integer,\n runtime integer,\n movie_status text,\n tagline text,\n vote_average real,\n vote_count integer\n);\nCREATE TABLE movie_genres (\n movie_id integer,\n genre_id integer\n);\nCREATE TABLE movie_languages (\n movie_id integer,\n language_id integer,\n language_role_id integer\n);\nCREATE TABLE person (\n person_id integer PRIMARY KEY,\n person_name text\n);\nCREATE TABLE movie_crew (\n movie_id integer,\n person_id integer,\n department_id integer,\n job text\n);\nCREATE TABLE production_company (\n company_id integer PRIMARY KEY,\n company_name text\n);\nCREATE TABLE production_country (\n movie_id integer,\n country_id integer\n);\nCREATE TABLE movie_cast (\n movie_id integer,\n person_id integer,\n character_name text,\n gender_id integer,\n cast_order integer\n);\nCREATE TABLE movie_keywords (\n movie_id integer,\n keyword_id integer\n);\nCREATE TABLE movie_company (\n movie_id integer,\n company_id integer\n);\n-- foreign keys: movie_genres.movie_id -> movie.movie_id; movie_genres.genre_id -> genre.genre_id; movie_languages.language_role_id -> language_role.role_id; movie_languages.movie_id -> movie.movie_id; movie_languages.language_id -> language.language_id; movie_crew.person_id -> person.person_id; movie_crew.movie_id -> movie.movie_id; movie_crew.department_id -> department.department_id; production_country.movie_id -> movie.movie_id; production_country.country_id -> country.country_id; movie_cast.person_id -> person.person_id; movie_cast.movie_id -> movie.movie_id; movie_cast.gender_id -> gender.gender_id\n\nHint: genre refers to genre_name; revenue is at least 120,000,000 refers to revenue > = 120000000; between 2012 and 2015 refers to release_date BETWEEN '2012-01-01' AND '2015-12-31'\n\nQuestion: Give the genre and popularity of movies whose revenue is at least 120,000,000 between 2012 and 2015."}, {"role": "assistant", "content": "SELECT T3.genre_name, T1.popularity FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id WHERE T1.revenue > 120000000 AND T1.release_date BETWEEN '2012-01-01' AND '2015-12-31'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE CBSA (\n CBSA integer PRIMARY KEY,\n CBSA_name text,\n CBSA_type text\n);\nCREATE TABLE state (\n abbreviation text PRIMARY KEY,\n name text\n);\nCREATE TABLE congress (\n cognress_rep_id text PRIMARY KEY,\n first_name text,\n last_name text,\n CID text,\n party text,\n state text,\n abbreviation text,\n House text,\n District integer,\n land_area real\n);\nCREATE TABLE zip_data (\n zip_code integer PRIMARY KEY,\n city text,\n state text,\n multi_county text,\n type text,\n organization text,\n time_zone text,\n daylight_savings text,\n latitude real,\n longitude real,\n elevation integer,\n state_fips integer,\n county_fips integer,\n region text,\n division text,\n population_2020 integer,\n population_2010 integer,\n households integer,\n avg_house_value integer,\n avg_income_per_household integer,\n persons_per_household real,\n white_population integer,\n black_population integer,\n hispanic_population integer,\n asian_population integer,\n american_indian_population integer,\n hawaiian_population integer,\n other_population integer,\n male_population integer,\n female_population integer,\n median_age real,\n male_median_age real,\n female_median_age real,\n residential_mailboxes integer,\n business_mailboxes integer,\n total_delivery_receptacles integer,\n businesses integer,\n 1st_quarter_payroll integer,\n annual_payroll integer,\n employees integer,\n water_area real,\n land_area real,\n single_family_delivery_units integer,\n multi_family_delivery_units integer,\n total_beneficiaries integer,\n retired_workers integer,\n disabled_workers integer,\n parents_and_widowed integer,\n spouses integer,\n children integer,\n over_65 integer,\n monthly_benefits_all integer,\n monthly_benefits_retired_workers integer,\n monthly_benefits_widowed integer,\n CBSA integer\n);\nCREATE TABLE alias (\n zip_code integer PRIMARY KEY,\n alias text\n);\nCREATE TABLE area_code (\n zip_code integer PRIMARY KEY,\n area_code integer PRIMARY KEY\n);\nCREATE TABLE avoid (\n zip_code integer PRIMARY KEY,\n bad_alias text PRIMARY KEY\n);\nCREATE TABLE country (\n zip_code integer PRIMARY KEY,\n county text PRIMARY KEY,\n state text\n);\nCREATE TABLE zip_congress (\n zip_code integer PRIMARY KEY,\n district text PRIMARY KEY\n);\n-- foreign keys: congress.abbreviation -> state.abbreviation; zip_data.CBSA -> CBSA.CBSA; zip_data.state -> state.abbreviation; alias.zip_code -> zip_data.zip_code; area_code.zip_code -> zip_data.zip_code; avoid.zip_code -> zip_data.zip_code; country.state -> state.abbreviation; country.zip_code -> zip_data.zip_code; zip_congress.zip_code -> zip_data.zip_code; zip_congress.district -> congress.cognress_rep_id\n\nHint: greater than 50 CBSA officers of metro type refers to COUNT(CBSA_type = 'Metro') > 50;\n\nQuestion: Which state has greater than 50 CBSA officers of metro type?"}, {"role": "assistant", "content": "SELECT T2.state FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_type = 'Metro' GROUP BY T2.state HAVING COUNT(T1.CBSA_type) > 50"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE chapters (\n id integer PRIMARY KEY,\n Act integer,\n Scene integer,\n Description text,\n work_id integer\n);\nCREATE TABLE characters (\n id integer PRIMARY KEY,\n CharName text,\n Abbrev text,\n Description text\n);\nCREATE TABLE paragraphs (\n id integer PRIMARY KEY,\n ParagraphNum integer,\n PlainText text,\n character_id integer,\n chapter_id integer\n);\nCREATE TABLE works (\n id integer PRIMARY KEY,\n Title text,\n LongTitle text,\n Date integer,\n GenreType text\n);\n\nHint: Venus and Adonis refers to Title = 'Venus and Adonis'; last scene refers to max(Scene)\n\nQuestion: In the Venus and Adonis, what is the description of the last scene listed?"}, {"role": "assistant", "content": "SELECT T2.Description FROM works AS T1 RIGHT JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.Title = 'Venus and Adonis' ORDER BY T2.Scene DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Activity (\n actid INTEGER PRIMARY KEY,\n activity_name varchar(25)\n);\n\ncreate table Participates_in (\n stuid INTEGER,\n actid INTEGER,\n FOREIGN KEY(stuid) REFERENCES Student(StuID),\n FOREIGN KEY(actid) REFERENCES Activity(actid)\n);\n\ncreate table Faculty_Participates_in (\n FacID INTEGER,\n actid INTEGER,\n FOREIGN KEY(FacID) REFERENCES Faculty(FacID),\n FOREIGN KEY(actid) REFERENCES Activity(actid)\n);\n\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\ncreate table Faculty (\n FacID \t INTEGER PRIMARY KEY,\n Lname\t\tVARCHAR(15),\n Fname\t\tVARCHAR(15),\n Rank\t\tVARCHAR(15),\n Sex\t\tVARCHAR(1),\n Phone\t\tINTEGER,\n Room\t\tVARCHAR(5),\n Building\t\tVARCHAR(13)\n);\n\nQuestion: Show the names of all the activities Mark Giuliano participates in."}, {"role": "assistant", "content": "SELECT T3.activity_name FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN Activity AS T3 ON T3.actid = T2.actid WHERE T1.fname = \"Mark\" AND T1.lname = \"Giuliano\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n/* \n * SQL scripts for CS61 Intro to SQL lectures\n * FILENAME SOCCER2.SQL\n */\n\nDROP TABLE IF EXISTS Player;\nDROP TABLE IF EXISTS Tryout;\nDROP TABLE IF EXISTS College;\n\nCREATE TABLE \tCollege \n ( cName \tvarchar(20) NOT NULL,\n state \tvarchar(2),\n enr \tnumeric(5,0),\n PRIMARY KEY (cName)\n );\n\nCREATE TABLE \tPlayer\n ( pID\t\t\tnumeric(5,0) NOT NULL,\n \tpName \tvarchar(20),\n yCard \tvarchar(3),\n HS \tnumeric(5,0),\n PRIMARY KEY (pID)\n );\n\nCREATE TABLE \tTryout\n ( pID\t\t\tnumeric(5,0),\n \tcName \tvarchar(20),\n pPos \tvarchar(8),\n decision varchar(3),\n PRIMARY KEY (pID, cName),\n FOREIGN KEY (pID) REFERENCES Player(pID),\n FOREIGN KEY (cName) REFERENCES College(cName)\n );\n\n/* note that \"left\" and \"right\" are reserved words in SQL */\n\nQuestion: Find the names of either colleges in LA with greater than 15000 size or in state AZ with less than 13000 enrollment."}, {"role": "assistant", "content": "SELECT cName FROM College WHERE enr < 13000 AND state = \"AZ\" UNION SELECT cName FROM College WHERE enr > 15000 AND state = \"LA\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nHint: store no. 1 refers to store_id = 1; address location refers to address, address2, district\n\nQuestion: State the address location of store No.1."}, {"role": "assistant", "content": "SELECT T1.address, T1.address2, T1.district FROM address AS T1 INNER JOIN store AS T2 ON T1.address_id = T2.address_id WHERE T2.store_id = 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE businesses (\n business_id integer PRIMARY KEY,\n name text,\n address text,\n city text,\n postal_code text,\n latitude real,\n longitude real,\n phone_number integer,\n tax_code text,\n business_certificate integer,\n application_date date,\n owner_name text,\n owner_address text,\n owner_city text,\n owner_state text,\n owner_zip text\n);\nCREATE TABLE inspections (\n business_id integer,\n score integer,\n date date,\n type text\n);\nCREATE TABLE violations (\n business_id integer,\n date date,\n violation_type_id text,\n risk_category text,\n description text\n);\n-- foreign keys: inspections.business_id -> businesses.business_id; violations.business_id -> businesses.business_id\n\nQuestion: For the business which got the most number of violations, how many inspections did it have?"}, {"role": "assistant", "content": "SELECT COUNT(T2.business_id) FROM violations AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id GROUP BY T1.business_id ORDER BY COUNT(T1.business_id) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Episode (\n episode_id text PRIMARY KEY,\n season integer,\n episode integer,\n number_in_series integer,\n title text,\n summary text,\n air_date text,\n episode_image text,\n rating real,\n votes integer\n);\nCREATE TABLE Person (\n name text PRIMARY KEY,\n birthdate text,\n birth_name text,\n birth_place text,\n birth_region text,\n birth_country text,\n height_meters real,\n nickname text\n);\nCREATE TABLE Award (\n award_id integer PRIMARY KEY,\n organization text,\n year integer,\n award_category text,\n award text,\n person text,\n role text,\n episode_id text,\n season text,\n song text,\n result text\n);\nCREATE TABLE Character_Award (\n award_id integer,\n character text\n);\nCREATE TABLE Credit (\n episode_id text,\n category text,\n person text,\n role text,\n credited text\n);\nCREATE TABLE Keyword (\n episode_id text PRIMARY KEY,\n keyword text PRIMARY KEY\n);\nCREATE TABLE Vote (\n episode_id text,\n stars integer,\n votes integer,\n percent real\n);\n-- 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\n\nQuestion: What are the keywords of the episode which has title as Dangerous Curves?"}, {"role": "assistant", "content": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Dangerous Curves';"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Allergy_Type (\n Allergy \t\t VARCHAR(20) PRIMARY KEY,\n AllergyType \t VARCHAR(20)\n);\n\ncreate table Has_Allergy (\n StuID \t\t INTEGER,\n Allergy \t\t VARCHAR(20),\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)\n);\n\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\nQuestion: Find the first name and gender of the student who has allergy to milk but not cat."}, {"role": "assistant", "content": "SELECT fname , sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = \"Milk\" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = \"Cat\")"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Name text,\n Price real\n);\nCREATE TABLE Sales (\n SalesID integer PRIMARY KEY,\n SalesPersonID integer,\n CustomerID integer,\n ProductID integer,\n Quantity integer\n);\n-- foreign keys: Sales.ProductID -> Products.ProductID; Sales.CustomerID -> Customers.CustomerID; Sales.SalesPersonID -> Employees.EmployeeID\n\nHint: product ID lower than 15 refers to ProductID < 15; costs 10 and below refers to Price; Price < = 10;\n\nQuestion: Among the products with product ID lower than 15, how many of them costs 10 and below?"}, {"role": "assistant", "content": "SELECT COUNT(ProductID) FROM Products WHERE ProductID < 15 AND Price <= 10"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\n\nCREATE TABLE \"film\" (\n\"Film_ID\" int,\n\"Title\" text,\n\"Studio\" text,\n\"Director\" text,\n\"Gross_in_dollar\" int,\nPRIMARY KEY (\"Film_ID\")\n);\n\nQuestion: What are the names of studios that have made two or more films?"}, {"role": "assistant", "content": "SELECT Studio FROM film GROUP BY Studio HAVING COUNT(*) >= 2"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE `Staff` (\n`staff_id` INTEGER PRIMARY KEY,\n`gender` VARCHAR(1),\n`first_name` VARCHAR(80),\n`last_name` VARCHAR(80),\n`email_address` VARCHAR(255),\n`phone_number` VARCHAR(80)\n);\n\nQuestion: Count the number of different complaint type codes."}, {"role": "assistant", "content": "SELECT count(DISTINCT complaint_type_code) FROM complaints"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"train\" (\n \"id\" int,\n \"train_number\" int,\n \"name\" text,\n \"origin\" text,\n \"destination\" text,\n \"time\" text,\n \"interval\" text,\n primary key (\"id\")\n);\n\nCREATE TABLE \"station\" (\n \"id\" int,\n \"network_name\" text,\n \"services\" text,\n \"local_authority\" text,\n primary key (\"id\")\n);\n\nCREATE TABLE \"route\" (\n \"train_id\" int,\n \"station_id\" int,\n primary key (\"train_id\", \"station_id\"),\n foreign key (\"train_id\") references `train`(\"id\"),\n foreign key (\"station_id\") references `station`(\"id\")\n);\n\nCREATE TABLE \"weekly_weather\" (\n \"station_id\" int,\n \"day_of_week\" text,\n \"high_temperature\" int,\n \"low_temperature\" int,\n \"precipitation\" real,\n \"wind_speed_mph\" int,\n primary key (\"station_id\", \"day_of_week\"),\n foreign key (\"station_id\") references \"station\"(\"id\")\n);\n\nQuestion: Find the id and local authority of the station whose maximum precipitation is higher than 50."}, {"role": "assistant", "content": "SELECT t2.id , t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id HAVING max(t1.precipitation) > 50"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`address_content` VARCHAR(80),\n`city` VARCHAR(50),\n`zip_postcode` VARCHAR(20),\n`state_province_county` VARCHAR(50),\n`country` VARCHAR(50),\n`other_address_details` VARCHAR(255)\n);\n\nQuestion: What are the dates when customers with ids between 10 and 20 became customers?"}, {"role": "assistant", "content": "SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE all_star (\n player_id TEXT,\n year INTEGER,\n game_num INTEGER,\n game_id TEXT,\n team_id TEXT,\n league_id TEXT,\n gp NUMERIC,\n starting_pos NUMERIC,\n foreign key (player_id) references player(player_id)\n);\n\nQuestion: Find the full name and id of the college that has the most baseball players."}, {"role": "assistant", "content": "SELECT T1.name_full , T1.college_id FROM college AS T1 JOIN player_college AS T2 ON T1.college_id = T2.college_id GROUP BY T1.college_id ORDER BY count(*) DESC LIMIT 1;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Document_Types` (\n`document_type_code` VARCHAR(10) PRIMARY KEY,\n`document_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Documents` (\n`document_id` INTEGER PRIMARY KEY,\n`document_type_code` VARCHAR(10),\n`grant_id` INTEGER NOT NULL,\n`sent_date` DATETIME NOT NULL,\n`response_received_date` DATETIME NOT NULL,\n`other_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ),\nFOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` )\n);\nCREATE TABLE `Grants` (\n`grant_id` INTEGER PRIMARY KEY,\n`organisation_id` INTEGER NOT NULL,\n`grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0,\n`grant_start_date` DATETIME NOT NULL,\n`grant_end_date` DATETIME NOT NULL,\n`other_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Organisation_Types` (\n`organisation_type` VARCHAR(10) PRIMARY KEY,\n`organisation_type_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Organisations` (\n`organisation_id` INTEGER PRIMARY KEY,\n`organisation_type` VARCHAR(10) NOT NULL,\n`organisation_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` )\n);\nCREATE TABLE `Project_Outcomes` (\n`project_id` INTEGER NOT NULL,\n`outcome_code` VARCHAR(10) NOT NULL,\n`outcome_details` VARCHAR(255),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` )\n);\nCREATE TABLE `Project_Staff` (\n`staff_id` DOUBLE PRIMARY KEY,\n`project_id` INTEGER NOT NULL,\n`role_code` VARCHAR(10) NOT NULL,\n`date_from` DATETIME,\n`date_to` DATETIME,\n`other_details` VARCHAR(255),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` )\n);\nCREATE TABLE `Projects` (\n`project_id` INTEGER PRIMARY KEY,\n`organisation_id` INTEGER NOT NULL,\n`project_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Research_Outcomes` (\n`outcome_code` VARCHAR(10) PRIMARY KEY,\n`outcome_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Research_Staff` (\n`staff_id` INTEGER PRIMARY KEY,\n`employer_organisation_id` INTEGER NOT NULL,\n`staff_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Staff_Roles` (\n`role_code` VARCHAR(10) PRIMARY KEY,\n`role_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Tasks` (\n`task_id` INTEGER PRIMARY KEY,\n`project_id` INTEGER NOT NULL,\n`task_details` VARCHAR(255) NOT NULL,\n`eg Agree Objectives` VARCHAR(1),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` )\n);\n\nQuestion: What is the description for the results whose project detail is 'sint'?"}, {"role": "assistant", "content": "SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code = T2.outcome_code JOIN Projects AS T3 ON T2.project_id = T3.project_id WHERE T3.project_details = 'sint'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Third_Party_Companies` (\n`company_id` INTEGER PRIMARY KEY ,\n`company_type` VARCHAR(5) NOT NULL,\n`company_name` VARCHAR(255),\n`company_address` VARCHAR(255),\n`other_company_details` VARCHAR(255)\n);\n\nQuestion: List the all the assets make, model, details by the disposed date ascendingly."}, {"role": "assistant", "content": "SELECT asset_make , asset_model , asset_details FROM Assets ORDER BY asset_disposed_date ASC"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE \"Rooms\" ( \n\t\"RoomId\" TEXT PRIMARY KEY,\n\t\"roomName\" TEXT, \n\t\"beds\" INTEGER, \n\t\"bedType\" TEXT, \n\t\"maxOccupancy\" INTEGER, \n\t\"basePrice\" INTEGER, \n\t\"decor\" TEXT\n\n);\n\nCREATE TABLE \"Reservations\" ( \n\t\"Code\" INTEGER PRIMARY KEY, \n\t\"Room\" TEXT, \n\t\"CheckIn\" TEXT, \n\t\"CheckOut\" TEXT, \n\t\"Rate\" REAL, \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Adults\" INTEGER, \n\t\"Kids\" INTEGER,\n\tFOREIGN KEY (Room) REFERENCES Rooms(RoomId)\n);\n\nQuestion: Return the name, rate, check in and check out date for the room with the highest rate."}, {"role": "assistant", "content": "SELECT T2.roomName , T1.Rate , T1.CheckIn , T1.CheckOut FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY T1.Rate DESC LIMIT 1;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"race\" (\n\"Race_ID\" int,\n\"Name\" text,\n\"Class\" text,\n\"Date\" text,\n\"Track_ID\" text,\nPRIMARY KEY (\"Race_ID\"),\nFOREIGN KEY (\"Track_ID\") REFERENCES \"track\"(\"Track_ID\")\n);\n\nCREATE TABLE \"track\" (\n\"Track_ID\" int,\n\"Name\" text,\n\"Location\" text,\n\"Seating\" real,\n\"Year_Opened\" real,\nPRIMARY KEY (\"Track_ID\")\n);\n\nQuestion: List the race class with at least two races."}, {"role": "assistant", "content": "SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city_name text,\n state text,\n population integer,\n area real\n);\nCREATE TABLE customer (\n cust_id integer PRIMARY KEY,\n cust_name text,\n annual_revenue integer,\n cust_type text,\n address text,\n city text,\n state text,\n zip real,\n phone text\n);\nCREATE TABLE driver (\n driver_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address text,\n city text,\n state text,\n zip_code integer,\n phone text\n);\nCREATE TABLE truck (\n truck_id integer PRIMARY KEY,\n make text,\n model_year integer\n);\nCREATE TABLE shipment (\n ship_id integer PRIMARY KEY,\n cust_id integer,\n weight real,\n truck_id integer,\n driver_id integer,\n city_id integer,\n ship_date text\n);\n-- 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\n\nHint: shipment no. 1275 refers to ship_id = 1275; customer name refers to cust_name\n\nQuestion: Who was the customer of shipment no.1275? Give the customer's name."}, {"role": "assistant", "content": "SELECT T1.cust_name FROM customer AS T1 INNER JOIN shipment AS T2 ON T1.cust_id = T2.cust_id WHERE T2.ship_id = '1275'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"event\" (\n \"Event_ID\" int,\n \"Date\" text,\n \"Venue\" text,\n \"Name\" text,\n \"Event_Attendance\" int,\n PRIMARY KEY (\"Event_ID\")\n);\n\nCREATE TABLE \"journalist\" (\n \"journalist_ID\" int,\n \"Name\" text,\n \"Nationality\" text,\n \"Age\" text,\n \"Years_working\" int,\n PRIMARY KEY (\"journalist_ID\")\n);\n\nQuestion: Find the average age and experience working length of journalists working on different role type."}, {"role": "assistant", "content": "SELECT avg(t1.age) , avg(Years_working) , t2.work_type FROM journalist AS t1 JOIN news_report AS t2 ON t1.journalist_id = t2.journalist_id GROUP BY t2.work_type"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"building\" (\n\"building_id\" text,\n\"Name\" text,\n\"Street_address\" text,\n\"Years_as_tallest\" text,\n\"Height_feet\" int,\n\"Floors\" int,\nPRIMARY KEY(\"building_id\")\n);\n\nCREATE TABLE \"Institution\" (\n\"Institution_id\" text,\n\"Institution\" text,\n\"Location\" text,\n\"Founded\" real,\n\"Type\" text,\n\"Enrollment\" int,\n\"Team\" text,\n\"Primary_Conference\" text,\n\"building_id\" text,\nPRIMARY KEY(\"Institution_id\"),\nFOREIGN KEY (\"building_id\") REFERENCES \"building\"(\"building_id\")\n);\n\nCREATE TABLE \"protein\" (\n\"common_name\" text,\n\"protein_name\" text,\n\"divergence_from_human_lineage\" real,\n\"accession_number\" text,\n\"sequence_length\" real,\n\"sequence_identity_to_human_protein\" text,\n\"Institution_id\" text,\nPRIMARY KEY(\"common_name\"),\nFOREIGN KEY(\"Institution_id\") REFERENCES \"Institution\"(\"Institution_id\")\n);\n\nQuestion: What are the average, maximum, and minimum number of floors for all buildings?"}, {"role": "assistant", "content": "SELECT avg(floors) , max(floors) , min(floors) FROM building"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\n\nCREATE TABLE Addresses (\nAddress_ID INTEGER NOT NULL ,\naddress_details VARCHAR(255),\nPRIMARY KEY (Address_ID),\nUNIQUE (Address_ID)\n);\nCREATE TABLE Locations (\nLocation_ID INTEGER NOT NULL ,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Location_ID)\n);\nCREATE TABLE Products (\nProduct_ID INTEGER NOT NULL,\nProduct_Type_Code CHAR(15),\nProduct_Name VARCHAR(255),\nProduct_Price DECIMAL(20,4),\nPRIMARY KEY (Product_ID),\nUNIQUE (Product_ID)\n);\nCREATE TABLE Parties (\nParty_ID INTEGER NOT NULL,\nParty_Details VARCHAR(255),\nPRIMARY KEY (Party_ID)\n);\nCREATE TABLE Assets (\nAsset_ID INTEGER NOT NULL ,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Asset_ID)\n);\nCREATE TABLE Channels (\nChannel_ID INTEGER NOT NULL ,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Channel_ID)\n);\nCREATE TABLE Finances (\nFinance_ID INTEGER NOT NULL ,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Finance_ID)\n);\n\nQuestion: Show the prices of the products named \"Dining\" or \"Trading Policy\"."}, {"role": "assistant", "content": "SELECT Product_Price FROM Products WHERE Product_Name = \"Dining\" OR Product_Name = \"Trading Policy\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE height_info (\n height_id integer PRIMARY KEY,\n height_in_cm integer,\n height_in_inch text\n);\nCREATE TABLE weight_info (\n weight_id integer PRIMARY KEY,\n weight_in_kg integer,\n weight_in_lbs integer\n);\nCREATE TABLE PlayerInfo (\n ELITEID integer PRIMARY KEY,\n PlayerName text,\n birthdate text,\n birthyear date,\n birthmonth integer,\n birthday integer,\n birthplace text,\n nation text,\n height integer,\n weight integer,\n position_info text,\n shoots text,\n draftyear integer,\n draftround integer,\n overall integer,\n overallby text,\n CSS_rank integer,\n sum_7yr_GP integer,\n sum_7yr_TOI integer,\n GP_greater_than_0 text\n);\nCREATE TABLE SeasonStatus (\n ELITEID integer,\n SEASON text,\n TEAM text,\n LEAGUE text,\n GAMETYPE text,\n GP integer,\n G integer,\n A integer,\n P integer,\n PIM integer,\n PLUSMINUS integer\n);\n-- foreign keys: PlayerInfo.weight -> weight_info.weight_id; PlayerInfo.height -> height_info.height_id; SeasonStatus.ELITEID -> PlayerInfo.ELITEID\n\nHint: goals scored refers to G; Calgary Hitmen refers to TEAM = 'Calgary Hitmen'; percentage = MULTIPLY(DIVIDE(SUM(G WHERE PlayerName = 'Ian Schultz'), SUM(G)), 100); 2007-2008 season refers to SEASON = '2007-2008';\n\nQuestion: Among all goals scored by Calgary Hitmen in the 2007-2008 season, identify the percentage scored by Ian Schultz."}, {"role": "assistant", "content": "SELECT CAST(SUM(CASE WHEN T2.PlayerName = 'Ian Schultz' THEN T1.G ELSE 0 END) AS REAL) * 100 / SUM(T1.G) FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.SEASON = '2007-2008' AND T1.TEAM = 'Calgary Hitmen'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- dbext:type=SQLITE:dbname=movie_rating.db\n\n/* Delete the tables if they already exist */\ndrop table if exists Movie;\ndrop table if exists Reviewer;\ndrop table if exists Rating;\n\n/* Create the schema for our tables */\ncreate table Movie(\n\tmID int primary key, \n\ttitle text, \n\tyear int, \n\tdirector text\n);\ncreate table Reviewer(\n\trID int primary key, \n\tname text);\n\ncreate table Rating(\n\trID int, \n\tmID int, \n\tstars int, \n\tratingDate date,\n\tFOREIGN KEY (mID) references Movie(mID),\n\tFOREIGN KEY (rID) references Reviewer(rID)\n);\n\n/* Populate the tables with our data */\n\nQuestion: What are names of the movies that are either made before 1980 or directed by James Cameron?"}, {"role": "assistant", "content": "SELECT title FROM Movie WHERE director = \"James Cameron\" OR YEAR < 1980"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"gymnast\" (\n\"Gymnast_ID\" int,\n\"Floor_Exercise_Points\" real,\n\"Pommel_Horse_Points\" real,\n\"Rings_Points\" real,\n\"Vault_Points\" real,\n\"Parallel_Bars_Points\" real,\n\"Horizontal_Bar_Points\" real,\n\"Total_Points\" real,\nPRIMARY KEY (\"Gymnast_ID\"),\nFOREIGN KEY (\"Gymnast_ID\") REFERENCES \"people\"(\"People_ID\")\n);\n\nCREATE TABLE \"people\" (\n\"People_ID\" int,\n\"Name\" text,\n\"Age\" real,\n\"Height\" real,\n\"Hometown\" text,\nPRIMARY KEY (\"People_ID\")\n);\n\nQuestion: What is the average horizontal bar points for all gymnasts?"}, {"role": "assistant", "content": "SELECT avg(Horizontal_Bar_Points) FROM gymnast"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\n\nCREATE TABLE \"film\" (\n\"Film_ID\" int,\n\"Title\" text,\n\"Studio\" text,\n\"Director\" text,\n\"Gross_in_dollar\" int,\nPRIMARY KEY (\"Film_ID\")\n);\n\nQuestion: Who are the different directors of films which had market estimation in 1995?"}, {"role": "assistant", "content": "SELECT DISTINCT T1.Director FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID WHERE T2.Year = 1995"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Author (\n Id integer PRIMARY KEY,\n Name text,\n Affiliation text\n);\nCREATE TABLE Conference (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Journal (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Paper (\n Id integer PRIMARY KEY,\n Title text,\n Year integer,\n ConferenceId integer,\n JournalId integer,\n Keyword text\n);\nCREATE TABLE PaperAuthor (\n PaperId integer,\n AuthorId integer,\n Name text,\n Affiliation text\n);\n-- foreign keys: Paper.JournalId -> Journal.Id; Paper.ConferenceId -> Conference.Id; PaperAuthor.AuthorId -> Author.Id; PaperAuthor.PaperId -> Paper.Id\n\nHint: A context-based navigation paradigm for accessing Web data' is the title of paper; name of conference refer to FullName\n\nQuestion: Where was the 'A context-based navigation paradigm for accessing Web data' paper published? State the name of the conference."}, {"role": "assistant", "content": "SELECT T2.FullName FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Title = 'A context-based navigation paradigm for accessing Web data'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- phpMyAdmin SQL Dump\n-- version 4.0.10.7\n-- http://www.phpmyadmin.net\n--\n-- Host: localhost\n-- Generation Time: Mar 20, 2015 at 01:43 AM\n-- Server version: 5.5.34-cll-lve\n-- PHP Version: 5.4.23\n\n\n\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n/*!40101 SET NAMES utf8 */;\nCREATE TABLE IF NOT EXISTS `regions` (\n `REGION_ID` decimal(5,0) NOT NULL,\n `REGION_NAME` varchar(25) DEFAULT NULL,\n PRIMARY KEY (`REGION_ID`)\n);\n\n--\n-- Dumping data for table `regions`\n--\n\nQuestion: What are the first name and department name of all employees?"}, {"role": "assistant", "content": "SELECT T1.first_name , T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"roller_coaster\" (\n\"Roller_Coaster_ID\" int,\n\"Name\" text,\n\"Park\" text,\n\"Country_ID\" int,\n\"Length\" real,\n\"Height\" real,\n\"Speed\" text,\n\"Opened\" text,\n\"Status\" text,\nPRIMARY KEY (\"Roller_Coaster_ID\"),\nFOREIGN KEY (\"Country_ID\") REFERENCES `country`(\"Country_ID\")\n);\n\nCREATE TABLE \"country\" (\n\"Country_ID\" int,\n\"Name\" text,\n\"Population\" int,\n\"Area\" int,\n\"Languages\" text,\nPRIMARY KEY (\"Country_ID\")\n);\n\nQuestion: What are the lengths and heights of roller coasters?"}, {"role": "assistant", "content": "SELECT LENGTH , Height FROM roller_coaster"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE state (\n StateCode text PRIMARY KEY,\n State text,\n Region text\n);\nCREATE TABLE callcenterlogs (\n Date received date,\n Complaint ID text PRIMARY KEY,\n rand client text,\n phonefinal text,\n vru+line text,\n call_id integer,\n priority integer,\n type text,\n outcome text,\n server text,\n ser_start text,\n ser_exit text,\n ser_time text\n);\nCREATE TABLE client (\n client_id text PRIMARY KEY,\n sex text,\n day integer,\n month integer,\n year integer,\n age integer,\n social text,\n first text,\n middle text,\n last text,\n phone text,\n email text,\n address_1 text,\n address_2 text,\n city text,\n state text,\n zipcode integer,\n district_id integer\n);\nCREATE TABLE district (\n district_id integer PRIMARY KEY,\n city text,\n state_abbrev text,\n division text\n);\nCREATE TABLE events (\n Date received date,\n Product text,\n Sub-product text,\n Issue text,\n Sub-issue text,\n Consumer complaint narrative text,\n Tags text,\n Consumer consent provided? text,\n Submitted via text,\n Date sent to company text,\n Company response to consumer text,\n Timely response? text,\n Consumer disputed? text,\n Complaint ID text PRIMARY KEY,\n Client_ID text PRIMARY KEY\n);\nCREATE TABLE reviews (\n Date date PRIMARY KEY,\n Stars integer,\n Reviews text,\n Product text,\n district_id integer\n);\n-- foreign keys: callcenterlogs.rand client -> client.client_id; client.district_id -> district.district_id; district.state_abbrev -> state.StateCode; events.Client_ID -> client.client_id; events.Complaint ID -> callcenterlogs.Complaint ID; reviews.district_id -> district.district_id\n\nHint: complaints narratives refers to \"Consumer complaint narrative\";\n\nQuestion: List all the complaints narratives made by the customer named Brenda and last name Mayer."}, {"role": "assistant", "content": "SELECT T2.`Consumer complaint narrative` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Brenda' AND T1.last = 'Mayer'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE bool (\n name text PRIMARY KEY\n);\nCREATE TABLE person (\n name text PRIMARY KEY\n);\nCREATE TABLE disabled (\n name text PRIMARY KEY\n);\nCREATE TABLE enlist (\n name text,\n organ text\n);\nCREATE TABLE filed_for_bankrupcy (\n name text PRIMARY KEY\n);\nCREATE TABLE longest_absense_from_school (\n name text PRIMARY KEY,\n month integer\n);\nCREATE TABLE male (\n name text PRIMARY KEY\n);\nCREATE TABLE no_payment_due (\n name text PRIMARY KEY,\n bool text\n);\nCREATE TABLE unemployed (\n name text PRIMARY KEY\n);\nCREATE TABLE enrolled (\n name text PRIMARY KEY,\n school text PRIMARY KEY,\n month integer\n);\n-- foreign keys: disabled.name -> person.name; enlist.name -> person.name; filed_for_bankrupcy.name -> person.name; longest_absense_from_school.name -> person.name; male.name -> person.name; no_payment_due.bool -> bool.name; no_payment_due.name -> person.name; unemployed.name -> person.name; enrolled.name -> person.name\n\nHint: enlisted in the navy organization refers to organ = 'navy';\n\nQuestion: How many students are enlisted in the Navy organization?"}, {"role": "assistant", "content": "SELECT COUNT(name) FROM enlist WHERE organ = 'navy'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Author (\n Id integer PRIMARY KEY,\n Name text,\n Affiliation text\n);\nCREATE TABLE Conference (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Journal (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Paper (\n Id integer PRIMARY KEY,\n Title text,\n Year integer,\n ConferenceId integer,\n JournalId integer,\n Keyword text\n);\nCREATE TABLE PaperAuthor (\n PaperId integer,\n AuthorId integer,\n Name text,\n Affiliation text\n);\n-- foreign keys: Paper.JournalId -> Journal.Id; Paper.ConferenceId -> Conference.Id; PaperAuthor.AuthorId -> Author.Id; PaperAuthor.PaperId -> Paper.Id\n\nHint: published in 2003 refers to Year = 2003; 'Department of Network Science, Graduate School of Information Systems, The University of Electro-Communications' is the Affiliation organization\n\nQuestion: What is the title of the paper published in 2003 by an author with affiliation with Department of Network Science, Graduate School of Information Systems, The University of Electro-Communications?"}, {"role": "assistant", "content": "SELECT DISTINCT T2.Title FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T1.Affiliation = 'Department of Network Science, Graduate School of Information Systems, The University of Electro-Communications' AND T2.Year = 2003"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n/* \n * SQL scripts for CS61 Intro to SQL lectures\n * FILENAME SOCCER2.SQL\n */\n\nDROP TABLE IF EXISTS Player;\nDROP TABLE IF EXISTS Tryout;\nDROP TABLE IF EXISTS College;\n\nCREATE TABLE \tCollege \n ( cName \tvarchar(20) NOT NULL,\n state \tvarchar(2),\n enr \tnumeric(5,0),\n PRIMARY KEY (cName)\n );\n\nCREATE TABLE \tPlayer\n ( pID\t\t\tnumeric(5,0) NOT NULL,\n \tpName \tvarchar(20),\n yCard \tvarchar(3),\n HS \tnumeric(5,0),\n PRIMARY KEY (pID)\n );\n\nCREATE TABLE \tTryout\n ( pID\t\t\tnumeric(5,0),\n \tcName \tvarchar(20),\n pPos \tvarchar(8),\n decision varchar(3),\n PRIMARY KEY (pID, cName),\n FOREIGN KEY (pID) REFERENCES Player(pID),\n FOREIGN KEY (cName) REFERENCES College(cName)\n );\n\n/* note that \"left\" and \"right\" are reserved words in SQL */\n\nQuestion: How many different players trained for more than 1000 hours?"}, {"role": "assistant", "content": "SELECT count(*) FROM Player WHERE HS > 1000"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"captain\" (\n\"Captain_ID\" int,\n\"Name\" text,\n\"Ship_ID\" int,\n\"age\" text,\n\"Class\" text,\n\"Rank\" text,\nPRIMARY KEY (\"Captain_ID\"),\nFOREIGN KEY (\"Ship_ID\") REFERENCES \"Ship\"(\"Ship_ID\")\n);\n\nCREATE TABLE \"Ship\" (\n\"Ship_ID\" int,\n\"Name\" text,\n\"Type\" text,\n\"Built_Year\" real,\n\"Class\" text,\n\"Flag\" text,\nPRIMARY KEY (\"Ship_ID\")\n);\n\nQuestion: Which classes have more than two captains?"}, {"role": "assistant", "content": "SELECT CLASS FROM captain GROUP BY CLASS HAVING count(*) > 2"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: attribute of beer_and_wine refers to attribute_value = 'beer_and_wine'; in Peoria refers to city = 'Peoria'\n\nQuestion: Among the businesses which have attribute of beer_and_wine, how many business located in Peoria?"}, {"role": "assistant", "content": "SELECT COUNT(T1.business_id) FROM Business_Attributes AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T2.city = 'Peoria' AND T1.attribute_value = 'beer_and_wine'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"repair\" (\n\"repair_ID\" int,\n\"name\" text,\n\"Launch_Date\" text,\n\"Notes\" text,\nPRIMARY KEY (\"repair_ID\")\n);\n\nQuestion: Show names of technicians who are assigned to repair machines with value point more than 70."}, {"role": "assistant", "content": "SELECT T3.Name FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.machine_id = T2.machine_id JOIN technician AS T3 ON T1.technician_ID = T3.technician_ID WHERE T2.value_points > 70"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nHint: 'Jon Stephens' is a full name of a customer; full name refers to first_name, last_name;\n\nQuestion: How many different clients have rented materials from Jon Stephens?"}, {"role": "assistant", "content": "SELECT COUNT(T1.customer_id) FROM rental AS T1 INNER JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Jon' AND T2.last_name = 'Stephens'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE divisions (\n division text PRIMARY KEY,\n name text,\n country text\n);\nCREATE TABLE matchs (\n Div text,\n Date date,\n HomeTeam text,\n AwayTeam text,\n FTHG integer,\n FTAG integer,\n FTR text,\n season integer\n);\n-- foreign keys: matchs.Div -> divisions.division\n\nHint: MAX(SUM where FTHG, FTAG, season = 2021);\n\nQuestion: What is the highest final-time score across all divisions in the 2021 season? Which team was the team that made up that score?"}, {"role": "assistant", "content": "SELECT ( SELECT MAX(MAX(FTAG), MAX(FTHG)) FROM matchs WHERE season = 2021 ) AS T1, AwayTeam FROM matchs WHERE season = 2021 AND FTHG = T1 OR FTAG = T1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`address_details` VARCHAR(255)\n);\n\nQuestion: What is id of the staff who had a Staff Department Assignment earlier than any Clerical Staff?"}, {"role": "assistant", "content": "SELECT staff_id FROM Staff_Department_Assignments WHERE date_assigned_to < (SELECT max(date_assigned_to) FROM Staff_Department_Assignments WHERE job_title_code = 'Clerical Staff')"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Community_Area (\n community_area_no integer PRIMARY KEY,\n community_area_name text,\n side text,\n population text\n);\nCREATE TABLE District (\n district_no integer PRIMARY KEY,\n district_name text,\n address text,\n zip_code integer,\n commander text,\n email text,\n phone text,\n fax text,\n tty text,\n twitter text\n);\nCREATE TABLE FBI_Code (\n fbi_code_no text PRIMARY KEY,\n title text,\n description text,\n crime_against text\n);\nCREATE TABLE IUCR (\n iucr_no text PRIMARY KEY,\n primary_description text,\n secondary_description text,\n index_code text\n);\nCREATE TABLE Neighborhood (\n neighborhood_name text PRIMARY KEY,\n community_area_no integer\n);\nCREATE TABLE Ward (\n ward_no integer PRIMARY KEY,\n alderman_first_name text,\n alderman_last_name text,\n alderman_name_suffix text,\n ward_office_address text,\n ward_office_zip text,\n ward_email text,\n ward_office_phone text,\n ward_office_fax text,\n city_hall_office_room integer,\n city_hall_office_phone text,\n city_hall_office_fax text,\n Population integer\n);\nCREATE TABLE Crime (\n report_no integer PRIMARY KEY,\n case_number text,\n date text,\n block text,\n iucr_no text,\n location_description text,\n arrest text,\n domestic text,\n beat integer,\n district_no integer,\n ward_no integer,\n community_area_no integer,\n fbi_code_no text,\n latitude text,\n longitude text\n);\n-- foreign keys: Neighborhood.community_area_no -> Community_Area.community_area_no; Crime.fbi_code_no -> FBI_Code.fbi_code_no; Crime.community_area_no -> Community_Area.community_area_no; Crime.district_no -> District.district_no; Crime.iucr_no -> IUCR.iucr_no; Crime.ward_no -> Ward.ward_no\n\nHint: \"Deering\" and \"Near West\" are both district_name; 'LIBRARY' is the location_description; district with the most number of crime Max(Count(district_no))\n\nQuestion: Between Deering and Near West districts, which district reported the most number of crime incidents that happened in a library?"}, {"role": "assistant", "content": "SELECT T1.district_name FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.district_name IN ('Deering', 'Near West') AND T2.location_description = 'LIBRARY' GROUP BY T1.district_name ORDER BY COUNT(T2.district_no) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE geographic (\n city text PRIMARY KEY,\n county text,\n region text\n);\nCREATE TABLE generalinfo (\n id_restaurant integer PRIMARY KEY,\n label text,\n food_type text,\n city text,\n review real\n);\nCREATE TABLE location (\n id_restaurant integer PRIMARY KEY,\n street_num integer,\n street_name text,\n city text\n);\n-- foreign keys: generalinfo.city -> geographic.city; location.id_restaurant -> generalinfo.id_restaurant; location.city -> geographic.city\n\nHint: Italian food refers to food_type = 'Italian'\n\nQuestion: Which country has the most restaurants with Italian food?"}, {"role": "assistant", "content": "SELECT T2.county FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.food_type = 'Italian' GROUP BY T2.county ORDER BY COUNT(T1.id_restaurant) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Name text,\n Price real\n);\nCREATE TABLE Sales (\n SalesID integer PRIMARY KEY,\n SalesPersonID integer,\n CustomerID integer,\n ProductID integer,\n Quantity integer\n);\n-- foreign keys: Sales.ProductID -> Products.ProductID; Sales.CustomerID -> Customers.CustomerID; Sales.SalesPersonID -> Employees.EmployeeID\n\nQuestion: What is the price and name of the product bought by Erica Xu?"}, {"role": "assistant", "content": "SELECT T3.Price, T3.Name FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID WHERE T2.FirstName = 'Erica' AND T2.LastName = 'Xu'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE station (\n id integer PRIMARY KEY,\n name text,\n lat real,\n long real,\n dock_count integer,\n city text,\n installation_date text\n);\nCREATE TABLE status (\n station_id integer,\n bikes_available integer,\n docks_available integer,\n time text\n);\nCREATE TABLE trip (\n id integer PRIMARY KEY,\n duration integer,\n start_date text,\n start_station_name text,\n start_station_id integer,\n end_date text,\n end_station_name text,\n end_station_id integer,\n bike_id integer,\n subscription_type text,\n zip_code integer\n);\nCREATE TABLE weather (\n date text,\n max_temperature_f integer,\n mean_temperature_f integer,\n min_temperature_f integer,\n max_dew_point_f integer,\n mean_dew_point_f integer,\n min_dew_point_f integer,\n max_humidity integer,\n mean_humidity integer,\n min_humidity integer,\n max_sea_level_pressure_inches real,\n mean_sea_level_pressure_inches real,\n min_sea_level_pressure_inches real,\n max_visibility_miles integer,\n mean_visibility_miles integer,\n min_visibility_miles integer,\n max_wind_Speed_mph integer,\n mean_wind_speed_mph integer,\n max_gust_speed_mph integer,\n precipitation_inches text,\n cloud_cover integer,\n events text,\n wind_dir_degrees integer,\n zip_code text\n);\n\nHint: rain of more than 0.8 inches refers to events = rain where precipitation_inches>0.8; average ride duration = DIVIDE(SUM(duration), COUNT(duration));\n\nQuestion: Find the average ride duration during the rain of more than 0.8 inches."}, {"role": "assistant", "content": "SELECT AVG(T1.duration) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE (T2.events = 'Rain' AND T2.precipitation_inches > 0.8) OR (T2.events = 'rain' AND T2.precipitation_inches > 0.8)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Categories (\n CategoryID integer PRIMARY KEY,\n CategoryName text,\n Description text\n);\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n CustomerName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n LastName text,\n FirstName text,\n BirthDate date,\n Photo text,\n Notes text\n);\nCREATE TABLE Shippers (\n ShipperID integer PRIMARY KEY,\n ShipperName text,\n Phone text\n);\nCREATE TABLE Suppliers (\n SupplierID integer PRIMARY KEY,\n SupplierName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text,\n Phone text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n ProductName text,\n SupplierID integer,\n CategoryID integer,\n Unit text,\n Price real\n);\nCREATE TABLE Orders (\n OrderID integer PRIMARY KEY,\n CustomerID integer,\n EmployeeID integer,\n OrderDate datetime,\n ShipperID integer\n);\nCREATE TABLE OrderDetails (\n OrderDetailID integer PRIMARY KEY,\n OrderID integer,\n ProductID integer,\n Quantity integer\n);\n-- 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\n\nHint: High reorder level generally means high user satisfaction of the product and vice versa; the least satisfaction refers to MIN(ReorderLevel); the highest unit price refers to MAX(UnitPrice);\n\nQuestion: Of the 10 products with the highest unit price, identify by their ID the ones that have generated the least satisfaction."}, {"role": "assistant", "content": "SELECT ProductID FROM Products ORDER BY ReorderLevel ASC, UnitPrice DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: user No. refers to user_id;\n\nQuestion: User No.\"63469\" has got \"1\" like for a tip to the Yelp business, which city is that business located in?"}, {"role": "assistant", "content": "SELECT T1.city FROM Business AS T1 INNER JOIN Tips AS T2 ON T1.business_id = T2.business_id WHERE T2.likes = 1 AND T2.user_id = 63469"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE station (\n id INTEGER PRIMARY KEY,\n name TEXT,\n lat NUMERIC,\n long NUMERIC,\n dock_count INTEGER,\n city TEXT,\n installation_date TEXT);\n\nQuestion: Give me the dates when the max temperature was higher than 85."}, {"role": "assistant", "content": "SELECT date FROM weather WHERE max_temperature_f > 85"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE Ref_Document_Types (\nDocument_Type_Code CHAR(15) NOT NULL,\nDocument_Type_Name VARCHAR(255) NOT NULL,\nDocument_Type_Description VARCHAR(255) NOT NULL,\nPRIMARY KEY (Document_Type_Code)\n);\n\nCREATE TABLE Ref_Calendar (\nCalendar_Date DATETIME NOT NULL,\nDay_Number INTEGER,\nPRIMARY KEY (Calendar_Date)\n);\nCREATE TABLE Ref_Locations (\nLocation_Code CHAR(15) NOT NULL,\nLocation_Name VARCHAR(255) NOT NULL,\nLocation_Description VARCHAR(255) NOT NULL,\nPRIMARY KEY (Location_Code)\n);\n\nCREATE TABLE Roles (\nRole_Code CHAR(15) NOT NULL,\nRole_Name VARCHAR(255),\nRole_Description VARCHAR(255),\nPRIMARY KEY (Role_Code)\n);\n\nCREATE TABLE All_Documents (\nDocument_ID INTEGER NOT NULL,\nDate_Stored DATETIME,\nDocument_Type_Code CHAR(15) NOT NULL,\nDocument_Name CHAR(255),\nDocument_Description CHAR(255),\nOther_Details VARCHAR(255),\nPRIMARY KEY (Document_ID),\nFOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code),\nFOREIGN KEY (Date_Stored) REFERENCES Ref_Calendar (Calendar_Date)\n);\n\nCREATE TABLE Employees (\nEmployee_ID INTEGER NOT NULL,\nRole_Code CHAR(15) NOT NULL,\nEmployee_Name VARCHAR(255),\nGender_MFU CHAR(1) NOT NULL,\nDate_of_Birth DATETIME NOT NULL,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Employee_ID),\nFOREIGN KEY (Role_Code) REFERENCES Roles (Role_Code)\n);\n\nCREATE TABLE Document_Locations (\nDocument_ID INTEGER NOT NULL,\nLocation_Code CHAR(15) NOT NULL,\nDate_in_Location_From DATETIME NOT NULL,\nDate_in_Locaton_To DATETIME,\nPRIMARY KEY (Document_ID, Location_Code, Date_in_Location_From),\nFOREIGN KEY (Location_Code) REFERENCES Ref_Locations (Location_Code),\nFOREIGN KEY (Date_in_Location_From) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Date_in_Locaton_To) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Document_ID) REFERENCES All_Documents (Document_ID)\n);\n\nCREATE TABLE Documents_to_be_Destroyed (\nDocument_ID INTEGER NOT NULL,\nDestruction_Authorised_by_Employee_ID INTEGER,\nDestroyed_by_Employee_ID INTEGER,\nPlanned_Destruction_Date DATETIME,\nActual_Destruction_Date DATETIME,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Document_ID),\nFOREIGN KEY (Destroyed_by_Employee_ID) REFERENCES Employees (Employee_ID),\nFOREIGN KEY (Destruction_Authorised_by_Employee_ID) REFERENCES Employees (Employee_ID),\nFOREIGN KEY (Planned_Destruction_Date) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Actual_Destruction_Date) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Document_ID) REFERENCES All_Documents (Document_ID)\n);\n\nQuestion: What are the names of the employees who authorised the destruction and the employees who destroyed the corresponding documents?"}, {"role": "assistant", "content": "SELECT T2.employee_name , T3.employee_name FROM Documents_to_be_destroyed AS T1 JOIN Employees AS T2 ON T1.Destruction_Authorised_by_Employee_ID = T2.employee_id JOIN Employees AS T3 ON T1.Destroyed_by_Employee_ID = T3.employee_id;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nHint: the category Travel refers to category.name = 'Travel'\n\nQuestion: List the descriptions of movies under the category Travel."}, {"role": "assistant", "content": "SELECT T1.description FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.`name` = 'Travel'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE `Staff` (\n`staff_id` INTEGER PRIMARY KEY,\n`gender` VARCHAR(1),\n`first_name` VARCHAR(80),\n`last_name` VARCHAR(80),\n`email_address` VARCHAR(255),\n`phone_number` VARCHAR(80)\n);\n\nQuestion: List the name of all products along with the number of complaints that they have received."}, {"role": "assistant", "content": "SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"film\" (\n\"Film_ID\" int,\n\"Rank_in_series\" int,\n\"Number_in_season\" int,\n\"Title\" text,\n\"Directed_by\" text,\n\"Original_air_date\" text,\n\"Production_code\" text,\nPRIMARY KEY (\"Film_ID\")\n);\n\nCREATE TABLE \"cinema\" (\n\"Cinema_ID\" int,\n\"Name\" text,\n\"Openning_year\" int,\n\"Capacity\" int,\n\"Location\" text,\nPRIMARY KEY (\"Cinema_ID\"));\n\nQuestion: How many films have the word 'Dummy' in their titles?"}, {"role": "assistant", "content": "SELECT count(*) FROM film WHERE title LIKE \"%Dummy%\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE address_status (\n status_id integer PRIMARY KEY,\n address_status text\n);\nCREATE TABLE author (\n author_id integer PRIMARY KEY,\n author_name text\n);\nCREATE TABLE book_language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n street_number text,\n street_name text,\n city text,\n country_id integer\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n email text\n);\nCREATE TABLE customer_address (\n customer_id integer PRIMARY KEY,\n address_id integer PRIMARY KEY,\n status_id integer\n);\nCREATE TABLE order_status (\n status_id integer PRIMARY KEY,\n status_value text\n);\nCREATE TABLE publisher (\n publisher_id integer PRIMARY KEY,\n publisher_name text\n);\nCREATE TABLE book (\n book_id integer PRIMARY KEY,\n title text,\n isbn13 text,\n language_id integer,\n num_pages integer,\n publication_date date,\n publisher_id integer\n);\nCREATE TABLE book_author (\n book_id integer PRIMARY KEY,\n author_id integer PRIMARY KEY\n);\nCREATE TABLE shipping_method (\n method_id integer PRIMARY KEY,\n method_name text,\n cost real\n);\nCREATE TABLE cust_order (\n order_id integer PRIMARY KEY,\n order_date datetime,\n customer_id integer,\n shipping_method_id integer,\n dest_address_id integer\n);\nCREATE TABLE order_history (\n history_id integer PRIMARY KEY,\n order_id integer,\n status_id integer,\n status_date datetime\n);\nCREATE TABLE order_line (\n line_id integer PRIMARY KEY,\n order_id integer,\n book_id integer,\n price real\n);\n-- 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\n\nHint: in Japanese refers to language_name = 'Japanese\n\nQuestion: How many books have been published in Japanese?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id WHERE T1.language_name = 'Japanese'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE location (\n LocationID integer PRIMARY KEY,\n Country text,\n State text,\n StateCode text,\n City text\n);\nCREATE TABLE user (\n UserID text PRIMARY KEY,\n Gender text\n);\nCREATE TABLE twitter (\n TweetID text PRIMARY KEY,\n Weekday text,\n Hour integer,\n Day integer,\n Lang text,\n IsReshare text,\n Reach integer,\n RetweetCount integer,\n Likes integer,\n Klout integer,\n Sentiment real,\n text text,\n LocationID integer,\n UserID text\n);\n-- foreign keys: twitter.UserID -> user.UserID; twitter.LocationID -> location.LocationID\n\nHint: \"United Kingdom\" is the Country\n\nQuestion: State the number of states in the United Kingdom."}, {"role": "assistant", "content": "SELECT COUNT(State) AS State_number FROM location WHERE Country = 'United Kingdom'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE all_prevalences (\n ITEM text PRIMARY KEY,\n POPULATION TYPE text,\n OCCURRENCES integer,\n POPULATION COUNT integer,\n PREVALENCE RATE real,\n PREVALENCE PERCENTAGE real\n);\nCREATE TABLE patients (\n patient text PRIMARY KEY,\n birthdate date,\n deathdate date,\n ssn text,\n drivers text,\n passport text,\n prefix text,\n first text,\n last text,\n suffix text,\n maiden text,\n marital text,\n race text,\n ethnicity text,\n gender text,\n birthplace text,\n address text\n);\nCREATE TABLE encounters (\n ID text PRIMARY KEY,\n DATE date,\n PATIENT text,\n CODE integer,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE allergies (\n START text,\n STOP text,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text\n);\nCREATE TABLE careplans (\n ID text,\n START date,\n STOP date,\n PATIENT text,\n ENCOUNTER text,\n CODE real,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE conditions (\n START date,\n STOP date,\n PATIENT text,\n ENCOUNTER text,\n CODE integer,\n DESCRIPTION text\n);\nCREATE TABLE immunizations (\n DATE date PRIMARY KEY,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text\n);\nCREATE TABLE medications (\n START date PRIMARY KEY,\n STOP date,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE observations (\n DATE date,\n PATIENT text,\n ENCOUNTER text,\n CODE text,\n DESCRIPTION text,\n VALUE real,\n UNITS text\n);\nCREATE TABLE procedures (\n DATE date,\n PATIENT text,\n ENCOUNTER text,\n CODE integer,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE claims (\n ID text PRIMARY KEY,\n PATIENT text,\n BILLABLEPERIOD date,\n ORGANIZATION text,\n ENCOUNTER text,\n DIAGNOSIS text,\n TOTAL integer\n);\n-- foreign keys: encounters.PATIENT -> patients.patient; allergies.PATIENT -> patients.patient; allergies.ENCOUNTER -> encounters.ID; careplans.PATIENT -> patients.patient; careplans.ENCOUNTER -> encounters.ID; conditions.DESCRIPTION -> all_prevalences.ITEM; conditions.PATIENT -> patients.patient; conditions.ENCOUNTER -> encounters.ID; immunizations.PATIENT -> patients.patient; immunizations.ENCOUNTER -> encounters.ID; medications.PATIENT -> patients.patient; medications.ENCOUNTER -> encounters.ID; observations.PATIENT -> patients.patient; observations.ENCOUNTER -> encounters.ID; procedures.PATIENT -> patients.patient; procedures.ENCOUNTER -> encounters.ID\n\nHint: full name = first, last; otitis media refers to conditions.DESCRIPTION = 'Otitis media';\n\nQuestion: List the full name of all patients with 'otitis media'."}, {"role": "assistant", "content": "SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Otitis media'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"artist\" (\n \"Artist_ID\" int,\n \"Artist\" text,\n \"Age\" int,\n \"Famous_Title\" text,\n \"Famous_Release_date\" text,\n PRIMARY KEY (\"Artist_ID\")\n);\n\n\n\nCREATE TABLE \"volume\" (\n \"Volume_ID\" int,\n \"Volume_Issue\" text,\n \"Issue_Date\" text,\n \"Weeks_on_Top\" real,\n \"Song\" text,\n \"Artist_ID\" int,\n PRIMARY KEY (\"Volume_ID\"),\n FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`)\n);\n\nQuestion: Return the dates of ceremony and the results of all music festivals"}, {"role": "assistant", "content": "SELECT Date_of_ceremony , RESULT FROM music_festival"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE chapters (\n id integer PRIMARY KEY,\n Act integer,\n Scene integer,\n Description text,\n work_id integer\n);\nCREATE TABLE characters (\n id integer PRIMARY KEY,\n CharName text,\n Abbrev text,\n Description text\n);\nCREATE TABLE paragraphs (\n id integer PRIMARY KEY,\n ParagraphNum integer,\n PlainText text,\n character_id integer,\n chapter_id integer\n);\nCREATE TABLE works (\n id integer PRIMARY KEY,\n Title text,\n LongTitle text,\n Date integer,\n GenreType text\n);\n\nHint: paragraph \"What, wilt thou hear some music, my sweet love?\" refers to\u00a0 PlainText = 'What, wilt thou hear some music, my sweet love?'\n\nQuestion: What is the chapter description where the paragraph \"What, wilt thou hear some music, my sweet love?\" belongs?"}, {"role": "assistant", "content": "SELECT T1.id, T1.Description FROM chapters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.chapter_id WHERE T2.PlainText = 'What, wilt thou hear some music, my sweet love?'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE current (\n ballotpedia_id text,\n bioguide_id text PRIMARY KEY,\n birthday_bio date,\n cspan_id real PRIMARY KEY,\n fec_id text,\n first_name text,\n gender_bio text,\n google_entity_id_id text,\n govtrack_id integer,\n house_history_id real,\n icpsr_id real,\n last_name text,\n lis_id text,\n maplight_id real,\n middle_name text,\n nickname_name text,\n official_full_name text,\n opensecrets_id text,\n religion_bio text,\n suffix_name text,\n thomas_id integer,\n votesmart_id real,\n wikidata_id text,\n wikipedia_id text\n);\nCREATE TABLE current-terms (\n address text,\n bioguide text PRIMARY KEY,\n caucus text,\n chamber text,\n class real,\n contact_form text,\n district real,\n end text PRIMARY KEY,\n fax text,\n last text,\n name text,\n office text,\n party text,\n party_affiliations text,\n phone text,\n relation text,\n rss_url text,\n start text,\n state text,\n state_rank text,\n title text,\n type text,\n url text\n);\nCREATE TABLE historical (\n ballotpedia_id text,\n bioguide_id text PRIMARY KEY,\n bioguide_previous_id text,\n birthday_bio text,\n cspan_id text,\n fec_id text,\n first_name text,\n gender_bio text,\n google_entity_id_id text,\n govtrack_id integer,\n house_history_alternate_id text,\n house_history_id real,\n icpsr_id real,\n last_name text,\n lis_id text,\n maplight_id text,\n middle_name text,\n nickname_name text,\n official_full_name text,\n opensecrets_id text,\n religion_bio text,\n suffix_name text,\n thomas_id text,\n votesmart_id text,\n wikidata_id text,\n wikipedia_id text\n);\nCREATE TABLE historical-terms (\n address text,\n bioguide text PRIMARY KEY,\n chamber text,\n class real,\n contact_form text,\n district real,\n end text,\n fax text,\n last text,\n middle text,\n name text,\n office text,\n party text,\n party_affiliations text,\n phone text,\n relation text,\n rss_url text,\n start text,\n state text,\n state_rank text,\n title text,\n type text,\n url text\n);\nCREATE TABLE social-media (\n bioguide text PRIMARY KEY,\n facebook text,\n facebook_id real,\n govtrack real,\n instagram text,\n instagram_id real,\n thomas integer,\n twitter text,\n twitter_id real,\n youtube text,\n youtube_id text\n);\n-- foreign keys: current-terms.bioguide -> current.bioguide_id; historical-terms.bioguide -> historical.bioguide_id; social-media.bioguide -> current.bioguide_id\n\nHint: full names = first_name, last_name; non-google entity refers to google_entity_id_id is null; female refers to gender_bio = 'F'; have not been registered in Federal Election Commission data refers to fec_id is null;\n\nQuestion: What are the full names of the non-google female entity legislators that have not been registered in Federal Election Commission data?"}, {"role": "assistant", "content": "SELECT first_name, last_name FROM historical WHERE gender_bio = 'F' AND google_entity_id_id IS NULL AND fec_id IS NULL"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE app_all (\n app_id integer PRIMARY KEY\n);\nCREATE TABLE app_events (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_events_relevant (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_labels (\n app_id integer,\n label_id integer\n);\nCREATE TABLE events (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE events_relevant (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE gender_age (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE gender_age_test (\n device_id integer PRIMARY KEY\n);\nCREATE TABLE gender_age_train (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE label_categories (\n label_id integer PRIMARY KEY,\n category text\n);\nCREATE TABLE phone_brand_device_model2 (\n device_id integer PRIMARY KEY,\n phone_brand text PRIMARY KEY,\n device_model text PRIMARY KEY\n);\nCREATE TABLE sample_submission (\n device_id integer PRIMARY KEY,\n F23- real,\n F24-26 real,\n F27-28 real,\n F29-32 real,\n F33-42 real,\n F43+ real,\n M22- real,\n M23-26 real,\n M27-28 real,\n M29-31 real,\n M32-38 real,\n M39+ real\n);\n-- 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\n\nHint: in 2016 refers to year(timestamp) = 2016; M23-26 user group refers to `group` = 'M23-26';\n\nQuestion: Among the devices with an event occurring in 2016, how many of them are owned by a user in the M23-26 user group?"}, {"role": "assistant", "content": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE STRFTIME('%Y', T2.timestamp) = '2016' AND T1.`group` = 'M23-26'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Episode (\n episode_id text PRIMARY KEY,\n season integer,\n episode integer,\n number_in_series integer,\n title text,\n summary text,\n air_date text,\n episode_image text,\n rating real,\n votes integer\n);\nCREATE TABLE Person (\n name text PRIMARY KEY,\n birthdate text,\n birth_name text,\n birth_place text,\n birth_region text,\n birth_country text,\n height_meters real,\n nickname text\n);\nCREATE TABLE Award (\n award_id integer PRIMARY KEY,\n organization text,\n year integer,\n award_category text,\n award text,\n person text,\n role text,\n episode_id text,\n season text,\n song text,\n result text\n);\nCREATE TABLE Character_Award (\n award_id integer,\n character text\n);\nCREATE TABLE Credit (\n episode_id text,\n category text,\n person text,\n role text,\n credited text\n);\nCREATE TABLE Keyword (\n episode_id text PRIMARY KEY,\n keyword text PRIMARY KEY\n);\nCREATE TABLE Vote (\n episode_id text,\n stars integer,\n votes integer,\n percent real\n);\n-- 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\n\nHint: in Season 20 Episode 11 refers to episode_id = 'S20-E11'; 'Doofus' is the nickname of person; include in credit list refers to credited = 'true'\n\nQuestion: In Season 20 Episode 11, how many times was Doofus included in the credit list?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T1.nickname = 'Doofus' AND T2.credited = 'true' AND T2.episode_id = 'S20-E11';"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: business are opened for more than 8 hours refer to business_id where SUBTRACT(closing_time, opening_time) > 8; DIVIDE(COUNT(business_id where active = 'true' and city = 'Mesa' and SUBTRACT(closing_time, opening_time) > 8), COUNT(business_id where city = 'Mesa' and SUBTRACT(closing_time, opening_time) > 8)) as percentage;\n\nQuestion: How many business are opened for more than 8 hour in Mesa and what is the percentage of the active businesses?"}, {"role": "assistant", "content": "SELECT CAST(SUM(CASE WHEN T1.active = 'true' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.business_id) AS ACT FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Mesa'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE authors (\n au_id text PRIMARY KEY,\n au_lname text,\n au_fname text,\n phone text,\n address text,\n city text,\n state text,\n zip text,\n contract text\n);\nCREATE TABLE jobs (\n job_id integer PRIMARY KEY,\n job_desc text,\n min_lvl integer,\n max_lvl integer\n);\nCREATE TABLE publishers (\n pub_id text PRIMARY KEY,\n pub_name text,\n city text,\n state text,\n country text\n);\nCREATE TABLE employee (\n emp_id text PRIMARY KEY,\n fname text,\n minit text,\n lname text,\n job_id integer,\n job_lvl integer,\n pub_id text,\n hire_date datetime\n);\nCREATE TABLE pub_info (\n pub_id text PRIMARY KEY,\n logo blob,\n pr_info text\n);\nCREATE TABLE stores (\n stor_id text PRIMARY KEY,\n stor_name text,\n stor_address text,\n city text,\n state text,\n zip text\n);\nCREATE TABLE discounts (\n discounttype text,\n stor_id text,\n lowqty integer,\n highqty integer,\n discount real\n);\nCREATE TABLE titles (\n title_id text PRIMARY KEY,\n title text,\n type text,\n pub_id text,\n price real,\n advance real,\n royalty integer,\n ytd_sales integer,\n notes text,\n pubdate datetime\n);\nCREATE TABLE roysched (\n title_id text,\n lorange integer,\n hirange integer,\n royalty integer\n);\nCREATE TABLE sales (\n stor_id text PRIMARY KEY,\n ord_num text PRIMARY KEY,\n ord_date datetime,\n qty integer,\n payterms text,\n title_id text PRIMARY KEY\n);\nCREATE TABLE titleauthor (\n au_id text PRIMARY KEY,\n title_id text PRIMARY KEY,\n au_ord integer,\n royaltyper integer\n);\n-- 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\n\nHint: publisher and designer are job descriptions which refers to job_desc; percentage more = 100*(SUBTRACT(SUM(CASE WHERE job_desc = 'publisher), SUM(CASE WHERE job_desc = 'designer'))\n\nQuestion: Among all the employees, how many percent more for the publishers than designers?"}, {"role": "assistant", "content": "SELECT CAST(SUM(CASE WHEN T2.job_desc = 'publisher' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.job_desc = 'designer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Country (\n CountryCode text PRIMARY KEY,\n ShortName text,\n TableName text,\n LongName text,\n Alpha2Code text,\n CurrencyUnit text,\n SpecialNotes text,\n Region text,\n IncomeGroup text,\n Wb2Code text,\n NationalAccountsBaseYear text,\n NationalAccountsReferenceYear text,\n SnaPriceValuation text,\n LendingCategory text,\n OtherGroups text,\n SystemOfNationalAccounts text,\n AlternativeConversionFactor text,\n PppSurveyYear text,\n BalanceOfPaymentsManualInUse text,\n ExternalDebtReportingStatus text,\n SystemOfTrade text,\n GovernmentAccountingConcept text,\n ImfDataDisseminationStandard text,\n LatestPopulationCensus text,\n LatestHouseholdSurvey text,\n SourceOfMostRecentIncomeAndExpenditureData text,\n VitalRegistrationComplete text,\n LatestAgriculturalCensus text,\n LatestIndustrialData integer,\n LatestTradeData integer,\n LatestWaterWithdrawalData integer\n);\nCREATE TABLE Series (\n SeriesCode text PRIMARY KEY,\n Topic text,\n IndicatorName text,\n ShortDefinition text,\n LongDefinition text,\n UnitOfMeasure text,\n Periodicity text,\n BasePeriod text,\n OtherNotes integer,\n AggregationMethod text,\n LimitationsAndExceptions text,\n NotesFromOriginalSource text,\n GeneralComments text,\n Source text,\n StatisticalConceptAndMethodology text,\n DevelopmentRelevance text,\n RelatedSourceLinks text,\n OtherWebLinks integer,\n RelatedIndicators integer,\n LicenseType text\n);\nCREATE TABLE CountryNotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Footnotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Indicators (\n CountryName text,\n CountryCode text PRIMARY KEY,\n IndicatorName text,\n IndicatorCode text PRIMARY KEY,\n Year integer PRIMARY KEY,\n Value integer\n);\nCREATE TABLE SeriesNotes (\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\n-- foreign keys: CountryNotes.Countrycode -> Country.CountryCode; CountryNotes.Seriescode -> Series.SeriesCode; Footnotes.Countrycode -> Country.CountryCode; Footnotes.Seriescode -> Series.SeriesCode; Indicators.CountryCode -> Country.CountryCode; SeriesNotes.Seriescode -> Series.SeriesCode\n\nQuestion: List out the table name and currency unit of countries using series code as FP.CPI.TOTL"}, {"role": "assistant", "content": "SELECT T1.TableName, T1.CurrencyUnit FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.SeriesCode = 'FP.CPI.TOTL'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE ranking_system (\n id integer PRIMARY KEY,\n system_name text\n);\nCREATE TABLE ranking_criteria (\n id integer PRIMARY KEY,\n ranking_system_id integer,\n criteria_name text\n);\nCREATE TABLE university (\n id integer PRIMARY KEY,\n country_id integer,\n university_name text\n);\nCREATE TABLE university_ranking_year (\n university_id integer,\n ranking_criteria_id integer,\n year integer,\n score integer\n);\nCREATE TABLE university_year (\n university_id integer,\n year integer,\n num_students integer,\n student_staff_ratio real,\n pct_international_students integer,\n pct_female_students integer\n);\n-- 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\n\nHint: In 2016 refers to year = 2016; name of the university refers to university_name; in Australia refers to country_name = 'Australia'; in Citations criteria refers to criteria_name = 'Citations'; highest score refers to MAX(score)\n\nQuestion: In 2016, what is the name of the university in Australia with the highest score in Citations criteria?"}, {"role": "assistant", "content": "SELECT T3.university_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id INNER JOIN country AS T4 ON T4.id = T3.country_id WHERE T1.criteria_name = 'Citations' AND T2.year = 2016 AND T1.id = 4 AND T4.country_name = 'Australia' ORDER BY T2.score DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n origin integer PRIMARY KEY,\n country text\n);\nCREATE TABLE price (\n ID integer PRIMARY KEY,\n price real\n);\nCREATE TABLE data (\n ID integer PRIMARY KEY,\n mpg real,\n cylinders integer,\n displacement real,\n horsepower integer,\n weight integer,\n acceleration real,\n model integer,\n car_name text\n);\nCREATE TABLE production (\n ID integer PRIMARY KEY,\n model_year integer PRIMARY KEY,\n country integer\n);\n-- foreign keys: data.ID -> price.ID; production.ID -> price.ID; production.ID -> data.ID; production.country -> country.origin\n\nHint: produced in 1975 refers to model_year = 1975; names refers to car_name; producing countries refers to country; the maximum number of cylinders refers to max(cylinders)\n\nQuestion: Among the cars produced in 1975, provide IDs, names, and producing countries of the cars with the maximum number of cylinders."}, {"role": "assistant", "content": "SELECT T1.ID, T1.car_name, T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T2.model_year = 1975 ORDER BY T1.cylinders DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"school\" (\n\"School_ID\" int,\n\"School\" text,\n\"Location\" text,\n\"Enrollment\" real,\n\"Founded\" real,\n\"Denomination\" text,\n\"Boys_or_Girls\" text,\n\"Day_or_Boarding\" text,\n\"Year_Entered_Competition\" real,\n\"School_Colors\" text,\nPRIMARY KEY (\"School_Id\")\n);\n\nQuestion: What are the enrollments of schools whose denomination is not \"Catholic\"?"}, {"role": "assistant", "content": "SELECT Enrollment FROM school WHERE Denomination != \"Catholic\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`address_details` VARCHAR(255)\n);\n\nQuestion: Find the average price of all product clothes."}, {"role": "assistant", "content": "SELECT avg(product_price) FROM products WHERE product_type_code = 'Clothes'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Allergy_Type (\n Allergy \t\t VARCHAR(20) PRIMARY KEY,\n AllergyType \t VARCHAR(20)\n);\n\ncreate table Has_Allergy (\n StuID \t\t INTEGER,\n Allergy \t\t VARCHAR(20),\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)\n);\n\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\nQuestion: What is the total number of students?"}, {"role": "assistant", "content": "SELECT count(*) FROM Student"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE state (\n StateCode text PRIMARY KEY,\n State text,\n Region text\n);\nCREATE TABLE callcenterlogs (\n Date received date,\n Complaint ID text PRIMARY KEY,\n rand client text,\n phonefinal text,\n vru+line text,\n call_id integer,\n priority integer,\n type text,\n outcome text,\n server text,\n ser_start text,\n ser_exit text,\n ser_time text\n);\nCREATE TABLE client (\n client_id text PRIMARY KEY,\n sex text,\n day integer,\n month integer,\n year integer,\n age integer,\n social text,\n first text,\n middle text,\n last text,\n phone text,\n email text,\n address_1 text,\n address_2 text,\n city text,\n state text,\n zipcode integer,\n district_id integer\n);\nCREATE TABLE district (\n district_id integer PRIMARY KEY,\n city text,\n state_abbrev text,\n division text\n);\nCREATE TABLE events (\n Date received date,\n Product text,\n Sub-product text,\n Issue text,\n Sub-issue text,\n Consumer complaint narrative text,\n Tags text,\n Consumer consent provided? text,\n Submitted via text,\n Date sent to company text,\n Company response to consumer text,\n Timely response? text,\n Consumer disputed? text,\n Complaint ID text PRIMARY KEY,\n Client_ID text PRIMARY KEY\n);\nCREATE TABLE reviews (\n Date date PRIMARY KEY,\n Stars integer,\n Reviews text,\n Product text,\n district_id integer\n);\n-- foreign keys: callcenterlogs.rand client -> client.client_id; client.district_id -> district.district_id; district.state_abbrev -> state.StateCode; events.Client_ID -> client.client_id; events.Complaint ID -> callcenterlogs.Complaint ID; reviews.district_id -> district.district_id\n\nHint: average age = avg(age where type = 'TT')\n\nQuestion: What is the average age of clients whose complaint type is \"TT\"?"}, {"role": "assistant", "content": "SELECT AVG(T1.age) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.type = 'TT'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE location (\n locationID integer PRIMARY KEY,\n locationcity text,\n address text,\n state text,\n zipcode integer,\n officephone text\n);\nCREATE TABLE position (\n positionID integer PRIMARY KEY,\n positiontitle text,\n educationrequired text,\n minsalary text,\n maxsalary text\n);\nCREATE TABLE employee (\n ssn text PRIMARY KEY,\n lastname text,\n firstname text,\n hiredate text,\n salary text,\n gender text,\n performance text,\n positionID integer,\n locationID integer\n);\n-- foreign keys: employee.positionID -> position.positionID; employee.locationID -> location.locationID\n\nHint: Trainees is a position title; California refers to state = 'NY'\n\nQuestion: Among the employees who are Trainees, how many of them work in New York?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T3.positiontitle = 'Trainee' AND T2.state = 'NY'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Ref_Payment_Methods (\npayment_method_code CHAR(10) NOT NULL,\npayment_method_description VARCHAR(80),\nPRIMARY KEY (payment_method_code),\nUNIQUE (payment_method_code)\n);\n\nQuestion: What are the phone and email for customer Harold?"}, {"role": "assistant", "content": "SELECT Customer_Phone , Customer_Email_Address FROM CUSTOMERS WHERE Customer_Name = \"Harold\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Air Carriers (\n Code integer PRIMARY KEY,\n Description text\n);\nCREATE TABLE Airports (\n Code text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Airlines (\n FL_DATE text,\n OP_CARRIER_AIRLINE_ID integer,\n TAIL_NUM text,\n OP_CARRIER_FL_NUM integer,\n ORIGIN_AIRPORT_ID integer,\n ORIGIN_AIRPORT_SEQ_ID integer,\n ORIGIN_CITY_MARKET_ID integer,\n ORIGIN text,\n DEST_AIRPORT_ID integer,\n DEST_AIRPORT_SEQ_ID integer,\n DEST_CITY_MARKET_ID integer,\n DEST text,\n CRS_DEP_TIME integer,\n DEP_TIME integer,\n DEP_DELAY integer,\n DEP_DELAY_NEW integer,\n ARR_TIME integer,\n ARR_DELAY integer,\n ARR_DELAY_NEW integer,\n CANCELLED integer,\n CANCELLATION_CODE text,\n CRS_ELAPSED_TIME integer,\n ACTUAL_ELAPSED_TIME integer,\n CARRIER_DELAY integer,\n WEATHER_DELAY integer,\n NAS_DELAY integer,\n SECURITY_DELAY integer,\n LATE_AIRCRAFT_DELAY integer\n);\n-- foreign keys: Airlines.OP_CARRIER_AIRLINE_ID -> Air Carriers.Code; Airlines.DEST -> Airports.Code; Airlines.ORIGIN -> Airports.Code\n\nHint: IATA code refers to Code; Anita Bay Airport in Anita Bay, Alaska refers to Description = 'Anita Bay, AK: Anita Bay Airport';\n\nQuestion: What is the IATA code of the Anita Bay Airport in Anita Bay, Alaska?"}, {"role": "assistant", "content": "SELECT Code FROM Airports WHERE Description = 'Anita Bay, AK: Anita Bay Airport'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Document_Types` (\n`document_type_code` VARCHAR(10) PRIMARY KEY,\n`document_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Documents` (\n`document_id` INTEGER PRIMARY KEY,\n`document_type_code` VARCHAR(10),\n`grant_id` INTEGER NOT NULL,\n`sent_date` DATETIME NOT NULL,\n`response_received_date` DATETIME NOT NULL,\n`other_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ),\nFOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` )\n);\nCREATE TABLE `Grants` (\n`grant_id` INTEGER PRIMARY KEY,\n`organisation_id` INTEGER NOT NULL,\n`grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0,\n`grant_start_date` DATETIME NOT NULL,\n`grant_end_date` DATETIME NOT NULL,\n`other_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Organisation_Types` (\n`organisation_type` VARCHAR(10) PRIMARY KEY,\n`organisation_type_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Organisations` (\n`organisation_id` INTEGER PRIMARY KEY,\n`organisation_type` VARCHAR(10) NOT NULL,\n`organisation_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` )\n);\nCREATE TABLE `Project_Outcomes` (\n`project_id` INTEGER NOT NULL,\n`outcome_code` VARCHAR(10) NOT NULL,\n`outcome_details` VARCHAR(255),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` )\n);\nCREATE TABLE `Project_Staff` (\n`staff_id` DOUBLE PRIMARY KEY,\n`project_id` INTEGER NOT NULL,\n`role_code` VARCHAR(10) NOT NULL,\n`date_from` DATETIME,\n`date_to` DATETIME,\n`other_details` VARCHAR(255),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` )\n);\nCREATE TABLE `Projects` (\n`project_id` INTEGER PRIMARY KEY,\n`organisation_id` INTEGER NOT NULL,\n`project_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Research_Outcomes` (\n`outcome_code` VARCHAR(10) PRIMARY KEY,\n`outcome_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Research_Staff` (\n`staff_id` INTEGER PRIMARY KEY,\n`employer_organisation_id` INTEGER NOT NULL,\n`staff_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Staff_Roles` (\n`role_code` VARCHAR(10) PRIMARY KEY,\n`role_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Tasks` (\n`task_id` INTEGER PRIMARY KEY,\n`project_id` INTEGER NOT NULL,\n`task_details` VARCHAR(255) NOT NULL,\n`eg Agree Objectives` VARCHAR(1),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` )\n);\n\nQuestion: What roles did staff members play between '2003-04-19 15:06:20' and '2016-03-15 00:33:18'?"}, {"role": "assistant", "content": "SELECT role_code FROM Project_Staff WHERE date_from > '2003-04-19 15:06:20' AND date_to < '2016-03-15 00:33:18'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nHint: 'Jason trap' is a title of a film; cast means actor; actor refers to first_name, last_name\n\nQuestion: Provide the cast for the film \"Jason trap\"."}, {"role": "assistant", "content": "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.title = 'JASON TRAP'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE address_status (\n status_id integer PRIMARY KEY,\n address_status text\n);\nCREATE TABLE author (\n author_id integer PRIMARY KEY,\n author_name text\n);\nCREATE TABLE book_language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n street_number text,\n street_name text,\n city text,\n country_id integer\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n email text\n);\nCREATE TABLE customer_address (\n customer_id integer PRIMARY KEY,\n address_id integer PRIMARY KEY,\n status_id integer\n);\nCREATE TABLE order_status (\n status_id integer PRIMARY KEY,\n status_value text\n);\nCREATE TABLE publisher (\n publisher_id integer PRIMARY KEY,\n publisher_name text\n);\nCREATE TABLE book (\n book_id integer PRIMARY KEY,\n title text,\n isbn13 text,\n language_id integer,\n num_pages integer,\n publication_date date,\n publisher_id integer\n);\nCREATE TABLE book_author (\n book_id integer PRIMARY KEY,\n author_id integer PRIMARY KEY\n);\nCREATE TABLE shipping_method (\n method_id integer PRIMARY KEY,\n method_name text,\n cost real\n);\nCREATE TABLE cust_order (\n order_id integer PRIMARY KEY,\n order_date datetime,\n customer_id integer,\n shipping_method_id integer,\n dest_address_id integer\n);\nCREATE TABLE order_history (\n history_id integer PRIMARY KEY,\n order_id integer,\n status_id integer,\n status_date datetime\n);\nCREATE TABLE order_line (\n line_id integer PRIMARY KEY,\n order_id integer,\n book_id integer,\n price real\n);\n-- 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\n\nHint: language refers to language_name; books with price less than 20% of the average price refers to price < Multiply (AVG(price), 0.2)\n\nQuestion: What are the language and title of the ordered books with price less than 20% of the average price of all ordered books?"}, {"role": "assistant", "content": "SELECT DISTINCT T3.language_name, T2.title FROM order_line AS T1 INNER JOIN book AS T2 ON T1.book_id = T2.book_id INNER JOIN book_language AS T3 ON T3.language_id = T2.language_id WHERE T1.price * 100 < ( SELECT AVG(price) FROM order_line ) * 20"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"product\" (\n\"product_id\" int,\n\"product\" text,\n\"dimensions\" text,\n\"dpi\" real,\n\"pages_per_minute_color\" real,\n\"max_page_size\" text,\n\"interface\" text,\nPRIMARY KEY (\"product_id\")\n);\n\nCREATE TABLE \"store\" (\n\"Store_ID\" int,\n\"Store_Name\" text,\n\"Type\" text,\n\"Area_size\" real,\n\"Number_of_product_category\" real,\n\"Ranking\" int,\nPRIMARY KEY (\"Store_ID\")\n);\n\nCREATE TABLE \"district\" (\n\"District_ID\" int,\n\"District_name\" text,\n\"Headquartered_City\" text,\n\"City_Population\" real,\n\"City_Area\" real,\nPRIMARY KEY (\"District_ID\")\n);\n\nQuestion: What are the names of all districts with a city area greater than 10 or have more than 100000 people living there?"}, {"role": "assistant", "content": "SELECT district_name FROM district WHERE city_area > 10 OR City_Population > 100000"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`line_1_number_building` VARCHAR(80),\n`city` VARCHAR(50),\n`zip_postcode` VARCHAR(20),\n`state_province_county` VARCHAR(50),\n`country` VARCHAR(50)\n);\n\nQuestion: What are the names of the states that have 2 to 4 employees living there?"}, {"role": "assistant", "content": "SELECT T1.state_province_county FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id GROUP BY T1.state_province_county HAVING count(*) BETWEEN 2 AND 4;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE course (\n course_id integer PRIMARY KEY,\n name text,\n credit integer,\n diff integer\n);\nCREATE TABLE prof (\n prof_id integer PRIMARY KEY,\n gender text,\n first_name text,\n last_name text,\n email text,\n popularity integer,\n teachingability integer,\n graduate_from text\n);\nCREATE TABLE RA (\n student_id integer PRIMARY KEY,\n capability integer,\n prof_id integer PRIMARY KEY,\n salary text\n);\nCREATE TABLE registration (\n course_id integer PRIMARY KEY,\n student_id integer PRIMARY KEY,\n grade text,\n sat integer\n);\nCREATE TABLE student (\n student_id integer PRIMARY KEY,\n f_name text,\n l_name text,\n phone_number text,\n email text,\n intelligence integer,\n gpa real,\n type text\n);\n-- foreign keys: RA.student_id -> student.student_id; RA.prof_id -> prof.prof_id; registration.student_id -> student.student_id; registration.course_id -> course.course_id\n\nHint: full names = f_name, l_name; research assistant refers to the student who serves for research where the abbreviation is RA; unpaid research assistant refers to salary = 'free';\n\nQuestion: Provide the full names and emails of unpaid research assistants."}, {"role": "assistant", "content": "SELECT T2.f_name, T2.l_name, T2.email FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'free'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Episode (\n episode_id text PRIMARY KEY,\n season integer,\n episode integer,\n number_in_series integer,\n title text,\n summary text,\n air_date text,\n episode_image text,\n rating real,\n votes integer\n);\nCREATE TABLE Person (\n name text PRIMARY KEY,\n birthdate text,\n birth_name text,\n birth_place text,\n birth_region text,\n birth_country text,\n height_meters real,\n nickname text\n);\nCREATE TABLE Award (\n award_id integer PRIMARY KEY,\n organization text,\n year integer,\n award_category text,\n award text,\n person text,\n role text,\n episode_id text,\n season text,\n song text,\n result text\n);\nCREATE TABLE Character_Award (\n award_id integer,\n character text\n);\nCREATE TABLE Credit (\n episode_id text,\n category text,\n person text,\n role text,\n credited text\n);\nCREATE TABLE Keyword (\n episode_id text PRIMARY KEY,\n keyword text PRIMARY KEY\n);\nCREATE TABLE Vote (\n episode_id text,\n stars integer,\n votes integer,\n percent real\n);\n-- 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\n\nHint: 10-star refers to stars = 10\n\nQuestion: What is the number of votes for 10-star for the episode that has the keyword \"reference to the fantastic four\"?"}, {"role": "assistant", "content": "SELECT T2.votes FROM Keyword AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 AND T1.keyword = 'reference to the fantastic four';"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n Customer Names text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Product Name text\n);\nCREATE TABLE Regions (\n StateCode text PRIMARY KEY,\n State text,\n Region text\n);\nCREATE TABLE Sales Team (\n SalesTeamID integer PRIMARY KEY,\n Sales Team text,\n Region text\n);\nCREATE TABLE Store Locations (\n StoreID integer PRIMARY KEY,\n City Name text,\n County text,\n StateCode text,\n State text,\n Type text,\n Latitude real,\n Longitude real,\n AreaCode integer,\n Population integer,\n Household Income integer,\n Median Income integer,\n Land Area integer,\n Water Area integer,\n Time Zone text\n);\nCREATE TABLE Sales Orders (\n OrderNumber text PRIMARY KEY,\n Sales Channel text,\n WarehouseCode text,\n ProcuredDate text,\n OrderDate text,\n ShipDate text,\n DeliveryDate text,\n CurrencyCode text,\n _SalesTeamID integer,\n _CustomerID integer,\n _StoreID integer,\n _ProductID integer,\n Order Quantity integer,\n Discount Applied real,\n Unit Price text,\n Unit Cost text\n);\n-- 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\n\nHint: least purchased product refers to Min(Count(Product Name)); 'Santa Clarita' is the City\n\nQuestion: What is the least purchased product by stores in the city of Santa Clarita?"}, {"role": "assistant", "content": "SELECT T1.`Product Name` 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 T3.`City Name` = 'Santa Clarita' GROUP BY T1.`Product Name` ORDER BY COUNT(T1.`Product Name`) ASC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE Customers (\nCustomer_ID INTEGER NOT NULL,\nCustomer_Details VARCHAR(255) NOT NULL,\nPRIMARY KEY (Customer_ID)\n);\n\nQuestion: Of all the claims, what was the earliest date when any claim was made?"}, {"role": "assistant", "content": "SELECT Date_Claim_Made FROM Claims ORDER BY Date_Claim_Made ASC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE sales_in_weather (\n date date PRIMARY KEY,\n store_nbr integer PRIMARY KEY,\n item_nbr integer PRIMARY KEY,\n units integer\n);\nCREATE TABLE weather (\n station_nbr integer PRIMARY KEY,\n date date PRIMARY KEY,\n tmax integer,\n tmin integer,\n tavg integer,\n depart integer,\n dewpoint integer,\n wetbulb integer,\n heat integer,\n cool integer,\n sunrise text,\n sunset text,\n codesum text,\n snowfall real,\n preciptotal real,\n stnpressure real,\n sealevel real,\n resultspeed real,\n resultdir integer,\n avgspeed real\n);\nCREATE TABLE relation (\n store_nbr integer PRIMARY KEY,\n station_nbr integer\n);\n-- foreign keys: relation.station_nbr -> weather.station_nbr; relation.store_nbr -> sales_in_weather.store_nbr\n\nHint: store no.19 refers to store_nbr = 19; on 2013/2/24 refers to date = '2013-02-24'; sea level status refers to sealevel\n\nQuestion: Show the sea level status recorded by the weather station of store no.19 on 2013/2/24."}, {"role": "assistant", "content": "SELECT T1.sealevel FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2013-02-24' AND T2.store_nbr = 19"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE cars (\n id integer PRIMARY KEY,\n train_id integer,\n position integer,\n shape text,\n len text,\n sides text,\n roof text,\n wheels integer,\n load_shape text,\n load_num integer\n);\nCREATE TABLE trains (\n id integer PRIMARY KEY,\n direction text\n);\n-- foreign keys: cars.train_id -> trains.id\n\nHint: at least 4 cars refers to trailPosi > = 4; calculation = MULTIPLY(DIVIDE(count(trailPosi > = 4 then id), count(id)), 100)\n\nQuestion: What is the percentage of all the trains with at least 4 cars? List the directions of the said trains."}, {"role": "assistant", "content": "SELECT CAST(COUNT(CASE WHEN T2.trailPosi >= 4 THEN T1.id ELSE NULL END) AS REAL) * 100 / COUNT(T1.id) FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars GROUP BY train_id ) AS T2 ON T1.id = T2.train_id UNION ALL SELECT T1.direction FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars t GROUP BY train_id ) AS T2 ON T1.id = T2.train_id AND T2.trailPosi >= 4"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"county_public_safety\" (\n\"County_ID\" int,\n\"Name\" text,\n\"Population\" int,\n\"Police_officers\" int,\n\"Residents_per_officer\" int,\n\"Case_burden\" int,\n\"Crime_rate\" real,\n\"Police_force\" text,\n\"Location\" text,\nPRIMARY KEY (\"County_ID\")\n);\n\nCREATE TABLE \"city\" (\n\"City_ID\" int,\n\"County_ID\" int,\n\"Name\" text,\n\"White\" real,\n\"Black\" real,\n\"Amerindian\" real,\n\"Asian\" real,\n\"Multiracial\" real,\n\"Hispanic\" real,\nPRIMARY KEY (\"City_ID\"),\nFOREIGN KEY (\"County_ID\") REFERENCES \"county_public_safety\"(\"County_ID\")\n);\n\nQuestion: Show the case burden of counties in descending order of population."}, {"role": "assistant", "content": "SELECT Case_burden FROM county_public_safety ORDER BY Population DESC"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Addresses (\naddress_id INTEGER NOT NULL,\nline_1 VARCHAR(80),\nline_2 VARCHAR(80),\ncity VARCHAR(50),\nzip_postcode CHAR(20),\nstate_province_county VARCHAR(50),\ncountry VARCHAR(50),\nPRIMARY KEY (address_id)\n);\n\nQuestion: What is the id of the candidate who most recently accessed the course?"}, {"role": "assistant", "content": "SELECT candidate_id FROM candidate_assessments ORDER BY assessment_date DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Episode (\n episode_id text PRIMARY KEY,\n series text,\n season integer,\n episode integer,\n number_in_series integer,\n title text,\n summary text,\n air_date date,\n episode_image text,\n rating real,\n votes integer\n);\nCREATE TABLE Keyword (\n episode_id text PRIMARY KEY,\n keyword text PRIMARY KEY\n);\nCREATE TABLE Person (\n person_id text PRIMARY KEY,\n name text,\n birthdate date,\n birth_name text,\n birth_place text,\n birth_region text,\n birth_country text,\n height_meters real,\n nickname text\n);\nCREATE TABLE Award (\n award_id integer PRIMARY KEY,\n organization text,\n year integer,\n award_category text,\n award text,\n series text,\n episode_id text,\n person_id text,\n role text,\n result text\n);\nCREATE TABLE Credit (\n episode_id text PRIMARY KEY,\n person_id text PRIMARY KEY,\n category text,\n role text,\n credited text\n);\nCREATE TABLE Vote (\n episode_id text,\n stars integer,\n votes integer,\n percent real\n);\n-- foreign keys: Keyword.episode_id -> Episode.episode_id; Award.person_id -> Person.person_id; Award.episode_id -> Episode.episode_id; Credit.person_id -> Person.person_id; Credit.episode_id -> Episode.episode_id; Vote.episode_id -> Episode.episode_id\n\nHint: credited refers to credited = 'true'\n\nQuestion: For how many times was Park Dietz credited?"}, {"role": "assistant", "content": "SELECT COUNT(T3.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'true' AND T3.name = 'Park Dietz'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE app_all (\n app_id integer PRIMARY KEY\n);\nCREATE TABLE app_events (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_events_relevant (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_labels (\n app_id integer,\n label_id integer\n);\nCREATE TABLE events (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE events_relevant (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE gender_age (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE gender_age_test (\n device_id integer PRIMARY KEY\n);\nCREATE TABLE gender_age_train (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE label_categories (\n label_id integer PRIMARY KEY,\n category text\n);\nCREATE TABLE phone_brand_device_model2 (\n device_id integer PRIMARY KEY,\n phone_brand text PRIMARY KEY,\n device_model text PRIMARY KEY\n);\nCREATE TABLE sample_submission (\n device_id integer PRIMARY KEY,\n F23- real,\n F24-26 real,\n F27-28 real,\n F29-32 real,\n F33-42 real,\n F43+ real,\n M22- real,\n M23-26 real,\n M27-28 real,\n M29-31 real,\n M32-38 real,\n M39+ real\n);\n-- 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\n\nQuestion: How many users who are between 20 and 60 use phone brand of TCL?"}, {"role": "assistant", "content": "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.age BETWEEN 20 AND 60 AND T2.phone_brand = 'TCL'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n/* \n * SQL scripts for CS61 Intro to SQL lectures\n * FILENAME SOCCER2.SQL\n */\n\nDROP TABLE IF EXISTS Player;\nDROP TABLE IF EXISTS Tryout;\nDROP TABLE IF EXISTS College;\n\nCREATE TABLE \tCollege \n ( cName \tvarchar(20) NOT NULL,\n state \tvarchar(2),\n enr \tnumeric(5,0),\n PRIMARY KEY (cName)\n );\n\nCREATE TABLE \tPlayer\n ( pID\t\t\tnumeric(5,0) NOT NULL,\n \tpName \tvarchar(20),\n yCard \tvarchar(3),\n HS \tnumeric(5,0),\n PRIMARY KEY (pID)\n );\n\nCREATE TABLE \tTryout\n ( pID\t\t\tnumeric(5,0),\n \tcName \tvarchar(20),\n pPos \tvarchar(8),\n decision varchar(3),\n PRIMARY KEY (pID, cName),\n FOREIGN KEY (pID) REFERENCES Player(pID),\n FOREIGN KEY (cName) REFERENCES College(cName)\n );\n\n/* note that \"left\" and \"right\" are reserved words in SQL */\n\nQuestion: What are the names of the schools with the top 3 largest class sizes?"}, {"role": "assistant", "content": "SELECT cName FROM college ORDER BY enr DESC LIMIT 3"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE ranking_system (\n id integer PRIMARY KEY,\n system_name text\n);\nCREATE TABLE ranking_criteria (\n id integer PRIMARY KEY,\n ranking_system_id integer,\n criteria_name text\n);\nCREATE TABLE university (\n id integer PRIMARY KEY,\n country_id integer,\n university_name text\n);\nCREATE TABLE university_ranking_year (\n university_id integer,\n ranking_criteria_id integer,\n year integer,\n score integer\n);\nCREATE TABLE university_year (\n university_id integer,\n year integer,\n num_students integer,\n student_staff_ratio real,\n pct_international_students integer,\n pct_female_students integer\n);\n-- 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\n\nHint: in 2011 refers to year 2011; in Australia refers to country_name = 'Australia'; student staff ratio of over 15 refers to student_staff_ratio > 15\n\nQuestion: Among the universities in Australia, how many of them have a student staff ratio of over 15 in 2011?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T3.country_name = 'Australia' AND T2.student_staff_ratio > 15 AND T2.year = 2011"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"wrestler\" (\n\"Wrestler_ID\" int,\n\"Name\" text,\n\"Reign\" text,\n\"Days_held\" text,\n\"Location\" text,\n\"Event\" text,\nPRIMARY KEY (\"Wrestler_ID\")\n);\n\nCREATE TABLE \"Elimination\" (\n\"Elimination_ID\" text,\n\"Wrestler_ID\" text,\n\"Team\" text,\n\"Eliminated_By\" text,\n\"Elimination_Move\" text,\n\"Time\" text,\nPRIMARY KEY (\"Elimination_ID\"),\nFOREIGN KEY (\"Wrestler_ID\") REFERENCES \"wrestler\"(\"Wrestler_ID\")\n);\n\nQuestion: Give the names of wrestlers and their elimination moves."}, {"role": "assistant", "content": "SELECT T2.Name , T1.Elimination_Move FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"train\" (\n \"id\" int,\n \"train_number\" int,\n \"name\" text,\n \"origin\" text,\n \"destination\" text,\n \"time\" text,\n \"interval\" text,\n primary key (\"id\")\n);\n\nCREATE TABLE \"station\" (\n \"id\" int,\n \"network_name\" text,\n \"services\" text,\n \"local_authority\" text,\n primary key (\"id\")\n);\n\nCREATE TABLE \"route\" (\n \"train_id\" int,\n \"station_id\" int,\n primary key (\"train_id\", \"station_id\"),\n foreign key (\"train_id\") references `train`(\"id\"),\n foreign key (\"station_id\") references `station`(\"id\")\n);\n\nCREATE TABLE \"weekly_weather\" (\n \"station_id\" int,\n \"day_of_week\" text,\n \"high_temperature\" int,\n \"low_temperature\" int,\n \"precipitation\" real,\n \"wind_speed_mph\" int,\n primary key (\"station_id\", \"day_of_week\"),\n foreign key (\"station_id\") references \"station\"(\"id\")\n);\n\nQuestion: Find the name of the train whose route runs through greatest number of stations."}, {"role": "assistant", "content": "SELECT t1.name FROM train AS t1 JOIN route AS t2 ON t1.id = t2.train_id GROUP BY t2.train_id ORDER BY count(*) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Scientists (\n SSN int,\n Name Char(30) not null,\n Primary Key (SSN)\n);\n\nCreate table Projects (\n Code Char(4),\n Name Char(50) not null,\n Hours int,\n Primary Key (Code)\n);\n\t\ncreate table AssignedTo (\n Scientist int not null,\n Project char(4) not null,\n Primary Key (Scientist, Project),\n Foreign Key (Scientist) references Scientists (SSN),\n Foreign Key (Project) references Projects (Code)\n);\n\nQuestion: Find the names of scientists who are not working on the project with the highest hours."}, {"role": "assistant", "content": "SELECT name FROM scientists EXCEPT SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT max(hours) FROM projects)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE chapters (\n id integer PRIMARY KEY,\n Act integer,\n Scene integer,\n Description text,\n work_id integer\n);\nCREATE TABLE characters (\n id integer PRIMARY KEY,\n CharName text,\n Abbrev text,\n Description text\n);\nCREATE TABLE paragraphs (\n id integer PRIMARY KEY,\n ParagraphNum integer,\n PlainText text,\n character_id integer,\n chapter_id integer\n);\nCREATE TABLE works (\n id integer PRIMARY KEY,\n Title text,\n LongTitle text,\n Date integer,\n GenreType text\n);\n\nHint: chapter with the longest number of paragraphs refers to max(ParagraphNum)\n\nQuestion: What is the description of the chapter with the longest number of paragraphs?"}, {"role": "assistant", "content": "SELECT T2.Description FROM paragraphs AS T1 INNER JOIN chapters AS T2 ON T1.chapter_id = T2.id ORDER BY T1.ParagraphNum DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE \"list\" ( \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Grade\" INTEGER, \n\t\"Classroom\" INTEGER,\n\tPRIMARY KEY(LastName, FirstName)\n);\nCREATE TABLE \"teachers\" ( \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Classroom\" INTEGER,\n\tPRIMARY KEY(LastName, FirstName)\n);\n\nQuestion: Find the last names of students studying in room 111."}, {"role": "assistant", "content": "SELECT lastname FROM list WHERE classroom = 111"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE customer (\n c_custkey integer PRIMARY KEY,\n c_mktsegment text,\n c_nationkey integer,\n c_name text,\n c_address text,\n c_phone text,\n c_acctbal real,\n c_comment text\n);\nCREATE TABLE lineitem (\n l_shipdate date,\n l_orderkey integer PRIMARY KEY,\n l_discount real,\n l_extendedprice real,\n l_suppkey integer,\n l_quantity integer,\n l_returnflag text,\n l_partkey integer,\n l_linestatus text,\n l_tax real,\n l_commitdate date,\n l_receiptdate date,\n l_shipmode text,\n l_linenumber integer PRIMARY KEY,\n l_shipinstruct text,\n l_comment text\n);\nCREATE TABLE nation (\n n_nationkey integer PRIMARY KEY,\n n_name text,\n n_regionkey integer,\n n_comment text\n);\nCREATE TABLE orders (\n o_orderdate date,\n o_orderkey integer PRIMARY KEY,\n o_custkey integer,\n o_orderpriority text,\n o_shippriority integer,\n o_clerk text,\n o_orderstatus text,\n o_totalprice real,\n o_comment text\n);\nCREATE TABLE part (\n p_partkey integer PRIMARY KEY,\n p_type text,\n p_size integer,\n p_brand text,\n p_name text,\n p_container text,\n p_mfgr text,\n p_retailprice real,\n p_comment text\n);\nCREATE TABLE partsupp (\n ps_partkey integer PRIMARY KEY,\n ps_suppkey integer PRIMARY KEY,\n ps_supplycost real,\n ps_availqty integer,\n ps_comment text\n);\nCREATE TABLE region (\n r_regionkey integer PRIMARY KEY,\n r_name text,\n r_comment text\n);\nCREATE TABLE supplier (\n s_suppkey integer PRIMARY KEY,\n s_nationkey integer,\n s_comment text,\n s_name text,\n s_address text,\n s_phone text,\n s_acctbal real\n);\n-- foreign keys: customer.c_nationkey -> nation.n_nationkey; lineitem.l_partkey -> partsupp.ps_partkey; lineitem.l_suppkey -> partsupp.ps_suppkey; lineitem.l_orderkey -> orders.o_orderkey; nation.n_regionkey -> region.r_regionkey; orders.o_custkey -> customer.c_custkey; partsupp.ps_suppkey -> supplier.s_suppkey; partsupp.ps_partkey -> part.p_partkey; supplier.s_nationkey -> nation.n_nationkey\n\nHint: name of the customer refers to c_name; total order price of 199180.63 refers o_totalprice = 199180.63; marketing segment refers to c_mktsegment;\n\nQuestion: What is the name and marketing segment of the customer with the total order price of 199180.63?"}, {"role": "assistant", "content": "SELECT T2.c_name, T2.c_mktsegment FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice = 199180.63"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: Arizona refers to state = 'AZ'; still running refers to active = 'true';\n\nQuestion: Among the Yelp_Businesses in Arizona, how many of them are still running?"}, {"role": "assistant", "content": "SELECT COUNT(business_id) FROM Business WHERE state LIKE 'AZ' AND active LIKE 'True'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE all_star (\n player_id TEXT,\n year INTEGER,\n game_num INTEGER,\n game_id TEXT,\n team_id TEXT,\n league_id TEXT,\n gp NUMERIC,\n starting_pos NUMERIC,\n foreign key (player_id) references player(player_id)\n);\n\nQuestion: Which team offers the lowest average salary? Give me the name and id of the team."}, {"role": "assistant", "content": "SELECT T1.name , T1.team_id FROM team AS T1 JOIN salary AS T2 ON T1.team_id = T2.team_id GROUP BY T1.team_id ORDER BY avg(T2.salary) ASC LIMIT 1;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Name text,\n Price real\n);\nCREATE TABLE Sales (\n SalesID integer PRIMARY KEY,\n SalesPersonID integer,\n CustomerID integer,\n ProductID integer,\n Quantity integer\n);\n-- foreign keys: Sales.ProductID -> Products.ProductID; Sales.CustomerID -> Customers.CustomerID; Sales.SalesPersonID -> Employees.EmployeeID\n\nQuestion: How many sales people are handling all the customers?"}, {"role": "assistant", "content": "SELECT COUNT(EmployeeID) FROM Employees"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE app_all (\n app_id integer PRIMARY KEY\n);\nCREATE TABLE app_events (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_events_relevant (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_labels (\n app_id integer,\n label_id integer\n);\nCREATE TABLE events (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE events_relevant (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE gender_age (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE gender_age_test (\n device_id integer PRIMARY KEY\n);\nCREATE TABLE gender_age_train (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE label_categories (\n label_id integer PRIMARY KEY,\n category text\n);\nCREATE TABLE phone_brand_device_model2 (\n device_id integer PRIMARY KEY,\n phone_brand text PRIMARY KEY,\n device_model text PRIMARY KEY\n);\nCREATE TABLE sample_submission (\n device_id integer PRIMARY KEY,\n F23- real,\n F24-26 real,\n F27-28 real,\n F29-32 real,\n F33-42 real,\n F43+ real,\n M22- real,\n M23-26 real,\n M27-28 real,\n M29-31 real,\n M32-38 real,\n M39+ real\n);\n-- 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\n\nHint: at 23:33:34 on 2016/5/6 refers to timestamp = '2016/5/6 23:33:34'; installed refers to is_installed = '1';\n\nQuestion: For the event which happened at 23:33:34 on 2016/5/6, how many installed apps were involved?"}, {"role": "assistant", "content": "SELECT COUNT(T1.event_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE SUBSTR(T2.`timestamp`, 1, 10) = '2016-05-06' AND T1.is_installed = '1'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"driver\" (\n\"Driver_ID\" int,\n\"Name\" text,\n\"Party\" text,\n\"Home_city\" text,\n\"Age\" int,\nPRIMARY KEY (\"Driver_ID\")\n);\n\nCREATE TABLE \"school\" (\n\"School_ID\" int,\n\"Grade\" text,\n\"School\" text,\n\"Location\" text,\n\"Type\" text,\nPRIMARY KEY (\"School_ID\")\n);\n\nQuestion: Show all home cities except for those having a driver older than 40."}, {"role": "assistant", "content": "SELECT home_city FROM driver EXCEPT SELECT home_city FROM driver WHERE age > 40"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"festival_detail\" (\n\"Festival_ID\" int,\n\"Festival_Name\" text,\n\"Chair_Name\" text,\n\"Location\" text,\n\"Year\" int,\n\"Num_of_Audience\" int,\nPRIMARY KEY (\"Festival_ID\")\n);\n\nQuestion: What are the total number of the audiences who visited any of the festivals?"}, {"role": "assistant", "content": "SELECT sum(Num_of_Audience) FROM festival_detail"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE state (\n StateCode text PRIMARY KEY,\n State text,\n Region text\n);\nCREATE TABLE callcenterlogs (\n Date received date,\n Complaint ID text PRIMARY KEY,\n rand client text,\n phonefinal text,\n vru+line text,\n call_id integer,\n priority integer,\n type text,\n outcome text,\n server text,\n ser_start text,\n ser_exit text,\n ser_time text\n);\nCREATE TABLE client (\n client_id text PRIMARY KEY,\n sex text,\n day integer,\n month integer,\n year integer,\n age integer,\n social text,\n first text,\n middle text,\n last text,\n phone text,\n email text,\n address_1 text,\n address_2 text,\n city text,\n state text,\n zipcode integer,\n district_id integer\n);\nCREATE TABLE district (\n district_id integer PRIMARY KEY,\n city text,\n state_abbrev text,\n division text\n);\nCREATE TABLE events (\n Date received date,\n Product text,\n Sub-product text,\n Issue text,\n Sub-issue text,\n Consumer complaint narrative text,\n Tags text,\n Consumer consent provided? text,\n Submitted via text,\n Date sent to company text,\n Company response to consumer text,\n Timely response? text,\n Consumer disputed? text,\n Complaint ID text PRIMARY KEY,\n Client_ID text PRIMARY KEY\n);\nCREATE TABLE reviews (\n Date date PRIMARY KEY,\n Stars integer,\n Reviews text,\n Product text,\n district_id integer\n);\n-- foreign keys: callcenterlogs.rand client -> client.client_id; client.district_id -> district.district_id; district.state_abbrev -> state.StateCode; events.Client_ID -> client.client_id; events.Complaint ID -> callcenterlogs.Complaint ID; reviews.district_id -> district.district_id\n\nHint: male refers to sex = 'Male'; age 25 and below refers to age < 25\n\nQuestion: What are the issues of the complains of male clients and products from age 25 and below?"}, {"role": "assistant", "content": "SELECT DISTINCT T2.Issue FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Male' AND T1.age < 25"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE Ref_Document_Types (\nDocument_Type_Code CHAR(15) NOT NULL,\nDocument_Type_Name VARCHAR(255) NOT NULL,\nDocument_Type_Description VARCHAR(255) NOT NULL,\nPRIMARY KEY (Document_Type_Code)\n);\n\nCREATE TABLE Ref_Calendar (\nCalendar_Date DATETIME NOT NULL,\nDay_Number INTEGER,\nPRIMARY KEY (Calendar_Date)\n);\nCREATE TABLE Ref_Locations (\nLocation_Code CHAR(15) NOT NULL,\nLocation_Name VARCHAR(255) NOT NULL,\nLocation_Description VARCHAR(255) NOT NULL,\nPRIMARY KEY (Location_Code)\n);\n\nCREATE TABLE Roles (\nRole_Code CHAR(15) NOT NULL,\nRole_Name VARCHAR(255),\nRole_Description VARCHAR(255),\nPRIMARY KEY (Role_Code)\n);\n\nCREATE TABLE All_Documents (\nDocument_ID INTEGER NOT NULL,\nDate_Stored DATETIME,\nDocument_Type_Code CHAR(15) NOT NULL,\nDocument_Name CHAR(255),\nDocument_Description CHAR(255),\nOther_Details VARCHAR(255),\nPRIMARY KEY (Document_ID),\nFOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code),\nFOREIGN KEY (Date_Stored) REFERENCES Ref_Calendar (Calendar_Date)\n);\n\nCREATE TABLE Employees (\nEmployee_ID INTEGER NOT NULL,\nRole_Code CHAR(15) NOT NULL,\nEmployee_Name VARCHAR(255),\nGender_MFU CHAR(1) NOT NULL,\nDate_of_Birth DATETIME NOT NULL,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Employee_ID),\nFOREIGN KEY (Role_Code) REFERENCES Roles (Role_Code)\n);\n\nCREATE TABLE Document_Locations (\nDocument_ID INTEGER NOT NULL,\nLocation_Code CHAR(15) NOT NULL,\nDate_in_Location_From DATETIME NOT NULL,\nDate_in_Locaton_To DATETIME,\nPRIMARY KEY (Document_ID, Location_Code, Date_in_Location_From),\nFOREIGN KEY (Location_Code) REFERENCES Ref_Locations (Location_Code),\nFOREIGN KEY (Date_in_Location_From) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Date_in_Locaton_To) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Document_ID) REFERENCES All_Documents (Document_ID)\n);\n\nCREATE TABLE Documents_to_be_Destroyed (\nDocument_ID INTEGER NOT NULL,\nDestruction_Authorised_by_Employee_ID INTEGER,\nDestroyed_by_Employee_ID INTEGER,\nPlanned_Destruction_Date DATETIME,\nActual_Destruction_Date DATETIME,\nOther_Details VARCHAR(255),\nPRIMARY KEY (Document_ID),\nFOREIGN KEY (Destroyed_by_Employee_ID) REFERENCES Employees (Employee_ID),\nFOREIGN KEY (Destruction_Authorised_by_Employee_ID) REFERENCES Employees (Employee_ID),\nFOREIGN KEY (Planned_Destruction_Date) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Actual_Destruction_Date) REFERENCES Ref_Calendar (Calendar_Date),\nFOREIGN KEY (Document_ID) REFERENCES All_Documents (Document_ID)\n);\n\nQuestion: Find the number of employees we have."}, {"role": "assistant", "content": "SELECT count(*) FROM Employees"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Person (\n name varchar(20) PRIMARY KEY,\n age INTEGER,\n city TEXT,\n gender TEXT,\n job TEXT\n);\n\nCREATE TABLE PersonFriend (\n name varchar(20),\n friend varchar(20),\n year INTEGER,\n FOREIGN KEY (name) REFERENCES Person(name),\n FOREIGN KEY (friend) REFERENCES Person(name)\n);\n\nQuestion: How many friends does Dan have?"}, {"role": "assistant", "content": "SELECT count(T2.friend) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Dan'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Categories (\n CategoryID integer PRIMARY KEY,\n CategoryName text,\n Description text\n);\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n CustomerName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n LastName text,\n FirstName text,\n BirthDate date,\n Photo text,\n Notes text\n);\nCREATE TABLE Shippers (\n ShipperID integer PRIMARY KEY,\n ShipperName text,\n Phone text\n);\nCREATE TABLE Suppliers (\n SupplierID integer PRIMARY KEY,\n SupplierName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text,\n Phone text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n ProductName text,\n SupplierID integer,\n CategoryID integer,\n Unit text,\n Price real\n);\nCREATE TABLE Orders (\n OrderID integer PRIMARY KEY,\n CustomerID integer,\n EmployeeID integer,\n OrderDate datetime,\n ShipperID integer\n);\nCREATE TABLE OrderDetails (\n OrderDetailID integer PRIMARY KEY,\n OrderID integer,\n ProductID integer,\n Quantity integer\n);\n-- 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\n\nHint: 'Pavlova' is a ProductName\n\nQuestion: How many boxes of 'Pavlova' did Northwind sell?"}, {"role": "assistant", "content": "SELECT COUNT(T2.Quantity) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName = 'Pavlova'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Person (\n name varchar(20) PRIMARY KEY,\n age INTEGER,\n city TEXT,\n gender TEXT,\n job TEXT\n);\n\nCREATE TABLE PersonFriend (\n name varchar(20),\n friend varchar(20),\n year INTEGER,\n FOREIGN KEY (name) REFERENCES Person(name),\n FOREIGN KEY (friend) REFERENCES Person(name)\n);\n\nQuestion: What are the names of the people who are older 40 but no friends under age 30?"}, {"role": "assistant", "content": "SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) EXCEPT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE ranking_system (\n id integer PRIMARY KEY,\n system_name text\n);\nCREATE TABLE ranking_criteria (\n id integer PRIMARY KEY,\n ranking_system_id integer,\n criteria_name text\n);\nCREATE TABLE university (\n id integer PRIMARY KEY,\n country_id integer,\n university_name text\n);\nCREATE TABLE university_ranking_year (\n university_id integer,\n ranking_criteria_id integer,\n year integer,\n score integer\n);\nCREATE TABLE university_year (\n university_id integer,\n year integer,\n num_students integer,\n student_staff_ratio real,\n pct_international_students integer,\n pct_female_students integer\n);\n-- 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\n\nHint: University of Auckland refers to university_name = 'University of Auckland'; in 2015 refers to year = 2015; number of staff refers to DIVIDE(num_students, student_staff_ratio)\n\nQuestion: Provide the number of staff at the University of Auckland in 2015."}, {"role": "assistant", "content": "SELECT CAST(SUM(T1.num_students) AS REAL) / SUM(T1.student_staff_ratio) FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'University of Auckland' AND T1.year = 2015"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"product\" (\n\"product_id\" int,\n\"product\" text,\n\"dimensions\" text,\n\"dpi\" real,\n\"pages_per_minute_color\" real,\n\"max_page_size\" text,\n\"interface\" text,\nPRIMARY KEY (\"product_id\")\n);\n\nCREATE TABLE \"store\" (\n\"Store_ID\" int,\n\"Store_Name\" text,\n\"Type\" text,\n\"Area_size\" real,\n\"Number_of_product_category\" real,\n\"Ranking\" int,\nPRIMARY KEY (\"Store_ID\")\n);\n\nCREATE TABLE \"district\" (\n\"District_ID\" int,\n\"District_name\" text,\n\"Headquartered_City\" text,\n\"City_Population\" real,\n\"City_Area\" real,\nPRIMARY KEY (\"District_ID\")\n);\n\nQuestion: Find the city with the most number of stores."}, {"role": "assistant", "content": "SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city ORDER BY count(*) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"storm\" (\n\"Storm_ID\" int,\n\"Name\" text,\n\"Dates_active\" text,\n\"Max_speed\" int,\n\"Damage_millions_USD\" real,\n\"Number_Deaths\" int,\nPRIMARY KEY (\"Storm_ID\")\n);\n\nQuestion: What are the names of the regions in alphabetical order?"}, {"role": "assistant", "content": "SELECT region_name FROM region ORDER BY region_name"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE CBSA (\n CBSA integer PRIMARY KEY,\n CBSA_name text,\n CBSA_type text\n);\nCREATE TABLE state (\n abbreviation text PRIMARY KEY,\n name text\n);\nCREATE TABLE congress (\n cognress_rep_id text PRIMARY KEY,\n first_name text,\n last_name text,\n CID text,\n party text,\n state text,\n abbreviation text,\n House text,\n District integer,\n land_area real\n);\nCREATE TABLE zip_data (\n zip_code integer PRIMARY KEY,\n city text,\n state text,\n multi_county text,\n type text,\n organization text,\n time_zone text,\n daylight_savings text,\n latitude real,\n longitude real,\n elevation integer,\n state_fips integer,\n county_fips integer,\n region text,\n division text,\n population_2020 integer,\n population_2010 integer,\n households integer,\n avg_house_value integer,\n avg_income_per_household integer,\n persons_per_household real,\n white_population integer,\n black_population integer,\n hispanic_population integer,\n asian_population integer,\n american_indian_population integer,\n hawaiian_population integer,\n other_population integer,\n male_population integer,\n female_population integer,\n median_age real,\n male_median_age real,\n female_median_age real,\n residential_mailboxes integer,\n business_mailboxes integer,\n total_delivery_receptacles integer,\n businesses integer,\n 1st_quarter_payroll integer,\n annual_payroll integer,\n employees integer,\n water_area real,\n land_area real,\n single_family_delivery_units integer,\n multi_family_delivery_units integer,\n total_beneficiaries integer,\n retired_workers integer,\n disabled_workers integer,\n parents_and_widowed integer,\n spouses integer,\n children integer,\n over_65 integer,\n monthly_benefits_all integer,\n monthly_benefits_retired_workers integer,\n monthly_benefits_widowed integer,\n CBSA integer\n);\nCREATE TABLE alias (\n zip_code integer PRIMARY KEY,\n alias text\n);\nCREATE TABLE area_code (\n zip_code integer PRIMARY KEY,\n area_code integer PRIMARY KEY\n);\nCREATE TABLE avoid (\n zip_code integer PRIMARY KEY,\n bad_alias text PRIMARY KEY\n);\nCREATE TABLE country (\n zip_code integer PRIMARY KEY,\n county text PRIMARY KEY,\n state text\n);\nCREATE TABLE zip_congress (\n zip_code integer PRIMARY KEY,\n district text PRIMARY KEY\n);\n-- foreign keys: congress.abbreviation -> state.abbreviation; zip_data.CBSA -> CBSA.CBSA; zip_data.state -> state.abbreviation; alias.zip_code -> zip_data.zip_code; area_code.zip_code -> zip_data.zip_code; avoid.zip_code -> zip_data.zip_code; country.state -> state.abbreviation; country.zip_code -> zip_data.zip_code; zip_congress.zip_code -> zip_data.zip_code; zip_congress.district -> congress.cognress_rep_id\n\nQuestion: What party does the area with the zip code 91701 belong to?"}, {"role": "assistant", "content": "SELECT T1.party FROM congress AS T1 INNER JOIN state AS T2 ON T1.abbreviation = T2.abbreviation INNER JOIN zip_data AS T3 ON T2.abbreviation = T3.state WHERE T3.zip_code = 91701 GROUP BY T1.party"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- phpMyAdmin SQL Dump\n-- version 4.0.10.7\n-- http://www.phpmyadmin.net\n--\n-- Host: localhost\n-- Generation Time: Mar 20, 2015 at 01:43 AM\n-- Server version: 5.5.34-cll-lve\n-- PHP Version: 5.4.23\n\n\n\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n/*!40101 SET NAMES utf8 */;\nCREATE TABLE IF NOT EXISTS `regions` (\n `REGION_ID` decimal(5,0) NOT NULL,\n `REGION_NAME` varchar(25) DEFAULT NULL,\n PRIMARY KEY (`REGION_ID`)\n);\n\n--\n-- Dumping data for table `regions`\n--\n\nQuestion: What are department ids for departments with managers managing more than 3 employees?"}, {"role": "assistant", "content": "SELECT DISTINCT department_id FROM employees GROUP BY department_id , manager_id HAVING COUNT(employee_id) >= 4"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nHint: English is a name of a language; for adults only refers to rating = 'NC-17'\n\nQuestion: How many films in English are for adults only?"}, {"role": "assistant", "content": "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'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Ref_Payment_Methods (\npayment_method_code CHAR(10) NOT NULL,\npayment_method_description VARCHAR(80),\nPRIMARY KEY (payment_method_code),\nUNIQUE (payment_method_code)\n);\n\nQuestion: Show the minimum, average, maximum order quantity of all invoices."}, {"role": "assistant", "content": "SELECT min(Order_Quantity) , avg(Order_Quantity) , max(Order_Quantity) FROM INVOICES"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: rated more than 4 refers to stars > 4;\n\nQuestion: How many businesses id are rated more than 4?"}, {"role": "assistant", "content": "SELECT COUNT(business_id) FROM Business WHERE stars > 4"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_iso_code text,\n country_name text\n);\nCREATE TABLE department (\n department_id integer PRIMARY KEY,\n department_name text\n);\nCREATE TABLE gender (\n gender_id integer PRIMARY KEY,\n gender text\n);\nCREATE TABLE genre (\n genre_id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE keyword (\n keyword_id integer PRIMARY KEY,\n keyword_name text\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE language_role (\n role_id integer PRIMARY KEY,\n language_role text\n);\nCREATE TABLE movie (\n movie_id integer PRIMARY KEY,\n title text,\n budget integer,\n homepage text,\n overview text,\n popularity real,\n release_date date,\n revenue integer,\n runtime integer,\n movie_status text,\n tagline text,\n vote_average real,\n vote_count integer\n);\nCREATE TABLE movie_genres (\n movie_id integer,\n genre_id integer\n);\nCREATE TABLE movie_languages (\n movie_id integer,\n language_id integer,\n language_role_id integer\n);\nCREATE TABLE person (\n person_id integer PRIMARY KEY,\n person_name text\n);\nCREATE TABLE movie_crew (\n movie_id integer,\n person_id integer,\n department_id integer,\n job text\n);\nCREATE TABLE production_company (\n company_id integer PRIMARY KEY,\n company_name text\n);\nCREATE TABLE production_country (\n movie_id integer,\n country_id integer\n);\nCREATE TABLE movie_cast (\n movie_id integer,\n person_id integer,\n character_name text,\n gender_id integer,\n cast_order integer\n);\nCREATE TABLE movie_keywords (\n movie_id integer,\n keyword_id integer\n);\nCREATE TABLE movie_company (\n movie_id integer,\n company_id integer\n);\n-- foreign keys: movie_genres.movie_id -> movie.movie_id; movie_genres.genre_id -> genre.genre_id; movie_languages.language_role_id -> language_role.role_id; movie_languages.movie_id -> movie.movie_id; movie_languages.language_id -> language.language_id; movie_crew.person_id -> person.person_id; movie_crew.movie_id -> movie.movie_id; movie_crew.department_id -> department.department_id; production_country.movie_id -> movie.movie_id; production_country.country_id -> country.country_id; movie_cast.person_id -> person.person_id; movie_cast.movie_id -> movie.movie_id; movie_cast.gender_id -> gender.gender_id\n\nHint: \"vi\" as their language code refers to language_code = 'vi'\n\nQuestion: How many movies have \"vi\" as their language code?"}, {"role": "assistant", "content": "SELECT COUNT(T1.movie_id) FROM movie_languages AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_code = 'vi'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE ranking_system (\n id integer PRIMARY KEY,\n system_name text\n);\nCREATE TABLE ranking_criteria (\n id integer PRIMARY KEY,\n ranking_system_id integer,\n criteria_name text\n);\nCREATE TABLE university (\n id integer PRIMARY KEY,\n country_id integer,\n university_name text\n);\nCREATE TABLE university_ranking_year (\n university_id integer,\n ranking_criteria_id integer,\n year integer,\n score integer\n);\nCREATE TABLE university_year (\n university_id integer,\n year integer,\n num_students integer,\n student_staff_ratio real,\n pct_international_students integer,\n pct_female_students integer\n);\n-- 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\n\nHint: in Australia refers to country_name = 'Australia'; name of university refers to university_name\n\nQuestion: Please list the names of all the universities in Australia."}, {"role": "assistant", "content": "SELECT T1.university_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Australia'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Community_Area (\n community_area_no integer PRIMARY KEY,\n community_area_name text,\n side text,\n population text\n);\nCREATE TABLE District (\n district_no integer PRIMARY KEY,\n district_name text,\n address text,\n zip_code integer,\n commander text,\n email text,\n phone text,\n fax text,\n tty text,\n twitter text\n);\nCREATE TABLE FBI_Code (\n fbi_code_no text PRIMARY KEY,\n title text,\n description text,\n crime_against text\n);\nCREATE TABLE IUCR (\n iucr_no text PRIMARY KEY,\n primary_description text,\n secondary_description text,\n index_code text\n);\nCREATE TABLE Neighborhood (\n neighborhood_name text PRIMARY KEY,\n community_area_no integer\n);\nCREATE TABLE Ward (\n ward_no integer PRIMARY KEY,\n alderman_first_name text,\n alderman_last_name text,\n alderman_name_suffix text,\n ward_office_address text,\n ward_office_zip text,\n ward_email text,\n ward_office_phone text,\n ward_office_fax text,\n city_hall_office_room integer,\n city_hall_office_phone text,\n city_hall_office_fax text,\n Population integer\n);\nCREATE TABLE Crime (\n report_no integer PRIMARY KEY,\n case_number text,\n date text,\n block text,\n iucr_no text,\n location_description text,\n arrest text,\n domestic text,\n beat integer,\n district_no integer,\n ward_no integer,\n community_area_no integer,\n fbi_code_no text,\n latitude text,\n longitude text\n);\n-- foreign keys: Neighborhood.community_area_no -> Community_Area.community_area_no; Crime.fbi_code_no -> FBI_Code.fbi_code_no; Crime.community_area_no -> Community_Area.community_area_no; Crime.district_no -> District.district_no; Crime.iucr_no -> IUCR.iucr_no; Crime.ward_no -> Ward.ward_no\n\nHint: fax number refers to fax; the most number of crimes refers to max(count(case_number)); in January 2018 refers to date like '%1/2018%'\n\nQuestion: What is the fax number for the district with the most number of crimes in January, 2018?"}, {"role": "assistant", "content": "SELECT T1.fax FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T2.date LIKE '%1/2018%' GROUP BY T2.district_no ORDER BY COUNT(case_number) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE customer (\n c_custkey integer PRIMARY KEY,\n c_mktsegment text,\n c_nationkey integer,\n c_name text,\n c_address text,\n c_phone text,\n c_acctbal real,\n c_comment text\n);\nCREATE TABLE lineitem (\n l_shipdate date,\n l_orderkey integer PRIMARY KEY,\n l_discount real,\n l_extendedprice real,\n l_suppkey integer,\n l_quantity integer,\n l_returnflag text,\n l_partkey integer,\n l_linestatus text,\n l_tax real,\n l_commitdate date,\n l_receiptdate date,\n l_shipmode text,\n l_linenumber integer PRIMARY KEY,\n l_shipinstruct text,\n l_comment text\n);\nCREATE TABLE nation (\n n_nationkey integer PRIMARY KEY,\n n_name text,\n n_regionkey integer,\n n_comment text\n);\nCREATE TABLE orders (\n o_orderdate date,\n o_orderkey integer PRIMARY KEY,\n o_custkey integer,\n o_orderpriority text,\n o_shippriority integer,\n o_clerk text,\n o_orderstatus text,\n o_totalprice real,\n o_comment text\n);\nCREATE TABLE part (\n p_partkey integer PRIMARY KEY,\n p_type text,\n p_size integer,\n p_brand text,\n p_name text,\n p_container text,\n p_mfgr text,\n p_retailprice real,\n p_comment text\n);\nCREATE TABLE partsupp (\n ps_partkey integer PRIMARY KEY,\n ps_suppkey integer PRIMARY KEY,\n ps_supplycost real,\n ps_availqty integer,\n ps_comment text\n);\nCREATE TABLE region (\n r_regionkey integer PRIMARY KEY,\n r_name text,\n r_comment text\n);\nCREATE TABLE supplier (\n s_suppkey integer PRIMARY KEY,\n s_nationkey integer,\n s_comment text,\n s_name text,\n s_address text,\n s_phone text,\n s_acctbal real\n);\n-- foreign keys: customer.c_nationkey -> nation.n_nationkey; lineitem.l_partkey -> partsupp.ps_partkey; lineitem.l_suppkey -> partsupp.ps_suppkey; lineitem.l_orderkey -> orders.o_orderkey; nation.n_regionkey -> region.r_regionkey; orders.o_custkey -> customer.c_custkey; partsupp.ps_suppkey -> supplier.s_suppkey; partsupp.ps_partkey -> part.p_partkey; supplier.s_nationkey -> nation.n_nationkey\n\nHint: order refers to o_orderkey; the highest total price refers to max(o_totalprice); delivery date refers to l_shipdate\n\nQuestion: List the 5 orders with the highest total price, indicating the delivery date."}, {"role": "assistant", "content": "SELECT T1.o_orderkey, T2.l_shipdate FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey ORDER BY T1.o_totalprice DESC LIMIT 5"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"repair\" (\n\"repair_ID\" int,\n\"name\" text,\n\"Launch_Date\" text,\n\"Notes\" text,\nPRIMARY KEY (\"repair_ID\")\n);\n\nQuestion: Please show the team that has the most number of technicians."}, {"role": "assistant", "content": "SELECT Team FROM technician GROUP BY Team ORDER BY COUNT(*) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE location (\n LocationID integer PRIMARY KEY,\n Country text,\n State text,\n StateCode text,\n City text\n);\nCREATE TABLE user (\n UserID text PRIMARY KEY,\n Gender text\n);\nCREATE TABLE twitter (\n TweetID text PRIMARY KEY,\n Weekday text,\n Hour integer,\n Day integer,\n Lang text,\n IsReshare text,\n Reach integer,\n RetweetCount integer,\n Likes integer,\n Klout integer,\n Sentiment real,\n text text,\n LocationID integer,\n UserID text\n);\n-- foreign keys: twitter.UserID -> user.UserID; twitter.LocationID -> location.LocationID\n\nHint: \"Argentina\" is the Country\n\nQuestion: Please list all the cities in Argentina."}, {"role": "assistant", "content": "SELECT City FROM location WHERE City IS NOT NULL AND Country = 'Argentina'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`address_content` VARCHAR(80),\n`city` VARCHAR(50),\n`zip_postcode` VARCHAR(20),\n`state_province_county` VARCHAR(50),\n`country` VARCHAR(50),\n`other_address_details` VARCHAR(255)\n);\n\nQuestion: Tell me the payment method used by the customer who ordered the least amount of goods in total."}, {"role": "assistant", "content": "SELECT t1.payment_method FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY sum(t3.order_quantity) LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE coins (\n id integer PRIMARY KEY,\n name text,\n slug text,\n symbol text,\n status text,\n category text,\n description text,\n subreddit text,\n notice text,\n tags text,\n tag_names text,\n website text,\n platform_id integer,\n date_added text,\n date_launched text\n);\nCREATE TABLE historical (\n date date,\n coin_id integer,\n cmc_rank integer,\n market_cap real,\n price real,\n open real,\n high real,\n low real,\n close real,\n time_high text,\n time_low text,\n volume_24h real,\n percent_change_1h real,\n percent_change_24h real,\n percent_change_7d real,\n circulating_supply real,\n total_supply real,\n max_supply real,\n num_market_pairs integer\n);\n\nHint: the percentage of the Bitcoins verifiably burned = divide(subtract(SUM(max_supply), SUM(total_supply)),SUM(total_supply))*100%; until 2013/4/28 refers to date<'2013-04-08'\n\nQuestion: What was the percentage of the Bitcoins verifiably burned until 2018/4/28?"}, {"role": "assistant", "content": "SELECT CAST((SUM(T2.max_supply) - SUM(T2.total_supply)) AS REAL) / SUM(T2.total_supply) FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date < '2018-04-28' AND T1.name = 'Bitcoin'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: avg(user_id) where user_yelping_since_year BETWEEN '2005' AND '2014';\n\nQuestion: Calculate the yearly average user who started using Yelp from the year of 2005 to 2014."}, {"role": "assistant", "content": "SELECT AVG(user_id) FROM Users WHERE user_yelping_since_year >= 2005 AND user_yelping_since_year <= 2015"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Community_Area (\n community_area_no integer PRIMARY KEY,\n community_area_name text,\n side text,\n population text\n);\nCREATE TABLE District (\n district_no integer PRIMARY KEY,\n district_name text,\n address text,\n zip_code integer,\n commander text,\n email text,\n phone text,\n fax text,\n tty text,\n twitter text\n);\nCREATE TABLE FBI_Code (\n fbi_code_no text PRIMARY KEY,\n title text,\n description text,\n crime_against text\n);\nCREATE TABLE IUCR (\n iucr_no text PRIMARY KEY,\n primary_description text,\n secondary_description text,\n index_code text\n);\nCREATE TABLE Neighborhood (\n neighborhood_name text PRIMARY KEY,\n community_area_no integer\n);\nCREATE TABLE Ward (\n ward_no integer PRIMARY KEY,\n alderman_first_name text,\n alderman_last_name text,\n alderman_name_suffix text,\n ward_office_address text,\n ward_office_zip text,\n ward_email text,\n ward_office_phone text,\n ward_office_fax text,\n city_hall_office_room integer,\n city_hall_office_phone text,\n city_hall_office_fax text,\n Population integer\n);\nCREATE TABLE Crime (\n report_no integer PRIMARY KEY,\n case_number text,\n date text,\n block text,\n iucr_no text,\n location_description text,\n arrest text,\n domestic text,\n beat integer,\n district_no integer,\n ward_no integer,\n community_area_no integer,\n fbi_code_no text,\n latitude text,\n longitude text\n);\n-- foreign keys: Neighborhood.community_area_no -> Community_Area.community_area_no; Crime.fbi_code_no -> FBI_Code.fbi_code_no; Crime.community_area_no -> Community_Area.community_area_no; Crime.district_no -> District.district_no; Crime.iucr_no -> IUCR.iucr_no; Crime.ward_no -> Ward.ward_no\n\nHint: aldermen's full name refers to alderman_name_suffix, alderman_first_name, alderman_last_name; 0000X N FRANCISCO AVE refers to block = '0000X N FRANCISCO AVE'\n\nQuestion: Provide case numbers, aldermen's full names, and district names of the crimes that happened in 0000X N FRANCISCO AVE."}, {"role": "assistant", "content": "SELECT T2.case_number, T3.alderman_first_name, T3.alderman_last_name, T1.district_name FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no INNER JOIN Ward AS T3 ON T2.ward_no = T3.ward_no WHERE T2.block = '0000X N FRANCISCO AVE' GROUP BY T2.case_number, T3.alderman_first_name, T3.alderman_last_name, T1.district_name"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE City (\n ID integer PRIMARY KEY,\n Name text,\n CountryCode text,\n District text,\n Population integer\n);\nCREATE TABLE Country (\n Code text PRIMARY KEY,\n Name text,\n Continent text,\n Region text,\n SurfaceArea real,\n IndepYear integer,\n Population integer,\n LifeExpectancy real,\n GNP real,\n GNPOld real,\n LocalName text,\n GovernmentForm text,\n HeadOfState text,\n Capital integer,\n Code2 text\n);\nCREATE TABLE CountryLanguage (\n CountryCode text PRIMARY KEY,\n Language text PRIMARY KEY,\n IsOfficial text,\n Percentage real\n);\n-- foreign keys: City.CountryCode -> Country.Code; CountryLanguage.CountryCode -> Country.Code\n\nQuestion: What is the surface area and GNP of the country where Namibe district belongs?"}, {"role": "assistant", "content": "SELECT T2.SurfaceArea, T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.District = 'Namibe'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"entrepreneur\" (\n\"Entrepreneur_ID\" int,\n\"People_ID\" int,\n\"Company\" text,\n\"Money_Requested\" real,\n\"Investor\" text,\nPRIMARY KEY (\"Entrepreneur_ID\"),\nFOREIGN KEY (\"People_ID\") REFERENCES \"people\"(\"People_ID\")\n);\n\nCREATE TABLE \"people\" (\n\"People_ID\" int,\n\"Name\" text,\n\"Height\" real,\n\"Weight\" real,\n\"Date_of_Birth\" text,\nPRIMARY KEY (\"People_ID\")\n);\n\nQuestion: What is the total money requested by entrepreneurs with height more than 1.85?"}, {"role": "assistant", "content": "SELECT sum(T1.Money_Requested) FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Height > 1.85"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE geographic (\n city text PRIMARY KEY,\n county text,\n region text\n);\nCREATE TABLE generalinfo (\n id_restaurant integer PRIMARY KEY,\n label text,\n food_type text,\n city text,\n review real\n);\nCREATE TABLE location (\n id_restaurant integer PRIMARY KEY,\n street_num integer,\n street_name text,\n city text\n);\n-- foreign keys: generalinfo.city -> geographic.city; location.id_restaurant -> generalinfo.id_restaurant; location.city -> geographic.city\n\nHint: street number ranges from 1000 to 2000 refers to 1000 < = street_num < = 2000; Afghani restaurant refers to food_type = 'afghani'; percentage = divide(count(id_restaurant where food_type = 'afghani'), count(id_restaurant)) * 100%\n\nQuestion: Among the restaurants located on the street number ranges from 1000 to 2000, what is the percentage of Afghani restaurants are there?"}, {"role": "assistant", "content": "SELECT CAST(SUM(IIF(T2.food_type = 'afghani', 1, 0)) AS REAL) * 100 / COUNT(T1.id_restaurant) FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE 1000 <= T1.street_num <= 2000"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE people (\n Customer ID text PRIMARY KEY,\n Customer Name text,\n Segment text,\n Country text,\n City text,\n State text,\n Postal Code integer,\n Region text PRIMARY KEY\n);\nCREATE TABLE product (\n Product ID text PRIMARY KEY,\n Product Name text,\n Category text,\n Sub-Category text,\n Region text PRIMARY KEY\n);\nCREATE TABLE central_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\nCREATE TABLE east_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\nCREATE TABLE south_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\nCREATE TABLE west_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\n-- 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\n\nHint: art product refers to Sub-Category = 'Art'; the most refers to max(order_number)\n\nQuestion: Among the orders in Central superstore, which art product were ordered the most?"}, {"role": "assistant", "content": "SELECT T2.`Product Name` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.`Sub-Category` = 'Art' GROUP BY T2.`Product Name` ORDER BY COUNT(T2.`Product ID`) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Apartment_Buildings (\nbuilding_id INTEGER NOT NULL,\nbuilding_short_name CHAR(15),\nbuilding_full_name VARCHAR(80),\nbuilding_description VARCHAR(255),\nbuilding_address VARCHAR(255),\nbuilding_manager VARCHAR(50),\nbuilding_phone VARCHAR(80),\nPRIMARY KEY (building_id),\nUNIQUE (building_id)\n);\n\nQuestion: Show the distinct apartment numbers of the apartments that have bookings with status code \"Confirmed\"."}, {"role": "assistant", "content": "SELECT DISTINCT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = \"Confirmed\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE employee (\n employee_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address text,\n city text,\n state text,\n zip integer,\n phone text,\n title text,\n salary integer,\n supervisor integer\n);\nCREATE TABLE establishment (\n license_no integer PRIMARY KEY,\n dba_name text,\n aka_name text,\n facility_type text,\n risk_level integer,\n address text,\n city text,\n state text,\n zip integer,\n latitude real,\n longitude real,\n ward integer\n);\nCREATE TABLE inspection (\n inspection_id integer PRIMARY KEY,\n inspection_date date,\n inspection_type text,\n results text,\n employee_id integer,\n license_no integer,\n followup_to integer\n);\nCREATE TABLE inspection_point (\n point_id integer PRIMARY KEY,\n Description text,\n category text,\n code text,\n fine integer,\n point_level text\n);\nCREATE TABLE violation (\n inspection_id integer PRIMARY KEY,\n point_id integer PRIMARY KEY,\n fine integer,\n inspector_comment text\n);\n-- foreign keys: employee.supervisor -> employee.employee_id; inspection.followup_to -> inspection.inspection_id; inspection.license_no -> establishment.license_no; inspection.employee_id -> employee.employee_id; violation.point_id -> inspection_point.point_id; violation.inspection_id -> inspection.inspection_id\n\nQuestion: List all inspection IDs where the employee named \"Rosemary Kennedy\" was involved."}, {"role": "assistant", "content": "SELECT DISTINCT T2.inspection_id FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T1.first_name = 'Rosemary' AND T1.last_name = 'Kennedy'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE bank (\nbranch_ID int PRIMARY KEY,\nbname varchar(20),\nno_of_customers int,\ncity varchar(10),\nstate varchar(20));\n\n\nCREATE TABLE customer (\ncust_ID varchar(3) PRIMARY KEY,\ncust_name varchar(20),\nacc_type char(1),\nacc_bal int,\nno_of_loans int,\ncredit_score int,\nbranch_ID int,\nstate varchar(20),\nFOREIGN KEY(branch_ID) REFERENCES bank(branch_ID));\n\n\nCREATE TABLE loan (\nloan_ID varchar(3) PRIMARY KEY,\nloan_type varchar(15),\ncust_ID varchar(3),\nbranch_ID varchar(3),\namount int,\nFOREIGN KEY(branch_ID) REFERENCES bank(branch_ID),\nFOREIGN KEY(Cust_ID) REFERENCES customer(Cust_ID));\n\nQuestion: List the name of all different customers who have some loan sorted by their total loan amount."}, {"role": "assistant", "content": "SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"body_builder\" (\n\"Body_Builder_ID\" int,\n\"People_ID\" int,\n\"Snatch\" real,\n\"Clean_Jerk\" real,\n\"Total\" real,\nPRIMARY KEY (\"Body_Builder_ID\"),\nFOREIGN KEY (\"People_ID\") REFERENCES `people`(\"People_ID\")\n);\n\nCREATE TABLE \"people\" (\n\"People_ID\" int,\n\"Name\" text,\n\"Height\" real,\n\"Weight\" real,\n\"Birth_Date\" text,\n\"Birth_Place\" text,\nPRIMARY KEY (\"People_ID\")\n);\n\nQuestion: What is the average snatch score of body builders?"}, {"role": "assistant", "content": "SELECT avg(Snatch) FROM body_builder"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n Customer Names text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Product Name text\n);\nCREATE TABLE Regions (\n StateCode text PRIMARY KEY,\n State text,\n Region text\n);\nCREATE TABLE Sales Team (\n SalesTeamID integer PRIMARY KEY,\n Sales Team text,\n Region text\n);\nCREATE TABLE Store Locations (\n StoreID integer PRIMARY KEY,\n City Name text,\n County text,\n StateCode text,\n State text,\n Type text,\n Latitude real,\n Longitude real,\n AreaCode integer,\n Population integer,\n Household Income integer,\n Median Income integer,\n Land Area integer,\n Water Area integer,\n Time Zone text\n);\nCREATE TABLE Sales Orders (\n OrderNumber text PRIMARY KEY,\n Sales Channel text,\n WarehouseCode text,\n ProcuredDate text,\n OrderDate text,\n ShipDate text,\n DeliveryDate text,\n CurrencyCode text,\n _SalesTeamID integer,\n _CustomerID integer,\n _StoreID integer,\n _ProductID integer,\n Order Quantity integer,\n Discount Applied real,\n Unit Price text,\n Unit Cost text\n);\n-- 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\n\nHint: \"New Hampshire\" is the State; average household income = AVG(Household Income)\n\nQuestion: What is the average household income in cities in the state of New Hampshire where there are stores of the type city?"}, {"role": "assistant", "content": "SELECT AVG(T2.`Household Income`) FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.State = 'New Hampshire' AND T2.Type = 'City'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Episode (\n episode_id text PRIMARY KEY,\n season integer,\n episode integer,\n number_in_series integer,\n title text,\n summary text,\n air_date text,\n episode_image text,\n rating real,\n votes integer\n);\nCREATE TABLE Person (\n name text PRIMARY KEY,\n birthdate text,\n birth_name text,\n birth_place text,\n birth_region text,\n birth_country text,\n height_meters real,\n nickname text\n);\nCREATE TABLE Award (\n award_id integer PRIMARY KEY,\n organization text,\n year integer,\n award_category text,\n award text,\n person text,\n role text,\n episode_id text,\n season text,\n song text,\n result text\n);\nCREATE TABLE Character_Award (\n award_id integer,\n character text\n);\nCREATE TABLE Credit (\n episode_id text,\n category text,\n person text,\n role text,\n credited text\n);\nCREATE TABLE Keyword (\n episode_id text PRIMARY KEY,\n keyword text PRIMARY KEY\n);\nCREATE TABLE Vote (\n episode_id text,\n stars integer,\n votes integer,\n percent real\n);\n-- 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\n\nHint: nominated refers to result = 'Nominee'; Annie Awards refers to organization = 'Annie Awards'; percent greater than 6 refers to percent > 6\n\nQuestion: In episode nominated in Annie Awards, how many of the episodes have a percent greater than 6?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM Award AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.organization = 'Annie Awards' AND T1.result = 'Nominee' AND T2.percent > 6;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE \"medicine\" (\n\"id\" int,\n\"name\" text,\n\"Trade_Name\" text,\n\"FDA_approved\" text,\nprimary key (\"id\")\n);\n\nCREATE TABLE \"enzyme\" (\n\"id\" int,\n\"name\" text,\n\"Location\" text,\n\"Product\" text,\n\"Chromosome\" text,\n\"OMIM\" int,\n\"Porphyria\" text,\nprimary key (\"id\")\n);\n\n\nCREATE TABLE \"medicine_enzyme_interaction\" (\n\"enzyme_id\" int,\n\"medicine_id\" int,\n\"interaction_type\" text,\nprimary key (\"enzyme_id\", \"medicine_id\"),\nforeign key (\"enzyme_id\") references `enzyme`(\"id\"),\nforeign key (\"medicine_id\") references `medicine`(\"id\")\n);\n\nQuestion: What is the count of enzymes without any interactions?"}, {"role": "assistant", "content": "SELECT count(*) FROM enzyme WHERE id NOT IN ( SELECT enzyme_id FROM medicine_enzyme_interaction );"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Air Carriers (\n Code integer PRIMARY KEY,\n Description text\n);\nCREATE TABLE Airports (\n Code text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Airlines (\n FL_DATE text,\n OP_CARRIER_AIRLINE_ID integer,\n TAIL_NUM text,\n OP_CARRIER_FL_NUM integer,\n ORIGIN_AIRPORT_ID integer,\n ORIGIN_AIRPORT_SEQ_ID integer,\n ORIGIN_CITY_MARKET_ID integer,\n ORIGIN text,\n DEST_AIRPORT_ID integer,\n DEST_AIRPORT_SEQ_ID integer,\n DEST_CITY_MARKET_ID integer,\n DEST text,\n CRS_DEP_TIME integer,\n DEP_TIME integer,\n DEP_DELAY integer,\n DEP_DELAY_NEW integer,\n ARR_TIME integer,\n ARR_DELAY integer,\n ARR_DELAY_NEW integer,\n CANCELLED integer,\n CANCELLATION_CODE text,\n CRS_ELAPSED_TIME integer,\n ACTUAL_ELAPSED_TIME integer,\n CARRIER_DELAY integer,\n WEATHER_DELAY integer,\n NAS_DELAY integer,\n SECURITY_DELAY integer,\n LATE_AIRCRAFT_DELAY integer\n);\n-- foreign keys: Airlines.OP_CARRIER_AIRLINE_ID -> Air Carriers.Code; Airlines.DEST -> Airports.Code; Airlines.ORIGIN -> Airports.Code\n\nHint: on 2018/8/1 refers to FL_DATE = '2018/8/1'; depart from refers to ORIGIN; John F. Kennedy International in New York refers to Description = 'New York, NY: John F. Kennedy International';\n\nQuestion: Among the flights on 2018/8/1, how many of them were scheduled to depart from John F. Kennedy International in New York?"}, {"role": "assistant", "content": "SELECT COUNT(T1.Code) FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.ORIGIN WHERE T2.FL_DATE = '2018/8/1' AND T1.Description = 'New York, NY: John F. Kennedy International'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE lists (\n user_id integer,\n list_id integer PRIMARY KEY,\n list_title text,\n list_movie_number integer,\n list_update_timestamp_utc text,\n list_creation_timestamp_utc text,\n list_followers integer,\n list_url text,\n list_comments integer,\n list_description text,\n list_cover_image_url text,\n list_first_image_url text,\n list_second_image_url text,\n list_third_image_url text\n);\nCREATE TABLE movies (\n movie_id integer PRIMARY KEY,\n movie_title text,\n movie_release_year integer,\n movie_url text,\n movie_title_language text,\n movie_popularity integer,\n movie_image_url text,\n director_id text,\n director_name text,\n director_url text\n);\nCREATE TABLE ratings_users (\n user_id integer,\n rating_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\nCREATE TABLE lists_users (\n user_id integer PRIMARY KEY,\n list_id integer PRIMARY KEY,\n list_update_date_utc text,\n list_creation_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial text,\n user_has_payment_method text\n);\nCREATE TABLE ratings (\n movie_id integer,\n rating_id integer,\n rating_url text,\n rating_score integer,\n rating_timestamp_utc text,\n critic text,\n critic_likes integer,\n critic_comments integer,\n user_id integer,\n user_trialist integer,\n user_subscriber integer,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\n-- 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\n\nHint: name of the movie refers to movie_title; most critic comments refers to MAX(critic_comments)\n\nQuestion: Which movie got the most critic comments? Give the name of the movie."}, {"role": "assistant", "content": "SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id GROUP BY T2.movie_title ORDER BY COUNT(T1.critic_comments) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE ranking_system (\n id integer PRIMARY KEY,\n system_name text\n);\nCREATE TABLE ranking_criteria (\n id integer PRIMARY KEY,\n ranking_system_id integer,\n criteria_name text\n);\nCREATE TABLE university (\n id integer PRIMARY KEY,\n country_id integer,\n university_name text\n);\nCREATE TABLE university_ranking_year (\n university_id integer,\n ranking_criteria_id integer,\n year integer,\n score integer\n);\nCREATE TABLE university_year (\n university_id integer,\n year integer,\n num_students integer,\n student_staff_ratio real,\n pct_international_students integer,\n pct_female_students integer\n);\n-- 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\n\nHint: average score refers to avg(score); between year 2013 to 2015 refers to year BETWEEN 2013 AND 2015\n\nQuestion: Calculate the average score of university ID 79 between year 2013 to 2015."}, {"role": "assistant", "content": "SELECT AVG(score) FROM university_ranking_year WHERE year BETWEEN 2013 AND 2015 AND university_id = 79"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Name text,\n Price real\n);\nCREATE TABLE Sales (\n SalesID integer PRIMARY KEY,\n SalesPersonID integer,\n CustomerID integer,\n ProductID integer,\n Quantity integer\n);\n-- foreign keys: Sales.ProductID -> Products.ProductID; Sales.CustomerID -> Customers.CustomerID; Sales.SalesPersonID -> Employees.EmployeeID\n\nHint: most common last name refers to MAX(COUNT(LastName));\n\nQuestion: How many customers share the most common last name?"}, {"role": "assistant", "content": "SELECT COUNT(CustomerID) FROM Customers GROUP BY LastName ORDER BY COUNT(LastName) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_iso_code text,\n country_name text\n);\nCREATE TABLE department (\n department_id integer PRIMARY KEY,\n department_name text\n);\nCREATE TABLE gender (\n gender_id integer PRIMARY KEY,\n gender text\n);\nCREATE TABLE genre (\n genre_id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE keyword (\n keyword_id integer PRIMARY KEY,\n keyword_name text\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE language_role (\n role_id integer PRIMARY KEY,\n language_role text\n);\nCREATE TABLE movie (\n movie_id integer PRIMARY KEY,\n title text,\n budget integer,\n homepage text,\n overview text,\n popularity real,\n release_date date,\n revenue integer,\n runtime integer,\n movie_status text,\n tagline text,\n vote_average real,\n vote_count integer\n);\nCREATE TABLE movie_genres (\n movie_id integer,\n genre_id integer\n);\nCREATE TABLE movie_languages (\n movie_id integer,\n language_id integer,\n language_role_id integer\n);\nCREATE TABLE person (\n person_id integer PRIMARY KEY,\n person_name text\n);\nCREATE TABLE movie_crew (\n movie_id integer,\n person_id integer,\n department_id integer,\n job text\n);\nCREATE TABLE production_company (\n company_id integer PRIMARY KEY,\n company_name text\n);\nCREATE TABLE production_country (\n movie_id integer,\n country_id integer\n);\nCREATE TABLE movie_cast (\n movie_id integer,\n person_id integer,\n character_name text,\n gender_id integer,\n cast_order integer\n);\nCREATE TABLE movie_keywords (\n movie_id integer,\n keyword_id integer\n);\nCREATE TABLE movie_company (\n movie_id integer,\n company_id integer\n);\n-- foreign keys: movie_genres.movie_id -> movie.movie_id; movie_genres.genre_id -> genre.genre_id; movie_languages.language_role_id -> language_role.role_id; movie_languages.movie_id -> movie.movie_id; movie_languages.language_id -> language.language_id; movie_crew.person_id -> person.person_id; movie_crew.movie_id -> movie.movie_id; movie_crew.department_id -> department.department_id; production_country.movie_id -> movie.movie_id; production_country.country_id -> country.country_id; movie_cast.person_id -> person.person_id; movie_cast.movie_id -> movie.movie_id; movie_cast.gender_id -> gender.gender_id\n\nQuestion: How many crew are named John Young?"}, {"role": "assistant", "content": "SELECT COUNT(person_id) FROM person WHERE person_name = 'John Young'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"company\" (\n\"Company_ID\" int,\n\"Rank\" int,\n\"Company\" text,\n\"Headquarters\" text,\n\"Main_Industry\" text,\n\"Sales_billion\" real,\n\"Profits_billion\" real,\n\"Assets_billion\" real,\n\"Market_Value\" real,\nPRIMARY KEY (\"Company_ID\")\n);\n\nCREATE TABLE \"gas_station\" (\n\"Station_ID\" int,\n\"Open_Year\" int,\n\"Location\" text,\n\"Manager_Name\" text,\n\"Vice_Manager_Name\" text,\n\"Representative_Name\" text,\nPRIMARY KEY (\"Station_ID\")\n);\n\nQuestion: Show all main industry and total market value in each industry."}, {"role": "assistant", "content": "SELECT main_industry , sum(market_value) FROM company GROUP BY main_industry"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE bool (\n name text PRIMARY KEY\n);\nCREATE TABLE person (\n name text PRIMARY KEY\n);\nCREATE TABLE disabled (\n name text PRIMARY KEY\n);\nCREATE TABLE enlist (\n name text,\n organ text\n);\nCREATE TABLE filed_for_bankrupcy (\n name text PRIMARY KEY\n);\nCREATE TABLE longest_absense_from_school (\n name text PRIMARY KEY,\n month integer\n);\nCREATE TABLE male (\n name text PRIMARY KEY\n);\nCREATE TABLE no_payment_due (\n name text PRIMARY KEY,\n bool text\n);\nCREATE TABLE unemployed (\n name text PRIMARY KEY\n);\nCREATE TABLE enrolled (\n name text PRIMARY KEY,\n school text PRIMARY KEY,\n month integer\n);\n-- foreign keys: disabled.name -> person.name; enlist.name -> person.name; filed_for_bankrupcy.name -> person.name; longest_absense_from_school.name -> person.name; male.name -> person.name; no_payment_due.bool -> bool.name; no_payment_due.name -> person.name; unemployed.name -> person.name; enrolled.name -> person.name\n\nHint: absent for 9 months refers to month = 9;\n\nQuestion: Among students who have been absent for nine months, how many of them are disabled?"}, {"role": "assistant", "content": "SELECT COUNT(T1.name) FROM disabled AS T1 LEFT JOIN longest_absense_from_school AS T2 ON T2.name = T1.name WHERE T2.month = 9"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE lists (\n user_id integer,\n list_id integer PRIMARY KEY,\n list_title text,\n list_movie_number integer,\n list_update_timestamp_utc text,\n list_creation_timestamp_utc text,\n list_followers integer,\n list_url text,\n list_comments integer,\n list_description text,\n list_cover_image_url text,\n list_first_image_url text,\n list_second_image_url text,\n list_third_image_url text\n);\nCREATE TABLE movies (\n movie_id integer PRIMARY KEY,\n movie_title text,\n movie_release_year integer,\n movie_url text,\n movie_title_language text,\n movie_popularity integer,\n movie_image_url text,\n director_id text,\n director_name text,\n director_url text\n);\nCREATE TABLE ratings_users (\n user_id integer,\n rating_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\nCREATE TABLE lists_users (\n user_id integer PRIMARY KEY,\n list_id integer PRIMARY KEY,\n list_update_date_utc text,\n list_creation_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial text,\n user_has_payment_method text\n);\nCREATE TABLE ratings (\n movie_id integer,\n rating_id integer,\n rating_url text,\n rating_score integer,\n rating_timestamp_utc text,\n critic text,\n critic_likes integer,\n critic_comments integer,\n user_id integer,\n user_trialist integer,\n user_subscriber integer,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\n-- 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\n\nHint: the average rating score refers to AVG(T2.rating_score); oldest movies refers to MIN(rating_timestamp_utc)\n\nQuestion: What are the top 10 oldest movies and what are the average rating score for each movie? Indicate the name of the director and when the movies were released."}, {"role": "assistant", "content": "SELECT T2.movie_id, AVG(T1.rating_score), T2.director_name, T2.movie_release_year FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.rating_timestamp_utc ASC LIMIT 10"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- dbext:type=SQLITE:dbname=movie_rating.db\n\n/* Delete the tables if they already exist */\ndrop table if exists Movie;\ndrop table if exists Reviewer;\ndrop table if exists Rating;\n\n/* Create the schema for our tables */\ncreate table Movie(\n\tmID int primary key, \n\ttitle text, \n\tyear int, \n\tdirector text\n);\ncreate table Reviewer(\n\trID int primary key, \n\tname text);\n\ncreate table Rating(\n\trID int, \n\tmID int, \n\tstars int, \n\tratingDate date,\n\tFOREIGN KEY (mID) references Movie(mID),\n\tFOREIGN KEY (rID) references Reviewer(rID)\n);\n\n/* Populate the tables with our data */\n\nQuestion: What are the titles of all movies that were not reviewed by Chris Jackson?"}, {"role": "assistant", "content": "SELECT DISTINCT title FROM Movie EXCEPT SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Chris Jackson'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE app_all (\n app_id integer PRIMARY KEY\n);\nCREATE TABLE app_events (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_events_relevant (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_labels (\n app_id integer,\n label_id integer\n);\nCREATE TABLE events (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE events_relevant (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE gender_age (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE gender_age_test (\n device_id integer PRIMARY KEY\n);\nCREATE TABLE gender_age_train (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE label_categories (\n label_id integer PRIMARY KEY,\n category text\n);\nCREATE TABLE phone_brand_device_model2 (\n device_id integer PRIMARY KEY,\n phone_brand text PRIMARY KEY,\n device_model text PRIMARY KEY\n);\nCREATE TABLE sample_submission (\n device_id integer PRIMARY KEY,\n F23- real,\n F24-26 real,\n F27-28 real,\n F29-32 real,\n F33-42 real,\n F43+ real,\n M22- real,\n M23-26 real,\n M27-28 real,\n M29-31 real,\n M32-38 real,\n M39+ real\n);\n-- 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\n\nQuestion: How many of the apps belong in the \"Equity Fund\" category?"}, {"role": "assistant", "content": "SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id WHERE T2.category = 'Equity Fund'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE Customers (\nCustomer_ID INTEGER NOT NULL,\nCustomer_Details VARCHAR(255) NOT NULL,\nPRIMARY KEY (Customer_ID)\n);\n\nQuestion: What are the names of the customers and staff members?"}, {"role": "assistant", "content": "SELECT customer_details FROM customers UNION SELECT staff_details FROM staff"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: 10 am refers to opening_time = '10AM'; 9 pm refers to closing_time = '9PM'; 'Monday' and 'Tuesday' are both day_of_week; difference number of business = Subtract(Count(business_id(day_of_week = 'Monday')), Count(business_id(day_of_week = 'Tuesday')))\n\nQuestion: Compare and get the difference of the number of businesses that are open in Monday and Tuesday from 10 am to 9 pm."}, {"role": "assistant", "content": "SELECT SUM(CASE WHEN T3.day_of_week = 'Monday' THEN 1 ELSE 0 END) - SUM(CASE WHEN T3.day_of_week = 'Tuesday' THEN 1 ELSE 0 END) AS DIFF FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T2.opening_time = '10AM' AND T2.closing_time = '9PM'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- phpMyAdmin SQL Dump\n-- version 4.0.10.7\n-- http://www.phpmyadmin.net\n--\n-- Host: localhost\n-- Generation Time: Mar 20, 2015 at 01:43 AM\n-- Server version: 5.5.34-cll-lve\n-- PHP Version: 5.4.23\n\n\n\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n/*!40101 SET NAMES utf8 */;\nCREATE TABLE IF NOT EXISTS `regions` (\n `REGION_ID` decimal(5,0) NOT NULL,\n `REGION_NAME` varchar(25) DEFAULT NULL,\n PRIMARY KEY (`REGION_ID`)\n);\n\n--\n-- Dumping data for table `regions`\n--\n\nQuestion: What are the job ids and dates of hire for employees hired after November 5th, 2007 and before July 5th, 2009?"}, {"role": "assistant", "content": "SELECT job_id , hire_date FROM employees WHERE hire_date BETWEEN '2007-11-05' AND '2009-07-05'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`line_1_number_building` VARCHAR(80),\n`city` VARCHAR(50),\n`zip_postcode` VARCHAR(20),\n`state_province_county` VARCHAR(50),\n`country` VARCHAR(50)\n);\n\nQuestion: What is the country in which the customer Carole Bernhard lived?"}, {"role": "assistant", "content": "SELECT T2.country FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T1.first_name = \"Carole\" AND T1.last_name = \"Bernhard\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Activity (\n actid INTEGER PRIMARY KEY,\n activity_name varchar(25)\n);\n\ncreate table Participates_in (\n stuid INTEGER,\n actid INTEGER,\n FOREIGN KEY(stuid) REFERENCES Student(StuID),\n FOREIGN KEY(actid) REFERENCES Activity(actid)\n);\n\ncreate table Faculty_Participates_in (\n FacID INTEGER,\n actid INTEGER,\n FOREIGN KEY(FacID) REFERENCES Faculty(FacID),\n FOREIGN KEY(actid) REFERENCES Activity(actid)\n);\n\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\ncreate table Faculty (\n FacID \t INTEGER PRIMARY KEY,\n Lname\t\tVARCHAR(15),\n Fname\t\tVARCHAR(15),\n Rank\t\tVARCHAR(15),\n Sex\t\tVARCHAR(1),\n Phone\t\tINTEGER,\n Room\t\tVARCHAR(5),\n Building\t\tVARCHAR(13)\n);\n\nQuestion: What are the names of the activities Mark Giuliano is involved in"}, {"role": "assistant", "content": "SELECT T3.activity_name FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN Activity AS T3 ON T3.actid = T2.actid WHERE T1.fname = \"Mark\" AND T1.lname = \"Giuliano\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE course (\n course_id integer PRIMARY KEY,\n name text,\n credit integer,\n diff integer\n);\nCREATE TABLE prof (\n prof_id integer PRIMARY KEY,\n gender text,\n first_name text,\n last_name text,\n email text,\n popularity integer,\n teachingability integer,\n graduate_from text\n);\nCREATE TABLE RA (\n student_id integer PRIMARY KEY,\n capability integer,\n prof_id integer PRIMARY KEY,\n salary text\n);\nCREATE TABLE registration (\n course_id integer PRIMARY KEY,\n student_id integer PRIMARY KEY,\n grade text,\n sat integer\n);\nCREATE TABLE student (\n student_id integer PRIMARY KEY,\n f_name text,\n l_name text,\n phone_number text,\n email text,\n intelligence integer,\n gpa real,\n type text\n);\n-- foreign keys: RA.student_id -> student.student_id; RA.prof_id -> prof.prof_id; registration.student_id -> student.student_id; registration.course_id -> course.course_id\n\nHint: GPA of the semester = DIVIDE(SUM(MULTIPLY(credit, grade)), SUM(credit)); grade 'A' refers to gpa = 4; grade 'B' refers to gpa = 3; grade 'C' refers to gpa = 2; grade 'D' refers to gpa = 1;\n\nQuestion: Calculate the GPA of the semester for Laughton Antonio."}, {"role": "assistant", "content": "SELECT CAST(SUM(T3.credit * CASE T1.grade WHEN 'A' THEN 4 WHEN 'B' THEN 3 WHEN 'C' THEN 2 WHEN 'D' THEN 1 ELSE 1 END) AS REAL) / COUNT(T3.credit) FROM registration AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T1.course_id = T3.course_id WHERE T2.f_name = 'Laughton' AND T2.l_name = 'Antonio'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE address_status (\n status_id integer PRIMARY KEY,\n address_status text\n);\nCREATE TABLE author (\n author_id integer PRIMARY KEY,\n author_name text\n);\nCREATE TABLE book_language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n street_number text,\n street_name text,\n city text,\n country_id integer\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n email text\n);\nCREATE TABLE customer_address (\n customer_id integer PRIMARY KEY,\n address_id integer PRIMARY KEY,\n status_id integer\n);\nCREATE TABLE order_status (\n status_id integer PRIMARY KEY,\n status_value text\n);\nCREATE TABLE publisher (\n publisher_id integer PRIMARY KEY,\n publisher_name text\n);\nCREATE TABLE book (\n book_id integer PRIMARY KEY,\n title text,\n isbn13 text,\n language_id integer,\n num_pages integer,\n publication_date date,\n publisher_id integer\n);\nCREATE TABLE book_author (\n book_id integer PRIMARY KEY,\n author_id integer PRIMARY KEY\n);\nCREATE TABLE shipping_method (\n method_id integer PRIMARY KEY,\n method_name text,\n cost real\n);\nCREATE TABLE cust_order (\n order_id integer PRIMARY KEY,\n order_date datetime,\n customer_id integer,\n shipping_method_id integer,\n dest_address_id integer\n);\nCREATE TABLE order_history (\n history_id integer PRIMARY KEY,\n order_id integer,\n status_id integer,\n status_date datetime\n);\nCREATE TABLE order_line (\n line_id integer PRIMARY KEY,\n order_id integer,\n book_id integer,\n price real\n);\n-- 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\n\nHint: books over $13 refers to price > 13; percentage = Divide (Sum (order_id where price > 13), Count (order_id)) * 100\n\nQuestion: Among the books ordered by Lucas Wyldbore, what is the percentage of those books over $13?"}, {"role": "assistant", "content": "SELECT CAST(SUM(CASE WHEN T1.price > 13 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Scientists (\n SSN int,\n Name Char(30) not null,\n Primary Key (SSN)\n);\n\nCreate table Projects (\n Code Char(4),\n Name Char(50) not null,\n Hours int,\n Primary Key (Code)\n);\n\t\ncreate table AssignedTo (\n Scientist int not null,\n Project char(4) not null,\n Primary Key (Scientist, Project),\n Foreign Key (Scientist) references Scientists (SSN),\n Foreign Key (Project) references Projects (Code)\n);\n\nQuestion: Find name of the project that needs the least amount of time to finish and the name of scientists who worked on it."}, {"role": "assistant", "content": "SELECT T2.name , T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT min(hours) FROM projects)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Dish (\n id integer PRIMARY KEY,\n name text,\n description text,\n menus_appeared integer,\n times_appeared integer,\n first_appeared integer,\n last_appeared integer,\n lowest_price real,\n highest_price real\n);\nCREATE TABLE Menu (\n id integer PRIMARY KEY,\n name text,\n sponsor text,\n event text,\n venue text,\n place text,\n physical_description text,\n occasion text,\n notes text,\n call_number text,\n keywords text,\n language text,\n date date,\n location text,\n location_type text,\n currency text,\n currency_symbol text,\n status text,\n page_count integer,\n dish_count integer\n);\nCREATE TABLE MenuPage (\n id integer PRIMARY KEY,\n menu_id integer,\n page_number integer,\n image_id real,\n full_height integer,\n full_width integer,\n uuid text\n);\nCREATE TABLE MenuItem (\n id integer PRIMARY KEY,\n menu_page_id integer,\n price real,\n high_price real,\n dish_id integer,\n created_at text,\n updated_at text,\n xpos real,\n ypos real\n);\n-- foreign keys: MenuPage.menu_id -> Menu.id; MenuItem.menu_page_id -> MenuPage.id; MenuItem.dish_id -> Dish.id\n\nHint: appear in the right upper corner of the menu page refers to xpos > 0.75 and ypos < 0.25;\n\nQuestion: How many dishes appear in the right upper corner of the menu page?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM MenuItem AS T1 INNER JOIN Dish AS T2 ON T1.dish_id = T2.id WHERE T1.xpos > 0.75 AND T1.ypos < 0.25"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Categories (\n CategoryID integer PRIMARY KEY,\n CategoryName text,\n Description text\n);\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n CustomerName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n LastName text,\n FirstName text,\n BirthDate date,\n Photo text,\n Notes text\n);\nCREATE TABLE Shippers (\n ShipperID integer PRIMARY KEY,\n ShipperName text,\n Phone text\n);\nCREATE TABLE Suppliers (\n SupplierID integer PRIMARY KEY,\n SupplierName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text,\n Phone text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n ProductName text,\n SupplierID integer,\n CategoryID integer,\n Unit text,\n Price real\n);\nCREATE TABLE Orders (\n OrderID integer PRIMARY KEY,\n CustomerID integer,\n EmployeeID integer,\n OrderDate datetime,\n ShipperID integer\n);\nCREATE TABLE OrderDetails (\n OrderDetailID integer PRIMARY KEY,\n OrderID integer,\n ProductID integer,\n Quantity integer\n);\n-- 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\n\nHint: 'Exotic Liquids' is a CompanyName; units in stock over 100 refers to UnitsInStock > 100\n\nQuestion: List all category name of Exotic Liquids 's product with units in stock over 100."}, {"role": "assistant", "content": "SELECT T3.CategoryName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN Categories AS T3 ON T2.CategoryID = T3.CategoryID WHERE T2.UnitsInStock > 100 AND T1.CompanyName = 'Exotic Liquids'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE bool (\n name text PRIMARY KEY\n);\nCREATE TABLE person (\n name text PRIMARY KEY\n);\nCREATE TABLE disabled (\n name text PRIMARY KEY\n);\nCREATE TABLE enlist (\n name text,\n organ text\n);\nCREATE TABLE filed_for_bankrupcy (\n name text PRIMARY KEY\n);\nCREATE TABLE longest_absense_from_school (\n name text PRIMARY KEY,\n month integer\n);\nCREATE TABLE male (\n name text PRIMARY KEY\n);\nCREATE TABLE no_payment_due (\n name text PRIMARY KEY,\n bool text\n);\nCREATE TABLE unemployed (\n name text PRIMARY KEY\n);\nCREATE TABLE enrolled (\n name text PRIMARY KEY,\n school text PRIMARY KEY,\n month integer\n);\n-- foreign keys: disabled.name -> person.name; enlist.name -> person.name; filed_for_bankrupcy.name -> person.name; longest_absense_from_school.name -> person.name; male.name -> person.name; no_payment_due.bool -> bool.name; no_payment_due.name -> person.name; unemployed.name -> person.name; enrolled.name -> person.name\n\nHint: employed students refers to disabled.name who are NOT in unemployed.name; zero absences refers to month = 0;\n\nQuestion: How many employed disabled students have zero absences?"}, {"role": "assistant", "content": "SELECT COUNT(T1.name) FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name INNER JOIN unemployed AS T3 ON T3.name = T2.name WHERE T1.month = 0"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE authors (\n au_id text PRIMARY KEY,\n au_lname text,\n au_fname text,\n phone text,\n address text,\n city text,\n state text,\n zip text,\n contract text\n);\nCREATE TABLE jobs (\n job_id integer PRIMARY KEY,\n job_desc text,\n min_lvl integer,\n max_lvl integer\n);\nCREATE TABLE publishers (\n pub_id text PRIMARY KEY,\n pub_name text,\n city text,\n state text,\n country text\n);\nCREATE TABLE employee (\n emp_id text PRIMARY KEY,\n fname text,\n minit text,\n lname text,\n job_id integer,\n job_lvl integer,\n pub_id text,\n hire_date datetime\n);\nCREATE TABLE pub_info (\n pub_id text PRIMARY KEY,\n logo blob,\n pr_info text\n);\nCREATE TABLE stores (\n stor_id text PRIMARY KEY,\n stor_name text,\n stor_address text,\n city text,\n state text,\n zip text\n);\nCREATE TABLE discounts (\n discounttype text,\n stor_id text,\n lowqty integer,\n highqty integer,\n discount real\n);\nCREATE TABLE titles (\n title_id text PRIMARY KEY,\n title text,\n type text,\n pub_id text,\n price real,\n advance real,\n royalty integer,\n ytd_sales integer,\n notes text,\n pubdate datetime\n);\nCREATE TABLE roysched (\n title_id text,\n lorange integer,\n hirange integer,\n royalty integer\n);\nCREATE TABLE sales (\n stor_id text PRIMARY KEY,\n ord_num text PRIMARY KEY,\n ord_date datetime,\n qty integer,\n payterms text,\n title_id text PRIMARY KEY\n);\nCREATE TABLE titleauthor (\n au_id text PRIMARY KEY,\n title_id text PRIMARY KEY,\n au_ord integer,\n royaltyper integer\n);\n-- 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\n\nHint: job level greater than 200 refers to job_lvl>200; job description refers to job_desc\n\nQuestion: Among all employees, who have job level greater than 200. State the employee name and job description."}, {"role": "assistant", "content": "SELECT T1.fname, T1.lname, T2.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.job_lvl > 200"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\ncreate table Faculty (\n FacID \t INTEGER PRIMARY KEY,\n Lname\t\tVARCHAR(15),\n Fname\t\tVARCHAR(15),\n Rank\t\tVARCHAR(15),\n Sex\t\tVARCHAR(1),\n Phone\t\tINTEGER,\n Room\t\tVARCHAR(5),\n Building\t\tVARCHAR(13)\n);\n\ncreate table Department (\n DNO \t\tINTEGER PRIMARY KEY,\n Division\t\tVARCHAR(2),\n DName\t\tVARCHAR(25),\n Room\t\tVARCHAR(5),\n Building\t\tVARCHAR(13),\n DPhone\t\tINTEGER\n);\n\ncreate table Member_of (\n FacID \t INTEGER,\n DNO\t INTEGER,\n Appt_Type VARCHAR(15),\n FOREIGN KEY(FacID) REFERENCES Faculty(FacID),\n FOREIGN KEY(DNO) REFERENCES Department(DNO)\n);\n\ncreate table Course (\n CID \t \tVARCHAR(7) PRIMARY KEY,\n CName\t\tVARCHAR(40),\n Credits\t\tINTEGER,\n Instructor\tINTEGER,\n Days\t\tVARCHAR(5),\n Hours\t\tVARCHAR(11),\n DNO\t\tINTEGER,\n FOREIGN KEY(Instructor) REFERENCES Faculty(FacID),\n FOREIGN KEY(DNO) REFERENCES Department(DNO)\n);\n\ncreate table Minor_in (\n StuID \t INTEGER,\n DNO\t\tINTEGER,\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(DNO) REFERENCES Department(DNO)\n);\n\ncreate table Enrolled_in (\n StuID \t\t INTEGER,\n CID\t\tVARCHAR(7),\n Grade\t\tVARCHAR(2),\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(CID) REFERENCES Course(CID),\n FOREIGN KEY(Grade) REFERENCES Gradeconversion(lettergrade)\n);\n\ncreate table Gradeconversion (\n lettergrade\t VARCHAR(2) PRIMARY KEY,\n gradepoint\t FLOAT\n);\n\nQuestion: Which building does the instructor who teaches the most number of courses live in?"}, {"role": "assistant", "content": "SELECT T2.Building FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID GROUP BY T1.Instructor ORDER BY count(*) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Categories (\n CategoryID integer PRIMARY KEY,\n CategoryName text,\n Description text\n);\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n CustomerName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n LastName text,\n FirstName text,\n BirthDate date,\n Photo text,\n Notes text\n);\nCREATE TABLE Shippers (\n ShipperID integer PRIMARY KEY,\n ShipperName text,\n Phone text\n);\nCREATE TABLE Suppliers (\n SupplierID integer PRIMARY KEY,\n SupplierName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text,\n Phone text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n ProductName text,\n SupplierID integer,\n CategoryID integer,\n Unit text,\n Price real\n);\nCREATE TABLE Orders (\n OrderID integer PRIMARY KEY,\n CustomerID integer,\n EmployeeID integer,\n OrderDate datetime,\n ShipperID integer\n);\nCREATE TABLE OrderDetails (\n OrderDetailID integer PRIMARY KEY,\n OrderID integer,\n ProductID integer,\n Quantity integer\n);\n-- 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\n\nHint: names of all territories refers to TerritoryDescription;\n\nQuestion: Please list the names of all the territories whose sales are taken in charge by Nancy Davolio."}, {"role": "assistant", "content": "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.FirstName = 'Nancy' AND T1.LastName = 'Davolio'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Categories (\n CategoryID integer PRIMARY KEY,\n CategoryName text,\n Description text\n);\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n CustomerName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n LastName text,\n FirstName text,\n BirthDate date,\n Photo text,\n Notes text\n);\nCREATE TABLE Shippers (\n ShipperID integer PRIMARY KEY,\n ShipperName text,\n Phone text\n);\nCREATE TABLE Suppliers (\n SupplierID integer PRIMARY KEY,\n SupplierName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text,\n Phone text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n ProductName text,\n SupplierID integer,\n CategoryID integer,\n Unit text,\n Price real\n);\nCREATE TABLE Orders (\n OrderID integer PRIMARY KEY,\n CustomerID integer,\n EmployeeID integer,\n OrderDate datetime,\n ShipperID integer\n);\nCREATE TABLE OrderDetails (\n OrderDetailID integer PRIMARY KEY,\n OrderID integer,\n ProductID integer,\n Quantity integer\n);\n-- 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\n\nHint: \"New Orleans Cajun Delights\" is the CompanyName; discontinued refers to Discontinued = 1\n\nQuestion: How many products have been discountinued by New Orleans Cajun Delights?"}, {"role": "assistant", "content": "SELECT COUNT(T1.Discontinued) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'New Orleans Cajun Delights'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE businesses (\n business_id integer PRIMARY KEY,\n name text,\n address text,\n city text,\n postal_code text,\n latitude real,\n longitude real,\n phone_number integer,\n tax_code text,\n business_certificate integer,\n application_date date,\n owner_name text,\n owner_address text,\n owner_city text,\n owner_state text,\n owner_zip text\n);\nCREATE TABLE inspections (\n business_id integer,\n score integer,\n date date,\n type text\n);\nCREATE TABLE violations (\n business_id integer,\n date date,\n violation_type_id text,\n risk_category text,\n description text\n);\n-- foreign keys: inspections.business_id -> businesses.business_id; violations.business_id -> businesses.business_id\n\nHint: businesses with a high risk category refer to business_id where risk_category = 'High Risk';\n\nQuestion: Among the businesses within the postal code 94117, what is total number of businesses with a high risk category?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT T2.business_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.postal_code = 94117 AND T1.risk_category = 'High Risk'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Customers (\nCustomer_ID INTEGER NOT NULL,\nCustomer_name VARCHAR(40),\nPRIMARY KEY (Customer_ID)\n);\n\nQuestion: Count the total number of available services."}, {"role": "assistant", "content": "SELECT count(*) FROM services"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n--data definition\n\ncreate table genre(\n\tg_name varchar2(20) not null,\n\trating varchar2(10),\n\tmost_popular_in varchar2(50),\n\tprimary key(g_name)\n);\n\ncreate table artist(\n\tartist_name varchar2(50) not null,\n\tcountry varchar2(20),\n\tgender varchar2(20),\n\tpreferred_genre varchar2(50),\n\tconstraint a_name primary key(artist_name),\n\tforeign key(preferred_genre) references genre(g_name) ON DELETE CASCADE\n);\n\ncreate table files(\n\tf_id number(10) not null,\n\tartist_name varchar2(50),\n\tfile_size varchar2(20),\n\tduration varchar2(20),\n\tformats varchar2(20),\n\tprimary key(f_id),\n\tforeign key(artist_name) references artist(artist_name) ON DELETE CASCADE\n);\n\n\ncreate table song(\n\tsong_name varchar2(50),\n\tartist_name varchar2(50),\n\tcountry varchar2(20),\n\tf_id number(10),\n \tgenre_is varchar2(20),\n\trating number(10) check(rating>0 and rating<11),\n\tlanguages varchar2(20),\n\treleasedate Date, \n\tresolution number(10) not null,\n\tconstraint s_name primary key(song_name),\n\tforeign key(artist_name) references artist(artist_name) ON DELETE CASCADE,\n\tforeign key(f_id) references files(f_id) ON DELETE CASCADE,\n\tforeign key(genre_is) references genre(g_name) ON DELETE CASCADE\n);\n\n\n--insertion of attributes in the table\n\nQuestion: Find the id of the song that lasts the longest."}, {"role": "assistant", "content": "SELECT f_id FROM files ORDER BY duration DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE characters (\n movie_title text PRIMARY KEY,\n release_date text,\n hero text,\n villian text,\n song text\n);\nCREATE TABLE director (\n name text PRIMARY KEY,\n director text\n);\nCREATE TABLE movies_total_gross (\n movie_title text PRIMARY KEY,\n release_date text PRIMARY KEY,\n genre text,\n MPAA_rating text,\n total_gross text,\n inflation_adjusted_gross text\n);\nCREATE TABLE revenue (\n Year integer PRIMARY KEY,\n Studio Entertainment[NI 1] real,\n Disney Consumer Products[NI 2] real,\n Disney Interactive[NI 3][Rev 1] integer,\n Walt Disney Parks and Resorts real,\n Disney Media Networks text,\n Total integer\n);\nCREATE TABLE voice-actors (\n character text PRIMARY KEY,\n voice-actor text,\n movie text\n);\n-- 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\n\nHint: name of the movie refers to movie_title;\n\nQuestion: Give the name of the movie which the song \"I Thought I Lost You\" is associated with."}, {"role": "assistant", "content": "SELECT movie_title FROM characters WHERE song = 'I Thought I Lost You'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Person (\n name varchar(20) PRIMARY KEY,\n age INTEGER,\n city TEXT,\n gender TEXT,\n job TEXT\n);\n\nCREATE TABLE PersonFriend (\n name varchar(20),\n friend varchar(20),\n year INTEGER,\n FOREIGN KEY (name) REFERENCES Person(name),\n FOREIGN KEY (friend) REFERENCES Person(name)\n);\n\nQuestion: What is the average age for all people in the table?"}, {"role": "assistant", "content": "SELECT avg(age) FROM Person"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE cites (\n cited_paper_id text PRIMARY KEY,\n citing_paper_id text PRIMARY KEY\n);\nCREATE TABLE paper (\n paper_id text PRIMARY KEY,\n class_label text\n);\nCREATE TABLE content (\n paper_id text PRIMARY KEY,\n word_cited_id text PRIMARY KEY\n);\n-- foreign keys: content.paper_id -> paper.paper_id\n\nHint: most cited word refers to max(count(word_cited_id);\n\nQuestion: What is the most cited word? How many papers was that word cited in?"}, {"role": "assistant", "content": "SELECT word_cited_id, COUNT(paper_id) FROM content GROUP BY word_cited_id ORDER BY COUNT(word_cited_id) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE app_all (\n app_id integer PRIMARY KEY\n);\nCREATE TABLE app_events (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_events_relevant (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_labels (\n app_id integer,\n label_id integer\n);\nCREATE TABLE events (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE events_relevant (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE gender_age (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE gender_age_test (\n device_id integer PRIMARY KEY\n);\nCREATE TABLE gender_age_train (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE label_categories (\n label_id integer PRIMARY KEY,\n category text\n);\nCREATE TABLE phone_brand_device_model2 (\n device_id integer PRIMARY KEY,\n phone_brand text PRIMARY KEY,\n device_model text PRIMARY KEY\n);\nCREATE TABLE sample_submission (\n device_id integer PRIMARY KEY,\n F23- real,\n F24-26 real,\n F27-28 real,\n F29-32 real,\n F33-42 real,\n F43+ real,\n M22- real,\n M23-26 real,\n M27-28 real,\n M29-31 real,\n M32-38 real,\n M39+ real\n);\n-- 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\n\nHint: active refers to is_active = 1;\n\nQuestion: How many active users are there in the event?"}, {"role": "assistant", "content": "SELECT COUNT(app_id) FROM app_events WHERE is_active = 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: 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\n\nQuestion: Find out which business is opened for 24/7 and list out what is the business attribute."}, {"role": "assistant", "content": "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"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Addresses (\naddress_id INTEGER NOT NULL,\nline_1 VARCHAR(80),\nline_2 VARCHAR(80),\ncity VARCHAR(50),\nzip_postcode CHAR(20),\nstate_province_county VARCHAR(50),\ncountry VARCHAR(50),\nPRIMARY KEY (address_id)\n);\n\nQuestion: How many students are attending English courses?"}, {"role": "assistant", "content": "SELECT count(*) FROM courses AS T1 JOIN student_course_attendance AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = \"English\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Investors` (\n`investor_id` INTEGER PRIMARY KEY,\n`Investor_details` VARCHAR(255)\n);\n\nQuestion: What are the dates of transactions with at least 100 share count or amount bigger than 100?"}, {"role": "assistant", "content": "SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count >= 100 OR amount_of_transaction >= 100"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE \"Rooms\" ( \n\t\"RoomId\" TEXT PRIMARY KEY,\n\t\"roomName\" TEXT, \n\t\"beds\" INTEGER, \n\t\"bedType\" TEXT, \n\t\"maxOccupancy\" INTEGER, \n\t\"basePrice\" INTEGER, \n\t\"decor\" TEXT\n\n);\n\nCREATE TABLE \"Reservations\" ( \n\t\"Code\" INTEGER PRIMARY KEY, \n\t\"Room\" TEXT, \n\t\"CheckIn\" TEXT, \n\t\"CheckOut\" TEXT, \n\t\"Rate\" REAL, \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Adults\" INTEGER, \n\t\"Kids\" INTEGER,\n\tFOREIGN KEY (Room) REFERENCES Rooms(RoomId)\n);\n\nQuestion: How many times does ROY SWEAZY has reserved a room."}, {"role": "assistant", "content": "SELECT count(*) FROM Reservations WHERE FirstName = \"ROY\" AND LastName = \"SWEAZY\";"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE actor (\n ActorID integer PRIMARY KEY,\n Name text,\n Date of Birth date,\n Birth City text,\n Birth Country text,\n Height (Inches) integer,\n Biography text,\n Gender text,\n Ethnicity text,\n NetWorth text\n);\nCREATE TABLE movie (\n MovieID integer PRIMARY KEY,\n Title text,\n MPAA Rating text,\n Budget integer,\n Gross integer,\n Release Date text,\n Genre text,\n Runtime integer,\n Rating real,\n Rating Count integer,\n Summary text\n);\nCREATE TABLE characters (\n MovieID integer PRIMARY KEY,\n ActorID integer PRIMARY KEY,\n Character Name text,\n creditOrder integer,\n pay text,\n screentime text\n);\n-- foreign keys: characters.MovieID -> movie.MovieID; characters.ActorID -> actor.ActorID\n\nHint: biggest budget refers to max(Budget); name of the movie refers to Title\n\nQuestion: Which movie had the biggest budget? Give the name of the movie."}, {"role": "assistant", "content": "SELECT Title FROM movie ORDER BY Budget DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE torrents (\n groupName text,\n totalSnatched integer,\n artist text,\n groupYear integer,\n releaseType text,\n groupId integer,\n id integer PRIMARY KEY\n);\nCREATE TABLE tags (\n index integer PRIMARY KEY,\n id integer,\n tag text\n);\n\nHint: tag = 'pop';\n\nQuestion: How many releases by the artist michael jackson are tagged \"pop\"?"}, {"role": "assistant", "content": "SELECT COUNT(T1.groupName) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'pop' AND T1.artist = 'michael jackson'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE City (\n ID integer PRIMARY KEY,\n Name text,\n CountryCode text,\n District text,\n Population integer\n);\nCREATE TABLE Country (\n Code text PRIMARY KEY,\n Name text,\n Continent text,\n Region text,\n SurfaceArea real,\n IndepYear integer,\n Population integer,\n LifeExpectancy real,\n GNP real,\n GNPOld real,\n LocalName text,\n GovernmentForm text,\n HeadOfState text,\n Capital integer,\n Code2 text\n);\nCREATE TABLE CountryLanguage (\n CountryCode text PRIMARY KEY,\n Language text PRIMARY KEY,\n IsOfficial text,\n Percentage real\n);\n-- foreign keys: City.CountryCode -> Country.Code; CountryLanguage.CountryCode -> Country.Code\n\nHint: independence year between 1980 to 1995 refers to IndepYear BETWEEN 1980 AND 1995;\n\nQuestion: List down the languages of countries with an independence year between 1980 to 1995."}, {"role": "assistant", "content": "SELECT T2.Name, T1.Language FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.IndepYear BETWEEN 1980 AND 1995"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE ranking_system (\n id integer PRIMARY KEY,\n system_name text\n);\nCREATE TABLE ranking_criteria (\n id integer PRIMARY KEY,\n ranking_system_id integer,\n criteria_name text\n);\nCREATE TABLE university (\n id integer PRIMARY KEY,\n country_id integer,\n university_name text\n);\nCREATE TABLE university_ranking_year (\n university_id integer,\n ranking_criteria_id integer,\n year integer,\n score integer\n);\nCREATE TABLE university_year (\n university_id integer,\n year integer,\n num_students integer,\n student_staff_ratio real,\n pct_international_students integer,\n pct_female_students integer\n);\n-- 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\n\nHint: average number of students refers to avg(num_students); in 2012 refers to year = 2012\n\nQuestion: Calculate the average number of students of all universities in 2012."}, {"role": "assistant", "content": "SELECT AVG(num_students) FROM university_year WHERE year = 2012"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nHint: duration between 100 to 110 minutes refers to length between 100 and 110\n\nQuestion: How many films have a duration between 100 to 110 minutes?"}, {"role": "assistant", "content": "SELECT COUNT(film_id) FROM film WHERE length BETWEEN 100 AND 110"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE lists (\n user_id integer,\n list_id integer PRIMARY KEY,\n list_title text,\n list_movie_number integer,\n list_update_timestamp_utc text,\n list_creation_timestamp_utc text,\n list_followers integer,\n list_url text,\n list_comments integer,\n list_description text,\n list_cover_image_url text,\n list_first_image_url text,\n list_second_image_url text,\n list_third_image_url text\n);\nCREATE TABLE movies (\n movie_id integer PRIMARY KEY,\n movie_title text,\n movie_release_year integer,\n movie_url text,\n movie_title_language text,\n movie_popularity integer,\n movie_image_url text,\n director_id text,\n director_name text,\n director_url text\n);\nCREATE TABLE ratings_users (\n user_id integer,\n rating_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\nCREATE TABLE lists_users (\n user_id integer PRIMARY KEY,\n list_id integer PRIMARY KEY,\n list_update_date_utc text,\n list_creation_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial text,\n user_has_payment_method text\n);\nCREATE TABLE ratings (\n movie_id integer,\n rating_id integer,\n rating_url text,\n rating_score integer,\n rating_timestamp_utc text,\n critic text,\n critic_likes integer,\n critic_comments integer,\n user_id integer,\n user_trialist integer,\n user_subscriber integer,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\n-- 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\n\nHint: movie released in 2021 refers to movie_release_year = 2021; popularity refers to movie_popularity;\n\nQuestion: What are the movie popularity of the movies released in 2021 that were directed by Steven Spielberg? List the names of the movies and their corresponding popularity."}, {"role": "assistant", "content": "SELECT movie_title, movie_popularity FROM movies WHERE movie_release_year = 2021 AND director_name = 'Steven Spielberg'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"people\" (\n\"People_ID\" int,\n\"District\" text,\n\"Name\" text,\n\"Party\" text,\n\"Age\" int,\nPRIMARY KEY (\"People_ID\")\n);\n\nCREATE TABLE \"debate\" (\n\"Debate_ID\" int,\n\"Date\" text,\n\"Venue\" text,\n\"Num_of_Audience\" int,\nPRIMARY KEY (\"Debate_ID\")\n);\n\nQuestion: How many debates are there?"}, {"role": "assistant", "content": "SELECT count(*) FROM debate"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE Customers (\nCustomer_ID INTEGER NOT NULL,\nCustomer_Details VARCHAR(255) NOT NULL,\nPRIMARY KEY (Customer_ID)\n);\n\nQuestion: Count the number of distinct claim outcome codes."}, {"role": "assistant", "content": "SELECT count(DISTINCT claim_outcome_code) FROM claims_processing"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country_iso_code text,\n country_name text\n);\nCREATE TABLE department (\n department_id integer PRIMARY KEY,\n department_name text\n);\nCREATE TABLE gender (\n gender_id integer PRIMARY KEY,\n gender text\n);\nCREATE TABLE genre (\n genre_id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE keyword (\n keyword_id integer PRIMARY KEY,\n keyword_name text\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n language_code text,\n language_name text\n);\nCREATE TABLE language_role (\n role_id integer PRIMARY KEY,\n language_role text\n);\nCREATE TABLE movie (\n movie_id integer PRIMARY KEY,\n title text,\n budget integer,\n homepage text,\n overview text,\n popularity real,\n release_date date,\n revenue integer,\n runtime integer,\n movie_status text,\n tagline text,\n vote_average real,\n vote_count integer\n);\nCREATE TABLE movie_genres (\n movie_id integer,\n genre_id integer\n);\nCREATE TABLE movie_languages (\n movie_id integer,\n language_id integer,\n language_role_id integer\n);\nCREATE TABLE person (\n person_id integer PRIMARY KEY,\n person_name text\n);\nCREATE TABLE movie_crew (\n movie_id integer,\n person_id integer,\n department_id integer,\n job text\n);\nCREATE TABLE production_company (\n company_id integer PRIMARY KEY,\n company_name text\n);\nCREATE TABLE production_country (\n movie_id integer,\n country_id integer\n);\nCREATE TABLE movie_cast (\n movie_id integer,\n person_id integer,\n character_name text,\n gender_id integer,\n cast_order integer\n);\nCREATE TABLE movie_keywords (\n movie_id integer,\n keyword_id integer\n);\nCREATE TABLE movie_company (\n movie_id integer,\n company_id integer\n);\n-- foreign keys: movie_genres.movie_id -> movie.movie_id; movie_genres.genre_id -> genre.genre_id; movie_languages.language_role_id -> language_role.role_id; movie_languages.movie_id -> movie.movie_id; movie_languages.language_id -> language.language_id; movie_crew.person_id -> person.person_id; movie_crew.movie_id -> movie.movie_id; movie_crew.department_id -> department.department_id; production_country.movie_id -> movie.movie_id; production_country.country_id -> country.country_id; movie_cast.person_id -> person.person_id; movie_cast.movie_id -> movie.movie_id; movie_cast.gender_id -> gender.gender_id\n\nHint: Warner Bros. Pictures' movies refers to company_name = 'Warner Bros. Pictures'; highest revenue refers to max(revenue)\n\nQuestion: Among Warner Bros. Pictures' movies, which title made the highest revenue?"}, {"role": "assistant", "content": "SELECT T3.title FROM production_company AS T1 INNER JOIN movie_company AS T2 ON T1.company_id = T2.company_id INNER JOIN movie AS T3 ON T2.movie_id = T3.movie_id WHERE T1.company_name = 'Warner Bros. Pictures' ORDER BY T3.revenue DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE customer (\n c_custkey integer PRIMARY KEY,\n c_mktsegment text,\n c_nationkey integer,\n c_name text,\n c_address text,\n c_phone text,\n c_acctbal real,\n c_comment text\n);\nCREATE TABLE lineitem (\n l_shipdate date,\n l_orderkey integer PRIMARY KEY,\n l_discount real,\n l_extendedprice real,\n l_suppkey integer,\n l_quantity integer,\n l_returnflag text,\n l_partkey integer,\n l_linestatus text,\n l_tax real,\n l_commitdate date,\n l_receiptdate date,\n l_shipmode text,\n l_linenumber integer PRIMARY KEY,\n l_shipinstruct text,\n l_comment text\n);\nCREATE TABLE nation (\n n_nationkey integer PRIMARY KEY,\n n_name text,\n n_regionkey integer,\n n_comment text\n);\nCREATE TABLE orders (\n o_orderdate date,\n o_orderkey integer PRIMARY KEY,\n o_custkey integer,\n o_orderpriority text,\n o_shippriority integer,\n o_clerk text,\n o_orderstatus text,\n o_totalprice real,\n o_comment text\n);\nCREATE TABLE part (\n p_partkey integer PRIMARY KEY,\n p_type text,\n p_size integer,\n p_brand text,\n p_name text,\n p_container text,\n p_mfgr text,\n p_retailprice real,\n p_comment text\n);\nCREATE TABLE partsupp (\n ps_partkey integer PRIMARY KEY,\n ps_suppkey integer PRIMARY KEY,\n ps_supplycost real,\n ps_availqty integer,\n ps_comment text\n);\nCREATE TABLE region (\n r_regionkey integer PRIMARY KEY,\n r_name text,\n r_comment text\n);\nCREATE TABLE supplier (\n s_suppkey integer PRIMARY KEY,\n s_nationkey integer,\n s_comment text,\n s_name text,\n s_address text,\n s_phone text,\n s_acctbal real\n);\n-- foreign keys: customer.c_nationkey -> nation.n_nationkey; lineitem.l_partkey -> partsupp.ps_partkey; lineitem.l_suppkey -> partsupp.ps_suppkey; lineitem.l_orderkey -> orders.o_orderkey; nation.n_regionkey -> region.r_regionkey; orders.o_custkey -> customer.c_custkey; partsupp.ps_suppkey -> supplier.s_suppkey; partsupp.ps_partkey -> part.p_partkey; supplier.s_nationkey -> nation.n_nationkey\n\nHint: customer phone refers to c_phone; Customer#000000001 refers to c_name;\n\nQuestion: What is the phone number of Customer#000000001?"}, {"role": "assistant", "content": "SELECT c_phone FROM customer WHERE c_name = 'Customer#000000001'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE station (\n id INTEGER PRIMARY KEY,\n name TEXT,\n lat NUMERIC,\n long NUMERIC,\n dock_count INTEGER,\n city TEXT,\n installation_date TEXT);\n\nQuestion: Find the ids and names of stations from which at least 200 trips started."}, {"role": "assistant", "content": "SELECT start_station_id , start_station_name FROM trip GROUP BY start_station_name HAVING COUNT(*) >= 200"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE ATT_CLASSES (\n ATT_CLASS_ID integer PRIMARY KEY,\n ATT_CLASS text\n);\nCREATE TABLE OBJ_CLASSES (\n OBJ_CLASS_ID integer PRIMARY KEY,\n OBJ_CLASS text\n);\nCREATE TABLE IMG_OBJ (\n IMG_ID integer PRIMARY KEY,\n OBJ_SAMPLE_ID integer PRIMARY KEY,\n OBJ_CLASS_ID integer,\n X integer,\n Y integer,\n W integer,\n H integer\n);\nCREATE TABLE IMG_OBJ_ATT (\n IMG_ID integer PRIMARY KEY,\n ATT_CLASS_ID integer PRIMARY KEY,\n OBJ_SAMPLE_ID integer PRIMARY KEY\n);\nCREATE TABLE PRED_CLASSES (\n PRED_CLASS_ID integer PRIMARY KEY,\n PRED_CLASS text\n);\nCREATE TABLE IMG_REL (\n IMG_ID integer PRIMARY KEY,\n PRED_CLASS_ID integer PRIMARY KEY,\n OBJ1_SAMPLE_ID integer PRIMARY KEY,\n OBJ2_SAMPLE_ID integer PRIMARY KEY\n);\n-- 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\n\nHint: DIVIDE(COUNT(OBJ_SAMPLE_ID where OBJ_CLASS = 'street lights'), COUNT(OBJ_SAMPLE_ID)) as percentage;\n\nQuestion: Calculate the percentage of object samples that are related to street lights."}, {"role": "assistant", "content": "SELECT CAST(SUM(CASE WHEN T2.OBJ_CLASS = 'street lights' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.OBJ_SAMPLE_ID) FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"publication\" (\n\"Publication_ID\" int,\n\"Book_ID\" int,\n\"Publisher\" text,\n\"Publication_Date\" text,\n\"Price\" real,\nPRIMARY KEY (\"Publication_ID\"),\nFOREIGN KEY (\"Book_ID\") REFERENCES \"book\"(\"Book_ID\")\n);\n\nCREATE TABLE \"book\" (\n\"Book_ID\" int,\n\"Title\" text,\n\"Issues\" real,\n\"Writer\" text,\nPRIMARY KEY (\"Book_ID\")\n);\n\nQuestion: Show the publishers that have publications with price higher than 10000000 and publications with price lower than 5000000."}, {"role": "assistant", "content": "SELECT Publisher FROM publication WHERE Price > 10000000 INTERSECT SELECT Publisher FROM publication WHERE Price < 5000000"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"film\" (\n\"Film_ID\" int,\n\"Rank_in_series\" int,\n\"Number_in_season\" int,\n\"Title\" text,\n\"Directed_by\" text,\n\"Original_air_date\" text,\n\"Production_code\" text,\nPRIMARY KEY (\"Film_ID\")\n);\n\nCREATE TABLE \"cinema\" (\n\"Cinema_ID\" int,\n\"Name\" text,\n\"Openning_year\" int,\n\"Capacity\" int,\n\"Location\" text,\nPRIMARY KEY (\"Cinema_ID\"));\n\nQuestion: Show all the locations where no cinema has capacity over 800."}, {"role": "assistant", "content": "SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE station (\n id integer PRIMARY KEY,\n name text,\n lat real,\n long real,\n dock_count integer,\n city text,\n installation_date text\n);\nCREATE TABLE status (\n station_id integer,\n bikes_available integer,\n docks_available integer,\n time text\n);\nCREATE TABLE trip (\n id integer PRIMARY KEY,\n duration integer,\n start_date text,\n start_station_name text,\n start_station_id integer,\n end_date text,\n end_station_name text,\n end_station_id integer,\n bike_id integer,\n subscription_type text,\n zip_code integer\n);\nCREATE TABLE weather (\n date text,\n max_temperature_f integer,\n mean_temperature_f integer,\n min_temperature_f integer,\n max_dew_point_f integer,\n mean_dew_point_f integer,\n min_dew_point_f integer,\n max_humidity integer,\n mean_humidity integer,\n min_humidity integer,\n max_sea_level_pressure_inches real,\n mean_sea_level_pressure_inches real,\n min_sea_level_pressure_inches real,\n max_visibility_miles integer,\n mean_visibility_miles integer,\n min_visibility_miles integer,\n max_wind_Speed_mph integer,\n mean_wind_speed_mph integer,\n max_gust_speed_mph integer,\n precipitation_inches text,\n cloud_cover integer,\n events text,\n wind_dir_degrees integer,\n zip_code text\n);\n\nHint: 37.331415 and -121.8932 are latitude (lat) and longitude (long) coordinates indicating location; returned at refers to end_station_name; the date the bike was borrowed refers to start_date;\n\nQuestion: List all trips where bikes were returned at location 37.331415, -121.8932. State the date the bike was borrowed."}, {"role": "assistant", "content": "SELECT T2.end_station_name, T2.start_date FROM station AS T1 INNER JOIN trip AS T2 ON T2.end_station_name = T1.name WHERE T1.lat = 37.331415 AND T1.long = -121.8932"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Person (\n name varchar(20) PRIMARY KEY,\n age INTEGER,\n city TEXT,\n gender TEXT,\n job TEXT\n);\n\nCREATE TABLE PersonFriend (\n name varchar(20),\n friend varchar(20),\n year INTEGER,\n FOREIGN KEY (name) REFERENCES Person(name),\n FOREIGN KEY (friend) REFERENCES Person(name)\n);\n\nQuestion: What is minimum age for different job title?"}, {"role": "assistant", "content": "SELECT min(age) , job FROM Person GROUP BY job"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`address_content` VARCHAR(80),\n`city` VARCHAR(50),\n`zip_postcode` VARCHAR(20),\n`state_province_county` VARCHAR(50),\n`country` VARCHAR(50),\n`other_address_details` VARCHAR(255)\n);\n\nQuestion: What are the cities no customers live in?"}, {"role": "assistant", "content": "SELECT city FROM addresses WHERE city NOT IN ( SELECT DISTINCT t3.city FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Course_Authors_and_Tutors` (\n`author_id` INTEGER PRIMARY KEY,\n`author_tutor_ATB` VARCHAR(3),\n`login_name` VARCHAR(40),\n`password` VARCHAR(40),\n`personal_name` VARCHAR(80),\n`middle_name` VARCHAR(80),\n`family_name` VARCHAR(80),\n`gender_mf` VARCHAR(1),\n`address_line_1` VARCHAR(80)\n);\n\nQuestion: Sort the information about course authors and tutors in alphabetical order of the personal name."}, {"role": "assistant", "content": "SELECT * FROM Course_Authors_and_Tutors ORDER BY personal_name"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city_name text,\n state text,\n population integer,\n area real\n);\nCREATE TABLE customer (\n cust_id integer PRIMARY KEY,\n cust_name text,\n annual_revenue integer,\n cust_type text,\n address text,\n city text,\n state text,\n zip real,\n phone text\n);\nCREATE TABLE driver (\n driver_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address text,\n city text,\n state text,\n zip_code integer,\n phone text\n);\nCREATE TABLE truck (\n truck_id integer PRIMARY KEY,\n make text,\n model_year integer\n);\nCREATE TABLE shipment (\n ship_id integer PRIMARY KEY,\n cust_id integer,\n weight real,\n truck_id integer,\n driver_id integer,\n city_id integer,\n ship_date text\n);\n-- 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\n\nHint: \"Klett & Sons Repair\" is the cust_name\n\nQuestion: What is the annual revenue of Klett & Sons Repair?"}, {"role": "assistant", "content": "SELECT annual_revenue FROM customer WHERE cust_name = 'Klett & Sons Repair'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE genre (\n id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE game (\n id integer PRIMARY KEY,\n genre_id integer,\n game_name text\n);\nCREATE TABLE platform (\n id integer PRIMARY KEY,\n platform_name text\n);\nCREATE TABLE publisher (\n id integer PRIMARY KEY,\n publisher_name text\n);\nCREATE TABLE game_publisher (\n id integer PRIMARY KEY,\n game_id integer,\n publisher_id integer\n);\nCREATE TABLE game_platform (\n id integer PRIMARY KEY,\n game_publisher_id integer,\n platform_id integer,\n release_year integer\n);\nCREATE TABLE region (\n id integer PRIMARY KEY,\n region_name text\n);\nCREATE TABLE region_sales (\n region_id integer,\n game_platform_id integer,\n num_sales real\n);\n-- 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\n\nHint: name of games refers to game_name;\u00a0 'SCD' platform refers to platform_name = 'SCD';\n\nQuestion: Indicate the name of all the games published for the 'SCD' platform."}, {"role": "assistant", "content": "SELECT T1.game_name FROM game AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.game_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 T4.platform_name = 'SCD'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE bool (\n name text PRIMARY KEY\n);\nCREATE TABLE person (\n name text PRIMARY KEY\n);\nCREATE TABLE disabled (\n name text PRIMARY KEY\n);\nCREATE TABLE enlist (\n name text,\n organ text\n);\nCREATE TABLE filed_for_bankrupcy (\n name text PRIMARY KEY\n);\nCREATE TABLE longest_absense_from_school (\n name text PRIMARY KEY,\n month integer\n);\nCREATE TABLE male (\n name text PRIMARY KEY\n);\nCREATE TABLE no_payment_due (\n name text PRIMARY KEY,\n bool text\n);\nCREATE TABLE unemployed (\n name text PRIMARY KEY\n);\nCREATE TABLE enrolled (\n name text PRIMARY KEY,\n school text PRIMARY KEY,\n month integer\n);\n-- foreign keys: disabled.name -> person.name; enlist.name -> person.name; filed_for_bankrupcy.name -> person.name; longest_absense_from_school.name -> person.name; male.name -> person.name; no_payment_due.bool -> bool.name; no_payment_due.name -> person.name; unemployed.name -> person.name; enrolled.name -> person.name\n\nHint: no due payments refers to bool = 'neg'; not males refers to not in male table\n\nQuestion: List 10 students that have no due payments and are not males."}, {"role": "assistant", "content": "SELECT T1.name FROM no_payment_due AS T1 INNER JOIN person AS T2 ON T1.`name` = T2.`name` WHERE T2.`name` NOT IN ( SELECT name FROM male ) AND T1.bool = 'neg'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE ATT_CLASSES (\n ATT_CLASS_ID integer PRIMARY KEY,\n ATT_CLASS text\n);\nCREATE TABLE OBJ_CLASSES (\n OBJ_CLASS_ID integer PRIMARY KEY,\n OBJ_CLASS text\n);\nCREATE TABLE IMG_OBJ (\n IMG_ID integer PRIMARY KEY,\n OBJ_SAMPLE_ID integer PRIMARY KEY,\n OBJ_CLASS_ID integer,\n X integer,\n Y integer,\n W integer,\n H integer\n);\nCREATE TABLE IMG_OBJ_ATT (\n IMG_ID integer PRIMARY KEY,\n ATT_CLASS_ID integer PRIMARY KEY,\n OBJ_SAMPLE_ID integer PRIMARY KEY\n);\nCREATE TABLE PRED_CLASSES (\n PRED_CLASS_ID integer PRIMARY KEY,\n PRED_CLASS text\n);\nCREATE TABLE IMG_REL (\n IMG_ID integer PRIMARY KEY,\n PRED_CLASS_ID integer PRIMARY KEY,\n OBJ1_SAMPLE_ID integer PRIMARY KEY,\n OBJ2_SAMPLE_ID integer PRIMARY KEY\n);\n-- 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\n\nHint: predicate class of image ID 68 refers to PRED_CLASS where IMG_ID = 68;\n\nQuestion: What is the predicate class of image ID 68?"}, {"role": "assistant", "content": "SELECT T2.PRED_CLASS FROM IMG_REL AS T1 INNER JOIN PRED_CLASSES AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T1.IMG_ID = 68"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE app_all (\n app_id integer PRIMARY KEY\n);\nCREATE TABLE app_events (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_events_relevant (\n event_id integer PRIMARY KEY,\n app_id integer PRIMARY KEY,\n is_installed integer,\n is_active integer\n);\nCREATE TABLE app_labels (\n app_id integer,\n label_id integer\n);\nCREATE TABLE events (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE events_relevant (\n event_id integer PRIMARY KEY,\n device_id integer,\n timestamp datetime,\n longitude real,\n latitude real\n);\nCREATE TABLE gender_age (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE gender_age_test (\n device_id integer PRIMARY KEY\n);\nCREATE TABLE gender_age_train (\n device_id integer PRIMARY KEY,\n gender text,\n age integer,\n group text\n);\nCREATE TABLE label_categories (\n label_id integer PRIMARY KEY,\n category text\n);\nCREATE TABLE phone_brand_device_model2 (\n device_id integer PRIMARY KEY,\n phone_brand text PRIMARY KEY,\n device_model text PRIMARY KEY\n);\nCREATE TABLE sample_submission (\n device_id integer PRIMARY KEY,\n F23- real,\n F24-26 real,\n F27-28 real,\n F29-32 real,\n F33-42 real,\n F43+ real,\n M22- real,\n M23-26 real,\n M27-28 real,\n M29-31 real,\n M32-38 real,\n M39+ real\n);\n-- 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\n\nHint: brand of phone refers to phone_brand; most applications are installed refers to MAX(COUNT(is_installed = 1));\n\nQuestion: On which brand of phone are the most applications installed?"}, {"role": "assistant", "content": "SELECT T.phone_brand FROM ( SELECT T1.phone_brand, COUNT(T4.is_active) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id INNER JOIN events_relevant AS T3 ON T2.device_id = T3.device_id INNER JOIN app_events_relevant AS T4 ON T3.event_id = T4.event_id WHERE T4.is_active = 1 GROUP BY T1.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Author (\n Id integer PRIMARY KEY,\n Name text,\n Affiliation text\n);\nCREATE TABLE Conference (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Journal (\n Id integer PRIMARY KEY,\n ShortName text,\n FullName text,\n HomePage text\n);\nCREATE TABLE Paper (\n Id integer PRIMARY KEY,\n Title text,\n Year integer,\n ConferenceId integer,\n JournalId integer,\n Keyword text\n);\nCREATE TABLE PaperAuthor (\n PaperId integer,\n AuthorId integer,\n Name text,\n Affiliation text\n);\n-- foreign keys: Paper.JournalId -> Journal.Id; Paper.ConferenceId -> Conference.Id; PaperAuthor.AuthorId -> Author.Id; PaperAuthor.PaperId -> Paper.Id\n\nHint: \"University of Oulu\" is the Affiliation Organization\n\nQuestion: Write down the author's name and IDs who are affiliated with Univeristiy of Oulu."}, {"role": "assistant", "content": "SELECT Name, id FROM Author WHERE Affiliation = 'University of Oulu'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Customers` (\n`customer_id` INTEGER PRIMARY KEY,\n`customer_first_name` VARCHAR(50),\n`customer_middle_initial` VARCHAR(1),\n`customer_last_name` VARCHAR(50),\n`gender` VARCHAR(1),\n`email_address` VARCHAR(255),\n`login_name` VARCHAR(80),\n`login_password` VARCHAR(20),\n`phone_number` VARCHAR(255),\n`town_city` VARCHAR(50),\n`state_county_province` VARCHAR(50),\n`country` VARCHAR(50)\n);\n\nQuestion: Show first name and id for all customers with at least 2 accounts."}, {"role": "assistant", "content": "SELECT T2.customer_first_name , T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 2"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n/* \n * SQL scripts for CS61 Intro to SQL lectures\n * FILENAME SOCCER2.SQL\n */\n\nDROP TABLE IF EXISTS Player;\nDROP TABLE IF EXISTS Tryout;\nDROP TABLE IF EXISTS College;\n\nCREATE TABLE \tCollege \n ( cName \tvarchar(20) NOT NULL,\n state \tvarchar(2),\n enr \tnumeric(5,0),\n PRIMARY KEY (cName)\n );\n\nCREATE TABLE \tPlayer\n ( pID\t\t\tnumeric(5,0) NOT NULL,\n \tpName \tvarchar(20),\n yCard \tvarchar(3),\n HS \tnumeric(5,0),\n PRIMARY KEY (pID)\n );\n\nCREATE TABLE \tTryout\n ( pID\t\t\tnumeric(5,0),\n \tcName \tvarchar(20),\n pPos \tvarchar(8),\n decision varchar(3),\n PRIMARY KEY (pID, cName),\n FOREIGN KEY (pID) REFERENCES Player(pID),\n FOREIGN KEY (cName) REFERENCES College(cName)\n );\n\n/* note that \"left\" and \"right\" are reserved words in SQL */\n\nQuestion: Find the name of players whose card is yes in the descending order of training hours."}, {"role": "assistant", "content": "SELECT pName FROM Player WHERE yCard = 'yes' ORDER BY HS DESC"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Customers` (\n`customer_id` INTEGER PRIMARY KEY,\n`customer_first_name` VARCHAR(50),\n`customer_middle_initial` VARCHAR(1),\n`customer_last_name` VARCHAR(50),\n`gender` VARCHAR(1),\n`email_address` VARCHAR(255),\n`login_name` VARCHAR(80),\n`login_password` VARCHAR(20),\n`phone_number` VARCHAR(255),\n`town_city` VARCHAR(50),\n`state_county_province` VARCHAR(50),\n`country` VARCHAR(50)\n);\n\nQuestion: Show the transaction types and the total amount of transactions."}, {"role": "assistant", "content": "SELECT transaction_type , sum(transaction_amount) FROM Financial_transactions GROUP BY transaction_type"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- dbext:type=SQLITE:dbname=movie_rating.db\n\n/* Delete the tables if they already exist */\ndrop table if exists Movie;\ndrop table if exists Reviewer;\ndrop table if exists Rating;\n\n/* Create the schema for our tables */\ncreate table Movie(\n\tmID int primary key, \n\ttitle text, \n\tyear int, \n\tdirector text\n);\ncreate table Reviewer(\n\trID int primary key, \n\tname text);\n\ncreate table Rating(\n\trID int, \n\tmID int, \n\tstars int, \n\tratingDate date,\n\tFOREIGN KEY (mID) references Movie(mID),\n\tFOREIGN KEY (rID) references Reviewer(rID)\n);\n\n/* Populate the tables with our data */\n\nQuestion: What are the names of the directors who created a movie with a 5 star rating, and what was the name of those movies?"}, {"role": "assistant", "content": "SELECT T1.director , T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"country\" (\n \"Country_id\" int,\n \"Country_name\" text,\n \"Capital\" text,\n \"Official_native_language\" text,\n PRIMARY KEY (\"Country_id\")\n);\n\n\nCREATE TABLE `team` (\n `Team_id` int,\n `Name` text,\n PRIMARY KEY (`Team_id`)\n) ;\n\nQuestion: Return the official native languages of countries who have players from Maryland or Duke colleges."}, {"role": "assistant", "content": "SELECT T1.Official_native_language FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.College = \"Maryland\" OR T2.College = \"Duke\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE ATT_CLASSES (\n ATT_CLASS_ID integer PRIMARY KEY,\n ATT_CLASS text\n);\nCREATE TABLE OBJ_CLASSES (\n OBJ_CLASS_ID integer PRIMARY KEY,\n OBJ_CLASS text\n);\nCREATE TABLE IMG_OBJ (\n IMG_ID integer PRIMARY KEY,\n OBJ_SAMPLE_ID integer PRIMARY KEY,\n OBJ_CLASS_ID integer,\n X integer,\n Y integer,\n W integer,\n H integer\n);\nCREATE TABLE IMG_OBJ_ATT (\n IMG_ID integer PRIMARY KEY,\n ATT_CLASS_ID integer PRIMARY KEY,\n OBJ_SAMPLE_ID integer PRIMARY KEY\n);\nCREATE TABLE PRED_CLASSES (\n PRED_CLASS_ID integer PRIMARY KEY,\n PRED_CLASS text\n);\nCREATE TABLE IMG_REL (\n IMG_ID integer PRIMARY KEY,\n PRED_CLASS_ID integer PRIMARY KEY,\n OBJ1_SAMPLE_ID integer PRIMARY KEY,\n OBJ2_SAMPLE_ID integer PRIMARY KEY\n);\n-- 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\n\nHint: attributes of polka dot refer to ATT_CLASS = 'polka dot'; images refer to IMG_ID;\n\nQuestion: How many images have objects with the attributes of polka dot?"}, {"role": "assistant", "content": "SELECT COUNT(T2.OBJ_SAMPLE_ID) FROM ATT_CLASSES AS T1 INNER JOIN IMG_OBJ_ATT AS T2 ON T1.ATT_CLASS_ID = T2.ATT_CLASS_ID WHERE T1.ATT_CLASS = 'polka dot'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE lists (\n user_id integer,\n list_id integer PRIMARY KEY,\n list_title text,\n list_movie_number integer,\n list_update_timestamp_utc text,\n list_creation_timestamp_utc text,\n list_followers integer,\n list_url text,\n list_comments integer,\n list_description text,\n list_cover_image_url text,\n list_first_image_url text,\n list_second_image_url text,\n list_third_image_url text\n);\nCREATE TABLE movies (\n movie_id integer PRIMARY KEY,\n movie_title text,\n movie_release_year integer,\n movie_url text,\n movie_title_language text,\n movie_popularity integer,\n movie_image_url text,\n director_id text,\n director_name text,\n director_url text\n);\nCREATE TABLE ratings_users (\n user_id integer,\n rating_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\nCREATE TABLE lists_users (\n user_id integer PRIMARY KEY,\n list_id integer PRIMARY KEY,\n list_update_date_utc text,\n list_creation_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial text,\n user_has_payment_method text\n);\nCREATE TABLE ratings (\n movie_id integer,\n rating_id integer,\n rating_url text,\n rating_score integer,\n rating_timestamp_utc text,\n critic text,\n critic_likes integer,\n critic_comments integer,\n user_id integer,\n user_trialist integer,\n user_subscriber integer,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\n-- 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\n\nHint: head portrait refers to user_avatar_image_url; \"5\" ratings refers to rating_score = 5\n\nQuestion: Show the head portrait of the user who gave the most \"5\" ratings."}, {"role": "assistant", "content": "SELECT T2.user_avatar_image_url FROM ratings AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id WHERE T1.rating_score = 5"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Community_Area (\n community_area_no integer PRIMARY KEY,\n community_area_name text,\n side text,\n population text\n);\nCREATE TABLE District (\n district_no integer PRIMARY KEY,\n district_name text,\n address text,\n zip_code integer,\n commander text,\n email text,\n phone text,\n fax text,\n tty text,\n twitter text\n);\nCREATE TABLE FBI_Code (\n fbi_code_no text PRIMARY KEY,\n title text,\n description text,\n crime_against text\n);\nCREATE TABLE IUCR (\n iucr_no text PRIMARY KEY,\n primary_description text,\n secondary_description text,\n index_code text\n);\nCREATE TABLE Neighborhood (\n neighborhood_name text PRIMARY KEY,\n community_area_no integer\n);\nCREATE TABLE Ward (\n ward_no integer PRIMARY KEY,\n alderman_first_name text,\n alderman_last_name text,\n alderman_name_suffix text,\n ward_office_address text,\n ward_office_zip text,\n ward_email text,\n ward_office_phone text,\n ward_office_fax text,\n city_hall_office_room integer,\n city_hall_office_phone text,\n city_hall_office_fax text,\n Population integer\n);\nCREATE TABLE Crime (\n report_no integer PRIMARY KEY,\n case_number text,\n date text,\n block text,\n iucr_no text,\n location_description text,\n arrest text,\n domestic text,\n beat integer,\n district_no integer,\n ward_no integer,\n community_area_no integer,\n fbi_code_no text,\n latitude text,\n longitude text\n);\n-- foreign keys: Neighborhood.community_area_no -> Community_Area.community_area_no; Crime.fbi_code_no -> FBI_Code.fbi_code_no; Crime.community_area_no -> Community_Area.community_area_no; Crime.district_no -> District.district_no; Crime.iucr_no -> IUCR.iucr_no; Crime.ward_no -> Ward.ward_no\n\nHint: arrest refers to arrest = 'TRUE'; in 2018 refers to date LIKE '%2018%'; in an animal hospital refers to location_description = 'ANIMAL HOSPITAL'; FBI code 08B refers to fbi_code_no = '08B'\n\nQuestion: How many arrests were made in 2018 in an animal hospital under FBI code 08B?"}, {"role": "assistant", "content": "SELECT SUM(CASE WHEN arrest = 'TRUE' THEN 1 ELSE 0 END) FROM Crime WHERE date LIKE '%2018%' AND location_description = 'ANIMAL HOSPITAL' AND fbi_code_no = '08B'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE course (\n course_id integer PRIMARY KEY,\n courseLevel text\n);\nCREATE TABLE person (\n p_id integer PRIMARY KEY,\n professor integer,\n student integer,\n hasPosition text,\n inPhase text,\n yearsInProgram text\n);\nCREATE TABLE advisedBy (\n p_id integer PRIMARY KEY,\n p_id_dummy integer PRIMARY KEY\n);\nCREATE TABLE taughtBy (\n course_id integer PRIMARY KEY,\n p_id integer PRIMARY KEY\n);\n-- foreign keys: advisedBy.p_id -> person.p_id; advisedBy.p_id_dummy -> person.p_id; taughtBy.course_id -> course.course_id; taughtBy.p_id -> person.p_id\n\nHint: people refers to taughtBy.p_id; course no.11 refers to course_id = 11\n\nQuestion: How many people teaches course no.11?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM taughtBy WHERE course_id = 11"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE `Staff` (\n`staff_id` INTEGER PRIMARY KEY,\n`gender` VARCHAR(1),\n`first_name` VARCHAR(80),\n`last_name` VARCHAR(80),\n`email_address` VARCHAR(255),\n`phone_number` VARCHAR(80)\n);\n\nQuestion: Find the emails and phone numbers of all the customers, ordered by email address and phone number."}, {"role": "assistant", "content": "SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\ncreate table Faculty (\n FacID \t INTEGER PRIMARY KEY,\n Lname\t\tVARCHAR(15),\n Fname\t\tVARCHAR(15),\n Rank\t\tVARCHAR(15),\n Sex\t\tVARCHAR(1),\n Phone\t\tINTEGER,\n Room\t\tVARCHAR(5),\n Building\t\tVARCHAR(13)\n);\n\ncreate table Department (\n DNO \t\tINTEGER PRIMARY KEY,\n Division\t\tVARCHAR(2),\n DName\t\tVARCHAR(25),\n Room\t\tVARCHAR(5),\n Building\t\tVARCHAR(13),\n DPhone\t\tINTEGER\n);\n\ncreate table Member_of (\n FacID \t INTEGER,\n DNO\t INTEGER,\n Appt_Type VARCHAR(15),\n FOREIGN KEY(FacID) REFERENCES Faculty(FacID),\n FOREIGN KEY(DNO) REFERENCES Department(DNO)\n);\n\ncreate table Course (\n CID \t \tVARCHAR(7) PRIMARY KEY,\n CName\t\tVARCHAR(40),\n Credits\t\tINTEGER,\n Instructor\tINTEGER,\n Days\t\tVARCHAR(5),\n Hours\t\tVARCHAR(11),\n DNO\t\tINTEGER,\n FOREIGN KEY(Instructor) REFERENCES Faculty(FacID),\n FOREIGN KEY(DNO) REFERENCES Department(DNO)\n);\n\ncreate table Minor_in (\n StuID \t INTEGER,\n DNO\t\tINTEGER,\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(DNO) REFERENCES Department(DNO)\n);\n\ncreate table Enrolled_in (\n StuID \t\t INTEGER,\n CID\t\tVARCHAR(7),\n Grade\t\tVARCHAR(2),\n FOREIGN KEY(StuID) REFERENCES Student(StuID),\n FOREIGN KEY(CID) REFERENCES Course(CID),\n FOREIGN KEY(Grade) REFERENCES Gradeconversion(lettergrade)\n);\n\ncreate table Gradeconversion (\n lettergrade\t VARCHAR(2) PRIMARY KEY,\n gradepoint\t FLOAT\n);\n\nQuestion: What are the course names, ordered by credits?"}, {"role": "assistant", "content": "SELECT CName FROM COURSE ORDER BY Credits"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE Ref_Document_Types (\nDocument_Type_Code CHAR(15) NOT NULL,\nDocument_Type_Name VARCHAR(255) NOT NULL,\nDocument_Type_Description VARCHAR(255) NOT NULL,\nPRIMARY KEY (Document_Type_Code)\n);\nCREATE TABLE Ref_Budget_Codes (\nBudget_Type_Code CHAR(15) NOT NULL,\nBudget_Type_Description VARCHAR(255) NOT NULL,\nPRIMARY KEY (Budget_Type_Code)\n);\n\nQuestion: List all statement ids and statement details."}, {"role": "assistant", "content": "SELECT STATEMENT_ID , statement_details FROM Statements"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"captain\" (\n\"Captain_ID\" int,\n\"Name\" text,\n\"Ship_ID\" int,\n\"age\" text,\n\"Class\" text,\n\"Rank\" text,\nPRIMARY KEY (\"Captain_ID\"),\nFOREIGN KEY (\"Ship_ID\") REFERENCES \"Ship\"(\"Ship_ID\")\n);\n\nCREATE TABLE \"Ship\" (\n\"Ship_ID\" int,\n\"Name\" text,\n\"Type\" text,\n\"Built_Year\" real,\n\"Class\" text,\n\"Flag\" text,\nPRIMARY KEY (\"Ship_ID\")\n);\n\nQuestion: Return the average and minimum age of captains in each class."}, {"role": "assistant", "content": "SELECT avg(age) , min(age) , CLASS FROM captain GROUP BY CLASS"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE CBSA (\n CBSA integer PRIMARY KEY,\n CBSA_name text,\n CBSA_type text\n);\nCREATE TABLE state (\n abbreviation text PRIMARY KEY,\n name text\n);\nCREATE TABLE congress (\n cognress_rep_id text PRIMARY KEY,\n first_name text,\n last_name text,\n CID text,\n party text,\n state text,\n abbreviation text,\n House text,\n District integer,\n land_area real\n);\nCREATE TABLE zip_data (\n zip_code integer PRIMARY KEY,\n city text,\n state text,\n multi_county text,\n type text,\n organization text,\n time_zone text,\n daylight_savings text,\n latitude real,\n longitude real,\n elevation integer,\n state_fips integer,\n county_fips integer,\n region text,\n division text,\n population_2020 integer,\n population_2010 integer,\n households integer,\n avg_house_value integer,\n avg_income_per_household integer,\n persons_per_household real,\n white_population integer,\n black_population integer,\n hispanic_population integer,\n asian_population integer,\n american_indian_population integer,\n hawaiian_population integer,\n other_population integer,\n male_population integer,\n female_population integer,\n median_age real,\n male_median_age real,\n female_median_age real,\n residential_mailboxes integer,\n business_mailboxes integer,\n total_delivery_receptacles integer,\n businesses integer,\n 1st_quarter_payroll integer,\n annual_payroll integer,\n employees integer,\n water_area real,\n land_area real,\n single_family_delivery_units integer,\n multi_family_delivery_units integer,\n total_beneficiaries integer,\n retired_workers integer,\n disabled_workers integer,\n parents_and_widowed integer,\n spouses integer,\n children integer,\n over_65 integer,\n monthly_benefits_all integer,\n monthly_benefits_retired_workers integer,\n monthly_benefits_widowed integer,\n CBSA integer\n);\nCREATE TABLE alias (\n zip_code integer PRIMARY KEY,\n alias text\n);\nCREATE TABLE area_code (\n zip_code integer PRIMARY KEY,\n area_code integer PRIMARY KEY\n);\nCREATE TABLE avoid (\n zip_code integer PRIMARY KEY,\n bad_alias text PRIMARY KEY\n);\nCREATE TABLE country (\n zip_code integer PRIMARY KEY,\n county text PRIMARY KEY,\n state text\n);\nCREATE TABLE zip_congress (\n zip_code integer PRIMARY KEY,\n district text PRIMARY KEY\n);\n-- foreign keys: congress.abbreviation -> state.abbreviation; zip_data.CBSA -> CBSA.CBSA; zip_data.state -> state.abbreviation; alias.zip_code -> zip_data.zip_code; area_code.zip_code -> zip_data.zip_code; avoid.zip_code -> zip_data.zip_code; country.state -> state.abbreviation; country.zip_code -> zip_data.zip_code; zip_congress.zip_code -> zip_data.zip_code; zip_congress.district -> congress.cognress_rep_id\n\nHint: micro CBSA refers to CBSA_type = 'Micro';\n\nQuestion: List all the cities with micro CBSA."}, {"role": "assistant", "content": "SELECT T2.city FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_type = 'Micro'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE country (\n id integer PRIMARY KEY,\n country_name text\n);\nCREATE TABLE ranking_system (\n id integer PRIMARY KEY,\n system_name text\n);\nCREATE TABLE ranking_criteria (\n id integer PRIMARY KEY,\n ranking_system_id integer,\n criteria_name text\n);\nCREATE TABLE university (\n id integer PRIMARY KEY,\n country_id integer,\n university_name text\n);\nCREATE TABLE university_ranking_year (\n university_id integer,\n ranking_criteria_id integer,\n year integer,\n score integer\n);\nCREATE TABLE university_year (\n university_id integer,\n year integer,\n num_students integer,\n student_staff_ratio real,\n pct_international_students integer,\n pct_female_students integer\n);\n-- 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\n\nHint: ranking system called Shanghai Ranking refers to system_name = 'Shanghai Ranking';\n\nQuestion: What is the total number of ranking criteria under the ranking system called Shanghai Ranking?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Shanghai Ranking'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE lists (\n user_id integer,\n list_id integer PRIMARY KEY,\n list_title text,\n list_movie_number integer,\n list_update_timestamp_utc text,\n list_creation_timestamp_utc text,\n list_followers integer,\n list_url text,\n list_comments integer,\n list_description text,\n list_cover_image_url text,\n list_first_image_url text,\n list_second_image_url text,\n list_third_image_url text\n);\nCREATE TABLE movies (\n movie_id integer PRIMARY KEY,\n movie_title text,\n movie_release_year integer,\n movie_url text,\n movie_title_language text,\n movie_popularity integer,\n movie_image_url text,\n director_id text,\n director_name text,\n director_url text\n);\nCREATE TABLE ratings_users (\n user_id integer,\n rating_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\nCREATE TABLE lists_users (\n user_id integer PRIMARY KEY,\n list_id integer PRIMARY KEY,\n list_update_date_utc text,\n list_creation_date_utc text,\n user_trialist integer,\n user_subscriber integer,\n user_avatar_image_url text,\n user_cover_image_url text,\n user_eligible_for_trial text,\n user_has_payment_method text\n);\nCREATE TABLE ratings (\n movie_id integer,\n rating_id integer,\n rating_url text,\n rating_score integer,\n rating_timestamp_utc text,\n critic text,\n critic_likes integer,\n critic_comments integer,\n user_id integer,\n user_trialist integer,\n user_subscriber integer,\n user_eligible_for_trial integer,\n user_has_payment_method integer\n);\n-- 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\n\nHint: 5 ratings refers to rating_score = 5; name of the movie refers to movie_title\n\nQuestion: Give the name of the movie that got the most \"5\" ratings."}, {"role": "assistant", "content": "SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_score = 5"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"buildings\" (\n\"id\" int,\n\"name\" text,\n\"City\" text,\n\"Height\" int,\n\"Stories\" int,\n\"Status\" text,\nPRIMARY KEY(\"id\")\n);\n\nQuestion: List the names of buildings that have no company office."}, {"role": "assistant", "content": "SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store\n\nCREATE TABLE Manufacturers (\n Code INTEGER,\n Name VARCHAR(255) NOT NULL,\n Headquarter VARCHAR(255) NOT NULL,\n Founder VARCHAR(255) NOT NULL,\n Revenue REAL,\n PRIMARY KEY (Code) \n);\n\nCREATE TABLE Products (\n Code INTEGER,\n Name VARCHAR(255) NOT NULL ,\n Price DECIMAL NOT NULL ,\n Manufacturer INTEGER NOT NULL,\n PRIMARY KEY (Code), \n FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code)\n);\n\nQuestion: Find all information of all the products with a price between $60 and $120."}, {"role": "assistant", "content": "SELECT * FROM products WHERE price BETWEEN 60 AND 120"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE height_info (\n height_id integer PRIMARY KEY,\n height_in_cm integer,\n height_in_inch text\n);\nCREATE TABLE weight_info (\n weight_id integer PRIMARY KEY,\n weight_in_kg integer,\n weight_in_lbs integer\n);\nCREATE TABLE PlayerInfo (\n ELITEID integer PRIMARY KEY,\n PlayerName text,\n birthdate text,\n birthyear date,\n birthmonth integer,\n birthday integer,\n birthplace text,\n nation text,\n height integer,\n weight integer,\n position_info text,\n shoots text,\n draftyear integer,\n draftround integer,\n overall integer,\n overallby text,\n CSS_rank integer,\n sum_7yr_GP integer,\n sum_7yr_TOI integer,\n GP_greater_than_0 text\n);\nCREATE TABLE SeasonStatus (\n ELITEID integer,\n SEASON text,\n TEAM text,\n LEAGUE text,\n GAMETYPE text,\n GP integer,\n G integer,\n A integer,\n P integer,\n PIM integer,\n PLUSMINUS integer\n);\n-- foreign keys: PlayerInfo.weight -> weight_info.weight_id; PlayerInfo.height -> height_info.height_id; SeasonStatus.ELITEID -> PlayerInfo.ELITEID\n\nHint: players refers to PlayerName; 1997-1998 season refers to SEASON = '1997-1998';\n\nQuestion: List out the nation of players who played for the 1997-1998 season ."}, {"role": "assistant", "content": "SELECT DISTINCT T2.nation FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.SEASON = '1997-1998'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"people\" (\n\"People_ID\" int,\n\"Name\" text,\n\"Country\" text,\n\"Is_Male\" text,\n\"Age\" int,\nPRIMARY KEY (\"People_ID\")\n);\n\nQuestion: Show the church names for the weddings of all people older than 30."}, {"role": "assistant", "content": "SELECT T4.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id JOIN church AS T4 ON T4.church_id = T1.church_id WHERE T2.age > 30 OR T3.age > 30"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Classification (\n GeneID text PRIMARY KEY,\n Localization text\n);\nCREATE TABLE Genes (\n GeneID text,\n Essential text,\n Class text,\n Complex text,\n Phenotype text,\n Motif text,\n Chromosome integer,\n Function text,\n Localization text\n);\nCREATE TABLE Interactions (\n GeneID1 text PRIMARY KEY,\n GeneID2 text PRIMARY KEY,\n Type text,\n Expression_Corr real\n);\n-- foreign keys: Genes.GeneID -> Classification.GeneID; Interactions.GeneID2 -> Classification.GeneID; Interactions.GeneID1 -> Classification.GeneID\n\nQuestion: Please list the motif of the genes that are located in the cytoplasm and have 7 chromosomes."}, {"role": "assistant", "content": "SELECT T2.GeneID1, T2.GeneID2 FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Localization = 'cytoplasm' AND T1.Chromosome = 7"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\ncreate table Student (\n StuID INTEGER PRIMARY KEY,\n LName VARCHAR(12),\n Fname VARCHAR(12),\n Age INTEGER,\n Sex VARCHAR(1),\n Major INTEGER,\n Advisor INTEGER,\n city_code VARCHAR(3)\n );\n\ncreate table Video_Games (\n GameID INTEGER PRIMARY KEY,\n GName VARCHAR(40),\n GType VARCHAR(40)\n);\n\ncreate table Plays_Games (\n StuID INTEGER,\n GameID INTEGER,\n Hours_Played INTEGER,\n FOREIGN KEY(GameID) REFERENCES Video_Games(GameID),\n FOREIGN KEY(StuID) REFERENCES Student(StuID)\n);\n\ncreate table SportsInfo (\n StuID INTEGER,\n SportName VARCHAR(32),\n HoursPerWeek INTEGER,\n GamesPlayed INTEGER,\n OnScholarship VARCHAR(1),\n FOREIGN KEY(StuID) REFERENCES Student(StuID)\n);\n\nQuestion: What are the ids of all students who are not video game players?"}, {"role": "assistant", "content": "SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE customer (\n c_custkey integer PRIMARY KEY,\n c_mktsegment text,\n c_nationkey integer,\n c_name text,\n c_address text,\n c_phone text,\n c_acctbal real,\n c_comment text\n);\nCREATE TABLE lineitem (\n l_shipdate date,\n l_orderkey integer PRIMARY KEY,\n l_discount real,\n l_extendedprice real,\n l_suppkey integer,\n l_quantity integer,\n l_returnflag text,\n l_partkey integer,\n l_linestatus text,\n l_tax real,\n l_commitdate date,\n l_receiptdate date,\n l_shipmode text,\n l_linenumber integer PRIMARY KEY,\n l_shipinstruct text,\n l_comment text\n);\nCREATE TABLE nation (\n n_nationkey integer PRIMARY KEY,\n n_name text,\n n_regionkey integer,\n n_comment text\n);\nCREATE TABLE orders (\n o_orderdate date,\n o_orderkey integer PRIMARY KEY,\n o_custkey integer,\n o_orderpriority text,\n o_shippriority integer,\n o_clerk text,\n o_orderstatus text,\n o_totalprice real,\n o_comment text\n);\nCREATE TABLE part (\n p_partkey integer PRIMARY KEY,\n p_type text,\n p_size integer,\n p_brand text,\n p_name text,\n p_container text,\n p_mfgr text,\n p_retailprice real,\n p_comment text\n);\nCREATE TABLE partsupp (\n ps_partkey integer PRIMARY KEY,\n ps_suppkey integer PRIMARY KEY,\n ps_supplycost real,\n ps_availqty integer,\n ps_comment text\n);\nCREATE TABLE region (\n r_regionkey integer PRIMARY KEY,\n r_name text,\n r_comment text\n);\nCREATE TABLE supplier (\n s_suppkey integer PRIMARY KEY,\n s_nationkey integer,\n s_comment text,\n s_name text,\n s_address text,\n s_phone text,\n s_acctbal real\n);\n-- foreign keys: customer.c_nationkey -> nation.n_nationkey; lineitem.l_partkey -> partsupp.ps_partkey; lineitem.l_suppkey -> partsupp.ps_suppkey; lineitem.l_orderkey -> orders.o_orderkey; nation.n_regionkey -> region.r_regionkey; orders.o_custkey -> customer.c_custkey; partsupp.ps_suppkey -> supplier.s_suppkey; partsupp.ps_partkey -> part.p_partkey; supplier.s_nationkey -> nation.n_nationkey\n\nHint: country refers to n_name; the least number of suppliers refers to min(count(s_name))\n\nQuestion: Which country has the least number of suppliers?"}, {"role": "assistant", "content": "SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey GROUP BY T1.s_nationkey ORDER BY COUNT(T1.s_name) LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE City (\n ID integer PRIMARY KEY,\n Name text,\n CountryCode text,\n District text,\n Population integer\n);\nCREATE TABLE Country (\n Code text PRIMARY KEY,\n Name text,\n Continent text,\n Region text,\n SurfaceArea real,\n IndepYear integer,\n Population integer,\n LifeExpectancy real,\n GNP real,\n GNPOld real,\n LocalName text,\n GovernmentForm text,\n HeadOfState text,\n Capital integer,\n Code2 text\n);\nCREATE TABLE CountryLanguage (\n CountryCode text PRIMARY KEY,\n Language text PRIMARY KEY,\n IsOfficial text,\n Percentage real\n);\n-- foreign keys: City.CountryCode -> Country.Code; CountryLanguage.CountryCode -> Country.Code\n\nHint: smallest surface area refers to MIN(smallest surface area);\n\nQuestion: Which country has the smallest surface area?"}, {"role": "assistant", "content": "SELECT Name FROM Country ORDER BY SurfaceArea ASC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE station (\n id INTEGER PRIMARY KEY,\n name TEXT,\n lat NUMERIC,\n long NUMERIC,\n dock_count INTEGER,\n city TEXT,\n installation_date TEXT);\n\nQuestion: What are the names of all stations that have more than 10 bikes available and are not located in San Jose?"}, {"role": "assistant", "content": "SELECT T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING avg(bikes_available) > 10 EXCEPT SELECT name FROM station WHERE city = \"San Jose\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Name text,\n Price real\n);\nCREATE TABLE Sales (\n SalesID integer PRIMARY KEY,\n SalesPersonID integer,\n CustomerID integer,\n ProductID integer,\n Quantity integer\n);\n-- foreign keys: Sales.ProductID -> Products.ProductID; Sales.CustomerID -> Customers.CustomerID; Sales.SalesPersonID -> Employees.EmployeeID\n\nHint: sales ID ranges from 1 to 200 refers to SalesID between 1 and 200; percentage = MULTIPLY(DIVIDE(SUM(Price between 200 and 300), COUNT(Price)), 1.0);\n\nQuestion: Among the sales ID ranges from 1 to 200, what is the percentage of the products with a price ranging from 200 to 300?"}, {"role": "assistant", "content": "SELECT CAST(SUM(IIF(T2.Price BETWEEN 200 AND 300, 1, 0)) AS REAL) * 100 / COUNT(T2.Price) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T1.SalesID BETWEEN 1 AND 200"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE genre (\n id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE game (\n id integer PRIMARY KEY,\n genre_id integer,\n game_name text\n);\nCREATE TABLE platform (\n id integer PRIMARY KEY,\n platform_name text\n);\nCREATE TABLE publisher (\n id integer PRIMARY KEY,\n publisher_name text\n);\nCREATE TABLE game_publisher (\n id integer PRIMARY KEY,\n game_id integer,\n publisher_id integer\n);\nCREATE TABLE game_platform (\n id integer PRIMARY KEY,\n game_publisher_id integer,\n platform_id integer,\n release_year integer\n);\nCREATE TABLE region (\n id integer PRIMARY KEY,\n region_name text\n);\nCREATE TABLE region_sales (\n region_id integer,\n game_platform_id integer,\n num_sales real\n);\n-- 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\n\nHint: total sales in all regions = MULTIPLY(SUM(num_sales), 100000);\n\nQuestion: Calculate the total sales in all regions with game platform ID 66."}, {"role": "assistant", "content": "SELECT SUM(T.num_sales) * 100000 FROM region_sales AS T WHERE T.game_platform_id = 66"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Attributes (\n attribute_id integer PRIMARY KEY,\n attribute_name text\n);\nCREATE TABLE Categories (\n category_id integer PRIMARY KEY,\n category_name text\n);\nCREATE TABLE Compliments (\n compliment_id integer PRIMARY KEY,\n compliment_type text\n);\nCREATE TABLE Days (\n day_id integer PRIMARY KEY,\n day_of_week text\n);\nCREATE TABLE Years (\n year_id integer PRIMARY KEY,\n actual_year integer\n);\nCREATE TABLE Business_Attributes (\n attribute_id integer PRIMARY KEY,\n business_id integer PRIMARY KEY,\n attribute_value text\n);\nCREATE TABLE Business_Categories (\n business_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY\n);\nCREATE TABLE Business_Hours (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n opening_time text,\n closing_time text\n);\nCREATE TABLE Checkins (\n business_id integer PRIMARY KEY,\n day_id integer PRIMARY KEY,\n label_time_0 text,\n label_time_1 text,\n label_time_2 text,\n label_time_3 text,\n label_time_4 text,\n label_time_5 text,\n label_time_6 text,\n label_time_7 text,\n label_time_8 text,\n label_time_9 text,\n label_time_10 text,\n label_time_11 text,\n label_time_12 text,\n label_time_13 text,\n label_time_14 text,\n label_time_15 text,\n label_time_16 text,\n label_time_17 text,\n label_time_18 text,\n label_time_19 text,\n label_time_20 text,\n label_time_21 text,\n label_time_22 text,\n label_time_23 text\n);\nCREATE TABLE Elite (\n user_id integer PRIMARY KEY,\n year_id integer PRIMARY KEY\n);\nCREATE TABLE Reviews (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n review_stars integer,\n review_votes_funny text,\n review_votes_useful text,\n review_votes_cool text,\n review_length text\n);\nCREATE TABLE Tips (\n business_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n likes integer,\n tip_length text\n);\nCREATE TABLE Users_Compliments (\n compliment_id integer PRIMARY KEY,\n user_id integer PRIMARY KEY,\n number_of_compliments text\n);\nCREATE TABLE Business (\n business_id integer PRIMARY KEY,\n active text,\n city text,\n state text,\n stars real,\n review_count text\n);\nCREATE TABLE Users (\n user_id integer PRIMARY KEY,\n user_yelping_since_year integer,\n user_average_stars text,\n user_votes_funny text,\n user_votes_useful text,\n user_votes_cool text,\n user_review_count text,\n user_fans text\n);\n\nHint: 2006 and 2007 refers to BETWEEN 2006 AND 2007; greater number in elite user refers to count(user_id)\n\nQuestion: Between 2006 and 2007, which year ID had the greater number in elite user?"}, {"role": "assistant", "content": "SELECT year_id FROM Elite WHERE year_id IN (2006, 2007) GROUP BY year_id ORDER BY COUNT(user_id) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE \"list\" ( \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Grade\" INTEGER, \n\t\"Classroom\" INTEGER,\n\tPRIMARY KEY(LastName, FirstName)\n);\nCREATE TABLE \"teachers\" ( \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Classroom\" INTEGER,\n\tPRIMARY KEY(LastName, FirstName)\n);\n\nQuestion: Which teachers teach in classroom 110? Give me their first names."}, {"role": "assistant", "content": "SELECT firstname FROM teachers WHERE classroom = 110"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Accounts` (\n`account_id` INTEGER PRIMARY KEY,\n`customer_id` INTEGER NOT NULL,\n`account_name` VARCHAR(50),\n`other_account_details` VARCHAR(255)\n);\nCREATE TABLE `Customers` (\n`customer_id` INTEGER PRIMARY KEY,\n`customer_first_name` VARCHAR(20),\n`customer_last_name` VARCHAR(20),\n`customer_address` VARCHAR(255),\n`customer_phone` VARCHAR(255),\n`customer_email` VARCHAR(255),\n`other_customer_details` VARCHAR(255)\n);\nCREATE TABLE `Customers_Cards` (\n`card_id` INTEGER PRIMARY KEY,\n`customer_id` INTEGER NOT NULL,\n`card_type_code` VARCHAR(15) NOT NULL,\n`card_number` VARCHAR(80),\n`date_valid_from` DATETIME,\n`date_valid_to` DATETIME,\n`other_card_details` VARCHAR(255)\n);\nCREATE TABLE `Financial_Transactions` (\n`transaction_id` INTEGER NOT NULL ,\n`previous_transaction_id` INTEGER,\n`account_id` INTEGER NOT NULL,\n`card_id` INTEGER NOT NULL,\n`transaction_type` VARCHAR(15) NOT NULL,\n`transaction_date` DATETIME,\n`transaction_amount` DOUBLE NULL,\n`transaction_comment` VARCHAR(255),\n`other_transaction_details` VARCHAR(255),\nFOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),\nFOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )\n);\n\nQuestion: How many cards does customer Art Turcotte have?"}, {"role": "assistant", "content": "SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = \"Art\" AND T2.customer_last_name = \"Turcotte\""}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE \"Campuses\" (\n\t\"Id\" INTEGER PRIMARY KEY, \n\t\"Campus\" TEXT, \n\t\"Location\" TEXT, \n\t\"County\" TEXT, \n\t\"Year\" INTEGER \n);\n\nCREATE TABLE \"csu_fees\" ( \n\t\"Campus\" INTEGER PRIMARY KEY, \n\t\"Year\" INTEGER, \n\t\"CampusFee\" INTEGER,\n\tFOREIGN KEY (Campus) REFERENCES Campuses(Id)\n);\n\nCREATE TABLE \"degrees\" ( \n\t\"Year\" INTEGER,\n\t\"Campus\" INTEGER, \n\t\"Degrees\" INTEGER,\n\tPRIMARY KEY (Year, Campus),\n\tFOREIGN KEY (Campus) REFERENCES Campuses(Id)\n);\n\n\n\nCREATE TABLE \"discipline_enrollments\" ( \n\t\"Campus\" INTEGER, \n\t\"Discipline\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Undergraduate\" INTEGER, \n\t\"Graduate\" INTEGER,\n\tPRIMARY KEY (Campus, Discipline),\n\tFOREIGN KEY (Campus) REFERENCES Campuses(Id)\n);\n\n\n\nCREATE TABLE \"enrollments\" ( \n\t\"Campus\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"TotalEnrollment_AY\" INTEGER, \n\t\"FTE_AY\" INTEGER,\n\tPRIMARY KEY(Campus, Year),\n\tFOREIGN KEY (Campus) REFERENCES Campuses(Id)\n);\n\nCREATE TABLE \"faculty\" ( \n\t\"Campus\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Faculty\" REAL,\n\tFOREIGN KEY (Campus) REFERENCES Campuses(Id) \n);\n\nQuestion: How many faculty members did the university that conferred the most degrees in 2002 have?"}, {"role": "assistant", "content": "SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2002 ORDER BY t3.degrees DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE customers (\n CustomerID integer PRIMARY KEY,\n First text,\n Last text,\n StreetAddress text,\n City text,\n State text,\n ZipCode integer,\n Email text,\n PhoneNumber text,\n FirstPurchaseDate date,\n SubscribedToEmailList text,\n Gender text\n);\nCREATE TABLE geolocation (\n LocationID integer PRIMARY KEY,\n Latitude real,\n Longitude real\n);\nCREATE TABLE location (\n LocationID integer PRIMARY KEY,\n LocationName text,\n StreetAddress text,\n City text,\n State text,\n ZipCode integer\n);\nCREATE TABLE rootbeerbrand (\n BrandID integer PRIMARY KEY,\n BrandName text,\n FirstBrewedYear integer,\n BreweryName text,\n City text,\n State text,\n Country text,\n Description text,\n CaneSugar text,\n CornSyrup text,\n Honey text,\n ArtificialSweetener text,\n Caffeinated text,\n Alcoholic text,\n AvailableInCans text,\n AvailableInBottles text,\n AvailableInKegs text,\n Website text,\n FacebookPage text,\n Twitter text,\n WholesaleCost real,\n CurrentRetailPrice real\n);\nCREATE TABLE rootbeer (\n RootBeerID integer PRIMARY KEY,\n BrandID integer,\n ContainerType text,\n LocationID integer,\n PurchaseDate date\n);\nCREATE TABLE rootbeerreview (\n CustomerID integer PRIMARY KEY,\n BrandID integer PRIMARY KEY,\n StarRating integer,\n ReviewDate date,\n Review text\n);\nCREATE TABLE transaction (\n TransactionID integer PRIMARY KEY,\n CreditCardNumber integer,\n CustomerID integer,\n TransactionDate date,\n CreditCardType text,\n LocationID integer,\n RootBeerID integer,\n PurchasePrice real\n);\n-- 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\n\nHint: 1-star rating refers to StarRating = 1; saying, \"Yuk, more like licorice soda\" refers to Review = 'Yuk, more like licorice soda.';\n\nQuestion: What is the brand name of the root beer that gained a 1-star rating from customer ID 331115 while saying, \"Yuk, more like licorice soda\"?"}, {"role": "assistant", "content": "SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.CustomerID = 331115 AND T2.Review = 'Yuk, more like licorice soda.' AND T2.StarRating = 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE film_text (\n film_id integer PRIMARY KEY,\n title text,\n description text\n);\nCREATE TABLE actor (\n actor_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n last_update datetime\n);\nCREATE TABLE address (\n address_id integer PRIMARY KEY,\n address text,\n address2 text,\n district text,\n city_id integer,\n postal_code text,\n phone text,\n last_update datetime\n);\nCREATE TABLE category (\n category_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE city (\n city_id integer PRIMARY KEY,\n city text,\n country_id integer,\n last_update datetime\n);\nCREATE TABLE country (\n country_id integer PRIMARY KEY,\n country text,\n last_update datetime\n);\nCREATE TABLE customer (\n customer_id integer PRIMARY KEY,\n store_id integer,\n first_name text,\n last_name text,\n email text,\n address_id integer,\n active integer,\n create_date datetime,\n last_update datetime\n);\nCREATE TABLE film (\n film_id integer PRIMARY KEY,\n title text,\n description text,\n release_year text,\n language_id integer,\n original_language_id integer,\n rental_duration integer,\n rental_rate real,\n length integer,\n replacement_cost real,\n rating text,\n special_features text,\n last_update datetime\n);\nCREATE TABLE film_actor (\n actor_id integer PRIMARY KEY,\n film_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE film_category (\n film_id integer PRIMARY KEY,\n category_id integer PRIMARY KEY,\n last_update datetime\n);\nCREATE TABLE inventory (\n inventory_id integer PRIMARY KEY,\n film_id integer,\n store_id integer,\n last_update datetime\n);\nCREATE TABLE language (\n language_id integer PRIMARY KEY,\n name text,\n last_update datetime\n);\nCREATE TABLE payment (\n payment_id integer PRIMARY KEY,\n customer_id integer,\n staff_id integer,\n rental_id integer,\n amount real,\n payment_date datetime,\n last_update datetime\n);\nCREATE TABLE rental (\n rental_id integer PRIMARY KEY,\n rental_date datetime,\n inventory_id integer,\n customer_id integer,\n return_date datetime,\n staff_id integer,\n last_update datetime\n);\nCREATE TABLE staff (\n staff_id integer PRIMARY KEY,\n first_name text,\n last_name text,\n address_id integer,\n picture blob,\n email text,\n store_id integer,\n active integer,\n username text,\n password text,\n last_update datetime\n);\nCREATE TABLE store (\n store_id integer PRIMARY KEY,\n manager_staff_id integer,\n address_id integer,\n last_update datetime\n);\n\nQuestion: How many films have a rental rate of 0.99?"}, {"role": "assistant", "content": "SELECT COUNT(film_id) FROM film WHERE rental_rate = 0.99"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"artist\" (\n \"Artist_ID\" int,\n \"Artist\" text,\n \"Age\" int,\n \"Famous_Title\" text,\n \"Famous_Release_date\" text,\n PRIMARY KEY (\"Artist_ID\")\n);\n\n\n\nCREATE TABLE \"volume\" (\n \"Volume_ID\" int,\n \"Volume_Issue\" text,\n \"Issue_Date\" text,\n \"Weeks_on_Top\" real,\n \"Song\" text,\n \"Artist_ID\" int,\n PRIMARY KEY (\"Volume_ID\"),\n FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`)\n);\n\nQuestion: Return names of songs in volumes that are by artists that are at least 32 years old."}, {"role": "assistant", "content": "SELECT T2.Song FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age >= 32"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE bool (\n name text PRIMARY KEY\n);\nCREATE TABLE person (\n name text PRIMARY KEY\n);\nCREATE TABLE disabled (\n name text PRIMARY KEY\n);\nCREATE TABLE enlist (\n name text,\n organ text\n);\nCREATE TABLE filed_for_bankrupcy (\n name text PRIMARY KEY\n);\nCREATE TABLE longest_absense_from_school (\n name text PRIMARY KEY,\n month integer\n);\nCREATE TABLE male (\n name text PRIMARY KEY\n);\nCREATE TABLE no_payment_due (\n name text PRIMARY KEY,\n bool text\n);\nCREATE TABLE unemployed (\n name text PRIMARY KEY\n);\nCREATE TABLE enrolled (\n name text PRIMARY KEY,\n school text PRIMARY KEY,\n month integer\n);\n-- foreign keys: disabled.name -> person.name; enlist.name -> person.name; filed_for_bankrupcy.name -> person.name; longest_absense_from_school.name -> person.name; male.name -> person.name; no_payment_due.bool -> bool.name; no_payment_due.name -> person.name; unemployed.name -> person.name; enrolled.name -> person.name\n\nHint: longest duration of absense refers to MAX(month)\n\nQuestion: State name of unemployed students who have the longest duration of absense from school."}, {"role": "assistant", "content": "SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name ORDER BY T1.month DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE essays (\n projectid text,\n teacher_acctid text,\n title text,\n short_description text,\n need_statement text,\n essay text\n);\nCREATE TABLE projects (\n projectid text PRIMARY KEY,\n teacher_acctid text,\n schoolid text,\n school_ncesid text,\n school_latitude real,\n school_longitude real,\n school_city text,\n school_state text,\n school_zip integer,\n school_metro text,\n school_district text,\n school_county text,\n school_charter text,\n school_magnet text,\n school_year_round text,\n school_nlns text,\n school_kipp text,\n school_charter_ready_promise text,\n teacher_prefix text,\n teacher_teach_for_america text,\n teacher_ny_teaching_fellow text,\n primary_focus_subject text,\n primary_focus_area text,\n secondary_focus_subject text,\n secondary_focus_area text,\n resource_type text,\n poverty_level text,\n grade_level text,\n fulfillment_labor_materials real,\n total_price_excluding_optional_support real,\n total_price_including_optional_support real,\n students_reached integer,\n eligible_double_your_impact_match text,\n eligible_almost_home_match text,\n date_posted date\n);\nCREATE TABLE donations (\n donationid text PRIMARY KEY,\n projectid text,\n donor_acctid text,\n donor_city text,\n donor_state text,\n donor_zip text,\n is_teacher_acct text,\n donation_timestamp datetime,\n donation_to_project real,\n donation_optional_support real,\n donation_total real,\n dollar_amount text,\n donation_included_optional_support text,\n payment_method text,\n payment_included_acct_credit text,\n payment_included_campaign_gift_card text,\n payment_included_web_purchased_gift_card text,\n payment_was_promo_matched text,\n via_giving_page text,\n for_honoree text,\n donation_message text\n);\nCREATE TABLE resources (\n resourceid text PRIMARY KEY,\n projectid text,\n vendorid integer,\n vendor_name text,\n project_resource_type text,\n item_name text,\n item_number text,\n item_unit_price real,\n item_quantity integer\n);\n-- foreign keys: donations.projectid -> projects.projectid; resources.projectid -> projects.projectid\n\nHint: school in Brooklyn refers to school_city = 'Brooklyn'; total donated amount refers to donation_total;\n\nQuestion: What is the total donated amount for projects created by a teacher working in a school in Brooklyn?"}, {"role": "assistant", "content": "SELECT SUM(T2.donation_total) FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.school_city = 'Brooklyn'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE station (\n id INTEGER PRIMARY KEY,\n name TEXT,\n lat NUMERIC,\n long NUMERIC,\n dock_count INTEGER,\n city TEXT,\n installation_date TEXT);\n\nQuestion: What are the 3 most common cloud covers in the zip code of 94107?"}, {"role": "assistant", "content": "SELECT cloud_cover FROM weather WHERE zip_code = 94107 GROUP BY cloud_cover ORDER BY COUNT (*) DESC LIMIT 3"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE height_info (\n height_id integer PRIMARY KEY,\n height_in_cm integer,\n height_in_inch text\n);\nCREATE TABLE weight_info (\n weight_id integer PRIMARY KEY,\n weight_in_kg integer,\n weight_in_lbs integer\n);\nCREATE TABLE PlayerInfo (\n ELITEID integer PRIMARY KEY,\n PlayerName text,\n birthdate text,\n birthyear date,\n birthmonth integer,\n birthday integer,\n birthplace text,\n nation text,\n height integer,\n weight integer,\n position_info text,\n shoots text,\n draftyear integer,\n draftround integer,\n overall integer,\n overallby text,\n CSS_rank integer,\n sum_7yr_GP integer,\n sum_7yr_TOI integer,\n GP_greater_than_0 text\n);\nCREATE TABLE SeasonStatus (\n ELITEID integer,\n SEASON text,\n TEAM text,\n LEAGUE text,\n GAMETYPE text,\n GP integer,\n G integer,\n A integer,\n P integer,\n PIM integer,\n PLUSMINUS integer\n);\n-- foreign keys: PlayerInfo.weight -> weight_info.weight_id; PlayerInfo.height -> height_info.height_id; SeasonStatus.ELITEID -> PlayerInfo.ELITEID\n\nHint: right-shooted refers to shoots = 'R'; weigh over 90 kg refers to weight_in_kg > 90;\n\nQuestion: Among all the players that are right-shooted, how many of them weigh over 90 kg?"}, {"role": "assistant", "content": "SELECT COUNT(T1.ELITEID) FROM PlayerInfo AS T1 INNER JOIN weight_info AS T2 ON T1.weight = T2.weight_id WHERE T2.weight_in_kg > 90 AND T1.shoots = 'R'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Dish (\n id integer PRIMARY KEY,\n name text,\n description text,\n menus_appeared integer,\n times_appeared integer,\n first_appeared integer,\n last_appeared integer,\n lowest_price real,\n highest_price real\n);\nCREATE TABLE Menu (\n id integer PRIMARY KEY,\n name text,\n sponsor text,\n event text,\n venue text,\n place text,\n physical_description text,\n occasion text,\n notes text,\n call_number text,\n keywords text,\n language text,\n date date,\n location text,\n location_type text,\n currency text,\n currency_symbol text,\n status text,\n page_count integer,\n dish_count integer\n);\nCREATE TABLE MenuPage (\n id integer PRIMARY KEY,\n menu_id integer,\n page_number integer,\n image_id real,\n full_height integer,\n full_width integer,\n uuid text\n);\nCREATE TABLE MenuItem (\n id integer PRIMARY KEY,\n menu_page_id integer,\n price real,\n high_price real,\n dish_id integer,\n created_at text,\n updated_at text,\n xpos real,\n ypos real\n);\n-- foreign keys: MenuPage.menu_id -> Menu.id; MenuItem.menu_page_id -> MenuPage.id; MenuItem.dish_id -> Dish.id\n\nHint: Zentral Theater Terrace is a name of menu;\n\nQuestion: How many dishes are there on the menu \"Zentral Theater Terrace\"?"}, {"role": "assistant", "content": "SELECT SUM(CASE WHEN T3.name = 'Zentral Theater Terrace' THEN 1 ELSE 0 END) 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"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE people (\n Customer ID text PRIMARY KEY,\n Customer Name text,\n Segment text,\n Country text,\n City text,\n State text,\n Postal Code integer,\n Region text PRIMARY KEY\n);\nCREATE TABLE product (\n Product ID text PRIMARY KEY,\n Product Name text,\n Category text,\n Sub-Category text,\n Region text PRIMARY KEY\n);\nCREATE TABLE central_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\nCREATE TABLE east_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\nCREATE TABLE south_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\nCREATE TABLE west_superstore (\n Row ID integer PRIMARY KEY,\n Order ID text,\n Order Date date,\n Ship Date date,\n Ship Mode text,\n Customer ID text,\n Region text,\n Product ID text,\n Sales real,\n Quantity integer,\n Discount real,\n Profit real\n);\n-- 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\n\nHint: name refers to \"Product Name\"; shipping mode refers to Ship Mode; shortest shipment time refers to min(subtract(Ship Date, Order Date))\n\nQuestion: In west superstore, what is the name and the shipping mode of the product that was ordered with the shortest shipment time?"}, {"role": "assistant", "content": "SELECT DISTINCT T2.`Product Name`, T1.`Ship Mode` FROM west_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.Region = 'West' ORDER BY T1.`Ship Date` - T1.`Order Date` LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE customers (\n CustomerID integer PRIMARY KEY,\n First text,\n Last text,\n StreetAddress text,\n City text,\n State text,\n ZipCode integer,\n Email text,\n PhoneNumber text,\n FirstPurchaseDate date,\n SubscribedToEmailList text,\n Gender text\n);\nCREATE TABLE geolocation (\n LocationID integer PRIMARY KEY,\n Latitude real,\n Longitude real\n);\nCREATE TABLE location (\n LocationID integer PRIMARY KEY,\n LocationName text,\n StreetAddress text,\n City text,\n State text,\n ZipCode integer\n);\nCREATE TABLE rootbeerbrand (\n BrandID integer PRIMARY KEY,\n BrandName text,\n FirstBrewedYear integer,\n BreweryName text,\n City text,\n State text,\n Country text,\n Description text,\n CaneSugar text,\n CornSyrup text,\n Honey text,\n ArtificialSweetener text,\n Caffeinated text,\n Alcoholic text,\n AvailableInCans text,\n AvailableInBottles text,\n AvailableInKegs text,\n Website text,\n FacebookPage text,\n Twitter text,\n WholesaleCost real,\n CurrentRetailPrice real\n);\nCREATE TABLE rootbeer (\n RootBeerID integer PRIMARY KEY,\n BrandID integer,\n ContainerType text,\n LocationID integer,\n PurchaseDate date\n);\nCREATE TABLE rootbeerreview (\n CustomerID integer PRIMARY KEY,\n BrandID integer PRIMARY KEY,\n StarRating integer,\n ReviewDate date,\n Review text\n);\nCREATE TABLE transaction (\n TransactionID integer PRIMARY KEY,\n CreditCardNumber integer,\n CustomerID integer,\n TransactionDate date,\n CreditCardType text,\n LocationID integer,\n RootBeerID integer,\n PurchasePrice real\n);\n-- 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\n\nHint: brewery refers to BreweryName; most sold root beer refers to MAX(COUNT(BrandID)); in 2015 refers to TransactionDate > = '2015-01-01' AND TransactionDate < = '2015-12-31';\n\nQuestion: Which brewery brewed the most sold root beer in 2015?"}, {"role": "assistant", "content": "SELECT T3.BreweryName 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 '2015%' GROUP BY T3.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Document_Types` (\n`document_type_code` VARCHAR(10) PRIMARY KEY,\n`document_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Documents` (\n`document_id` INTEGER PRIMARY KEY,\n`document_type_code` VARCHAR(10),\n`grant_id` INTEGER NOT NULL,\n`sent_date` DATETIME NOT NULL,\n`response_received_date` DATETIME NOT NULL,\n`other_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`document_type_code` ) REFERENCES `Document_Types`(`document_type_code` ),\nFOREIGN KEY (`grant_id` ) REFERENCES `Grants`(`grant_id` )\n);\nCREATE TABLE `Grants` (\n`grant_id` INTEGER PRIMARY KEY,\n`organisation_id` INTEGER NOT NULL,\n`grant_amount` DECIMAL(19,4) NOT NULL DEFAULT 0,\n`grant_start_date` DATETIME NOT NULL,\n`grant_end_date` DATETIME NOT NULL,\n`other_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Organisation_Types` (\n`organisation_type` VARCHAR(10) PRIMARY KEY,\n`organisation_type_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Organisations` (\n`organisation_id` INTEGER PRIMARY KEY,\n`organisation_type` VARCHAR(10) NOT NULL,\n`organisation_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_type` ) REFERENCES `Organisation_Types`(`organisation_type` )\n);\nCREATE TABLE `Project_Outcomes` (\n`project_id` INTEGER NOT NULL,\n`outcome_code` VARCHAR(10) NOT NULL,\n`outcome_details` VARCHAR(255),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`outcome_code` ) REFERENCES `Research_Outcomes`(`outcome_code` )\n);\nCREATE TABLE `Project_Staff` (\n`staff_id` DOUBLE PRIMARY KEY,\n`project_id` INTEGER NOT NULL,\n`role_code` VARCHAR(10) NOT NULL,\n`date_from` DATETIME,\n`date_to` DATETIME,\n`other_details` VARCHAR(255),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` ),FOREIGN KEY (`role_code` ) REFERENCES `Staff_Roles`(`role_code` )\n);\nCREATE TABLE `Projects` (\n`project_id` INTEGER PRIMARY KEY,\n`organisation_id` INTEGER NOT NULL,\n`project_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Research_Outcomes` (\n`outcome_code` VARCHAR(10) PRIMARY KEY,\n`outcome_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Research_Staff` (\n`staff_id` INTEGER PRIMARY KEY,\n`employer_organisation_id` INTEGER NOT NULL,\n`staff_details` VARCHAR(255) NOT NULL,\nFOREIGN KEY (`employer_organisation_id` ) REFERENCES `Organisations`(`organisation_id` )\n);\nCREATE TABLE `Staff_Roles` (\n`role_code` VARCHAR(10) PRIMARY KEY,\n`role_description` VARCHAR(255) NOT NULL\n);\nCREATE TABLE `Tasks` (\n`task_id` INTEGER PRIMARY KEY,\n`project_id` INTEGER NOT NULL,\n`task_details` VARCHAR(255) NOT NULL,\n`eg Agree Objectives` VARCHAR(1),\nFOREIGN KEY (`project_id` ) REFERENCES `Projects`(`project_id` )\n);\n\nQuestion: What is the type and id of the organization that has the most research staff?"}, {"role": "assistant", "content": "SELECT T1.organisation_type , T1.organisation_id FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id = T2.employer_organisation_id GROUP BY T1.organisation_id ORDER BY count(*) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE current (\n ballotpedia_id text,\n bioguide_id text PRIMARY KEY,\n birthday_bio date,\n cspan_id real PRIMARY KEY,\n fec_id text,\n first_name text,\n gender_bio text,\n google_entity_id_id text,\n govtrack_id integer,\n house_history_id real,\n icpsr_id real,\n last_name text,\n lis_id text,\n maplight_id real,\n middle_name text,\n nickname_name text,\n official_full_name text,\n opensecrets_id text,\n religion_bio text,\n suffix_name text,\n thomas_id integer,\n votesmart_id real,\n wikidata_id text,\n wikipedia_id text\n);\nCREATE TABLE current-terms (\n address text,\n bioguide text PRIMARY KEY,\n caucus text,\n chamber text,\n class real,\n contact_form text,\n district real,\n end text PRIMARY KEY,\n fax text,\n last text,\n name text,\n office text,\n party text,\n party_affiliations text,\n phone text,\n relation text,\n rss_url text,\n start text,\n state text,\n state_rank text,\n title text,\n type text,\n url text\n);\nCREATE TABLE historical (\n ballotpedia_id text,\n bioguide_id text PRIMARY KEY,\n bioguide_previous_id text,\n birthday_bio text,\n cspan_id text,\n fec_id text,\n first_name text,\n gender_bio text,\n google_entity_id_id text,\n govtrack_id integer,\n house_history_alternate_id text,\n house_history_id real,\n icpsr_id real,\n last_name text,\n lis_id text,\n maplight_id text,\n middle_name text,\n nickname_name text,\n official_full_name text,\n opensecrets_id text,\n religion_bio text,\n suffix_name text,\n thomas_id text,\n votesmart_id text,\n wikidata_id text,\n wikipedia_id text\n);\nCREATE TABLE historical-terms (\n address text,\n bioguide text PRIMARY KEY,\n chamber text,\n class real,\n contact_form text,\n district real,\n end text,\n fax text,\n last text,\n middle text,\n name text,\n office text,\n party text,\n party_affiliations text,\n phone text,\n relation text,\n rss_url text,\n start text,\n state text,\n state_rank text,\n title text,\n type text,\n url text\n);\nCREATE TABLE social-media (\n bioguide text PRIMARY KEY,\n facebook text,\n facebook_id real,\n govtrack real,\n instagram text,\n instagram_id real,\n thomas integer,\n twitter text,\n twitter_id real,\n youtube text,\n youtube_id text\n);\n-- foreign keys: current-terms.bioguide -> current.bioguide_id; historical-terms.bioguide -> historical.bioguide_id; social-media.bioguide -> current.bioguide_id\n\nHint: Readjuster Democrats refers to party = 'Readjuster Democrat'\n\nQuestion: Give the Wikipedia IDs of historical legislators who are Readjuster Democrats."}, {"role": "assistant", "content": "SELECT T2.wikipedia_id FROM `historical-terms` AS T1 INNER JOIN historical AS T2 ON T2.bioguide_id = T1.bioguide WHERE T1.party = 'Readjuster Democrat'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE actor (\n ActorID integer PRIMARY KEY,\n Name text,\n Date of Birth date,\n Birth City text,\n Birth Country text,\n Height (Inches) integer,\n Biography text,\n Gender text,\n Ethnicity text,\n NetWorth text\n);\nCREATE TABLE movie (\n MovieID integer PRIMARY KEY,\n Title text,\n MPAA Rating text,\n Budget integer,\n Gross integer,\n Release Date text,\n Genre text,\n Runtime integer,\n Rating real,\n Rating Count integer,\n Summary text\n);\nCREATE TABLE characters (\n MovieID integer PRIMARY KEY,\n ActorID integer PRIMARY KEY,\n Character Name text,\n creditOrder integer,\n pay text,\n screentime text\n);\n-- foreign keys: characters.MovieID -> movie.MovieID; characters.ActorID -> actor.ActorID\n\nHint: movie Batman refers to title = 'Batman'\n\nQuestion: Please list the names of the actors who played a role in the movie Batman."}, {"role": "assistant", "content": "SELECT T3.Name FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Title = 'Batman'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n/* \n * SQL scripts for CS61 Intro to SQL lectures\n * FILENAME SOCCER2.SQL\n */\n\nDROP TABLE IF EXISTS Player;\nDROP TABLE IF EXISTS Tryout;\nDROP TABLE IF EXISTS College;\n\nCREATE TABLE \tCollege \n ( cName \tvarchar(20) NOT NULL,\n state \tvarchar(2),\n enr \tnumeric(5,0),\n PRIMARY KEY (cName)\n );\n\nCREATE TABLE \tPlayer\n ( pID\t\t\tnumeric(5,0) NOT NULL,\n \tpName \tvarchar(20),\n yCard \tvarchar(3),\n HS \tnumeric(5,0),\n PRIMARY KEY (pID)\n );\n\nCREATE TABLE \tTryout\n ( pID\t\t\tnumeric(5,0),\n \tcName \tvarchar(20),\n pPos \tvarchar(8),\n decision varchar(3),\n PRIMARY KEY (pID, cName),\n FOREIGN KEY (pID) REFERENCES Player(pID),\n FOREIGN KEY (cName) REFERENCES College(cName)\n );\n\n/* note that \"left\" and \"right\" are reserved words in SQL */\n\nQuestion: What is the name of school that has the smallest enrollment in each state?"}, {"role": "assistant", "content": "SELECT cName , state , min(enr) FROM college GROUP BY state"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\nCREATE TABLE `Course_Authors_and_Tutors` (\n`author_id` INTEGER PRIMARY KEY,\n`author_tutor_ATB` VARCHAR(3),\n`login_name` VARCHAR(40),\n`password` VARCHAR(40),\n`personal_name` VARCHAR(80),\n`middle_name` VARCHAR(80),\n`family_name` VARCHAR(80),\n`gender_mf` VARCHAR(1),\n`address_line_1` VARCHAR(80)\n);\n\nQuestion: Find the common personal name of course authors and students."}, {"role": "assistant", "content": "SELECT personal_name FROM Course_Authors_and_Tutors INTERSECT SELECT personal_name FROM Students"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE `Addresses` (\n`address_id` INTEGER PRIMARY KEY,\n`line_1_number_building` VARCHAR(80),\n`city` VARCHAR(50),\n`zip_postcode` VARCHAR(20),\n`state_province_county` VARCHAR(50),\n`country` VARCHAR(50)\n);\n\nQuestion: Show the detail of vehicle with id 1."}, {"role": "assistant", "content": "SELECT vehicle_details FROM Vehicles WHERE vehicle_id = 1;"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\n-- phpMyAdmin SQL Dump\n-- version 4.0.10.7\n-- http://www.phpmyadmin.net\n--\n-- Host: localhost\n-- Generation Time: Mar 20, 2015 at 01:43 AM\n-- Server version: 5.5.34-cll-lve\n-- PHP Version: 5.4.23\n\n\n\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n/*!40101 SET NAMES utf8 */;\nCREATE TABLE IF NOT EXISTS `regions` (\n `REGION_ID` decimal(5,0) NOT NULL,\n `REGION_NAME` varchar(25) DEFAULT NULL,\n PRIMARY KEY (`REGION_ID`)\n);\n\n--\n-- Dumping data for table `regions`\n--\n\nQuestion: Find the first name and last name and department id for those employees who earn such amount of salary which is the smallest salary of any of the departments."}, {"role": "assistant", "content": "SELECT first_name , last_name , department_id FROM employees WHERE salary IN (SELECT MIN(salary) FROM employees GROUP BY department_id)"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE location (\n LocationID integer PRIMARY KEY,\n Country text,\n State text,\n StateCode text,\n City text\n);\nCREATE TABLE user (\n UserID text PRIMARY KEY,\n Gender text\n);\nCREATE TABLE twitter (\n TweetID text PRIMARY KEY,\n Weekday text,\n Hour integer,\n Day integer,\n Lang text,\n IsReshare text,\n Reach integer,\n RetweetCount integer,\n Likes integer,\n Klout integer,\n Sentiment real,\n text text,\n LocationID integer,\n UserID text\n);\n-- foreign keys: twitter.UserID -> user.UserID; twitter.LocationID -> location.LocationID\n\nHint: \"Florida\" is the State; male user refers to Gender = 'Male'; percentage = Divide (Count(UserID where Gender = 'Male'), Count (UserID)) * 100\n\nQuestion: What is the percentage of male Twitter users from Florida?"}, {"role": "assistant", "content": "SELECT SUM(CASE WHEN T3.Gender = 'Male' THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS percentage FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID INNER JOIN user AS T3 ON T3.UserID = T1.UserID WHERE T2.State = 'Florida'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"buildings\" (\n\"id\" int,\n\"name\" text,\n\"City\" text,\n\"Height\" int,\n\"Stories\" int,\n\"Status\" text,\nPRIMARY KEY(\"id\")\n);\n\nQuestion: Count the number of distinct company industries."}, {"role": "assistant", "content": "SELECT count(DISTINCT Industry) FROM Companies"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"company\" (\n\"Company_ID\" int,\n\"Rank\" int,\n\"Company\" text,\n\"Headquarters\" text,\n\"Main_Industry\" text,\n\"Sales_billion\" real,\n\"Profits_billion\" real,\n\"Assets_billion\" real,\n\"Market_Value\" real,\nPRIMARY KEY (\"Company_ID\")\n);\n\nCREATE TABLE \"gas_station\" (\n\"Station_ID\" int,\n\"Open_Year\" int,\n\"Location\" text,\n\"Manager_Name\" text,\n\"Vice_Manager_Name\" text,\n\"Representative_Name\" text,\nPRIMARY KEY (\"Station_ID\")\n);\n\nQuestion: For each main industry, what is the total number of companies for the industry with the highest total market value?"}, {"role": "assistant", "content": "SELECT main_industry , count(*) FROM company GROUP BY main_industry ORDER BY sum(market_value) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"candidate\" (\n\"Candidate_ID\" int,\n\"People_ID\" int,\n\"Poll_Source\" text,\n\"Date\" text,\n\"Support_rate\" real,\n\"Consider_rate\" real,\n\"Oppose_rate\" real,\n\"Unsure_rate\" real,\nPRIMARY KEY (\"Candidate_ID\"),\nFOREIGN KEY (\"People_ID\") REFERENCES \"people\"(\"People_ID\")\n);\n\nCREATE TABLE \"people\" (\n\"People_ID\" int,\n\"Sex\" text,\n\"Name\" text,\n\"Date_of_Birth\" text,\n\"Height\" real,\n\"Weight\" real,\nPRIMARY KEY (\"People_ID\")\n);\n\nQuestion: find the highest support percentage, lowest consider rate and oppose rate of all candidates."}, {"role": "assistant", "content": "SELECT max(support_rate) , min(consider_rate) , min(oppose_rate) FROM candidate"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE all_prevalences (\n ITEM text PRIMARY KEY,\n POPULATION TYPE text,\n OCCURRENCES integer,\n POPULATION COUNT integer,\n PREVALENCE RATE real,\n PREVALENCE PERCENTAGE real\n);\nCREATE TABLE patients (\n patient text PRIMARY KEY,\n birthdate date,\n deathdate date,\n ssn text,\n drivers text,\n passport text,\n prefix text,\n first text,\n last text,\n suffix text,\n maiden text,\n marital text,\n race text,\n ethnicity text,\n gender text,\n birthplace text,\n address text\n);\nCREATE TABLE encounters (\n ID text PRIMARY KEY,\n DATE date,\n PATIENT text,\n CODE integer,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE allergies (\n START text,\n STOP text,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text\n);\nCREATE TABLE careplans (\n ID text,\n START date,\n STOP date,\n PATIENT text,\n ENCOUNTER text,\n CODE real,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE conditions (\n START date,\n STOP date,\n PATIENT text,\n ENCOUNTER text,\n CODE integer,\n DESCRIPTION text\n);\nCREATE TABLE immunizations (\n DATE date PRIMARY KEY,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text\n);\nCREATE TABLE medications (\n START date PRIMARY KEY,\n STOP date,\n PATIENT text PRIMARY KEY,\n ENCOUNTER text PRIMARY KEY,\n CODE integer PRIMARY KEY,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE observations (\n DATE date,\n PATIENT text,\n ENCOUNTER text,\n CODE text,\n DESCRIPTION text,\n VALUE real,\n UNITS text\n);\nCREATE TABLE procedures (\n DATE date,\n PATIENT text,\n ENCOUNTER text,\n CODE integer,\n DESCRIPTION text,\n REASONCODE integer,\n REASONDESCRIPTION text\n);\nCREATE TABLE claims (\n ID text PRIMARY KEY,\n PATIENT text,\n BILLABLEPERIOD date,\n ORGANIZATION text,\n ENCOUNTER text,\n DIAGNOSIS text,\n TOTAL integer\n);\n-- foreign keys: encounters.PATIENT -> patients.patient; allergies.PATIENT -> patients.patient; allergies.ENCOUNTER -> encounters.ID; careplans.PATIENT -> patients.patient; careplans.ENCOUNTER -> encounters.ID; conditions.DESCRIPTION -> all_prevalences.ITEM; conditions.PATIENT -> patients.patient; conditions.ENCOUNTER -> encounters.ID; immunizations.PATIENT -> patients.patient; immunizations.ENCOUNTER -> encounters.ID; medications.PATIENT -> patients.patient; medications.ENCOUNTER -> encounters.ID; observations.PATIENT -> patients.patient; observations.ENCOUNTER -> encounters.ID; procedures.PATIENT -> patients.patient; procedures.ENCOUNTER -> encounters.ID\n\nQuestion: Describe the condition of patient Wilmer Koepp."}, {"role": "assistant", "content": "SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Wilmer' AND T1.last = 'Koepp'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE offices (\n officeCode text PRIMARY KEY,\n city text,\n phone text,\n addressLine1 text,\n addressLine2 text,\n state text,\n country text,\n postalCode text,\n territory text\n);\nCREATE TABLE employees (\n employeeNumber integer PRIMARY KEY,\n lastName text,\n firstName text,\n extension text,\n email text,\n officeCode text,\n reportsTo integer,\n jobTitle text\n);\nCREATE TABLE customers (\n customerNumber integer PRIMARY KEY,\n customerName text,\n contactLastName text,\n contactFirstName text,\n phone text,\n addressLine1 text,\n addressLine2 text,\n city text,\n state text,\n postalCode text,\n country text,\n salesRepEmployeeNumber integer,\n creditLimit real\n);\nCREATE TABLE orders (\n orderNumber integer PRIMARY KEY,\n orderDate date,\n requiredDate date,\n shippedDate date,\n status text,\n comments text,\n customerNumber integer\n);\nCREATE TABLE payments (\n customerNumber integer PRIMARY KEY,\n checkNumber text PRIMARY KEY,\n paymentDate date,\n amount real\n);\nCREATE TABLE productlines (\n productLine text PRIMARY KEY,\n textDescription text,\n htmlDescription text,\n image blob\n);\nCREATE TABLE products (\n productCode text PRIMARY KEY,\n productName text,\n productLine text,\n productScale text,\n productVendor text,\n productDescription text,\n quantityInStock integer,\n buyPrice real,\n MSRP real\n);\nCREATE TABLE orderdetails (\n orderNumber integer PRIMARY KEY,\n productCode text PRIMARY KEY,\n quantityOrdered integer,\n priceEach real,\n orderLineNumber integer\n);\n-- foreign keys: employees.reportsTo -> employees.employeeNumber; employees.officeCode -> offices.officeCode; customers.salesRepEmployeeNumber -> employees.employeeNumber; orders.customerNumber -> customers.customerNumber; payments.customerNumber -> customers.customerNumber; products.productLine -> productlines.productLine\n\nHint: Where can I find the office refers to address, comprising of addressLine1 and addressLine2; President is a jobTitle\n\nQuestion: Where can I find the office of the President of the company?"}, {"role": "assistant", "content": "SELECT t2.addressLine1, t2.addressLine2 FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t1.jobTitle = 'President'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE state (\n StateCode text PRIMARY KEY,\n State text,\n Region text\n);\nCREATE TABLE callcenterlogs (\n Date received date,\n Complaint ID text PRIMARY KEY,\n rand client text,\n phonefinal text,\n vru+line text,\n call_id integer,\n priority integer,\n type text,\n outcome text,\n server text,\n ser_start text,\n ser_exit text,\n ser_time text\n);\nCREATE TABLE client (\n client_id text PRIMARY KEY,\n sex text,\n day integer,\n month integer,\n year integer,\n age integer,\n social text,\n first text,\n middle text,\n last text,\n phone text,\n email text,\n address_1 text,\n address_2 text,\n city text,\n state text,\n zipcode integer,\n district_id integer\n);\nCREATE TABLE district (\n district_id integer PRIMARY KEY,\n city text,\n state_abbrev text,\n division text\n);\nCREATE TABLE events (\n Date received date,\n Product text,\n Sub-product text,\n Issue text,\n Sub-issue text,\n Consumer complaint narrative text,\n Tags text,\n Consumer consent provided? text,\n Submitted via text,\n Date sent to company text,\n Company response to consumer text,\n Timely response? text,\n Consumer disputed? text,\n Complaint ID text PRIMARY KEY,\n Client_ID text PRIMARY KEY\n);\nCREATE TABLE reviews (\n Date date PRIMARY KEY,\n Stars integer,\n Reviews text,\n Product text,\n district_id integer\n);\n-- foreign keys: callcenterlogs.rand client -> client.client_id; client.district_id -> district.district_id; district.state_abbrev -> state.StateCode; events.Client_ID -> client.client_id; events.Complaint ID -> callcenterlogs.Complaint ID; reviews.district_id -> district.district_id\n\nHint: detailed product refers to \"Sub-product\"; Mr refers to sex = 'Male';\n\nQuestion: Which detailed product did Mr Lennox Oliver Drake complain about?"}, {"role": "assistant", "content": "SELECT DISTINCT T2.`Sub-product` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Lennox' AND T1.middle = 'Oliver' AND T1.last = 'Drake' AND T1.sex = 'Male'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"book_club\" (\n\"book_club_id\" int,\n\"Year\" int,\n\"Author_or_Editor\" text,\n\"Book_Title\" text,\n\"Publisher\" text,\n\"Category\" text,\n\"Result\" text,\nPRIMARY KEY (\"book_club_id\")\n);\n\nQuestion: Which directors had a movie in either 1999 or 2000?"}, {"role": "assistant", "content": "SELECT director FROM movie WHERE YEAR = 1999 OR YEAR = 2000"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Categories (\n CategoryID integer PRIMARY KEY,\n CategoryName text,\n Description text\n);\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n CustomerName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n LastName text,\n FirstName text,\n BirthDate date,\n Photo text,\n Notes text\n);\nCREATE TABLE Shippers (\n ShipperID integer PRIMARY KEY,\n ShipperName text,\n Phone text\n);\nCREATE TABLE Suppliers (\n SupplierID integer PRIMARY KEY,\n SupplierName text,\n ContactName text,\n Address text,\n City text,\n PostalCode text,\n Country text,\n Phone text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n ProductName text,\n SupplierID integer,\n CategoryID integer,\n Unit text,\n Price real\n);\nCREATE TABLE Orders (\n OrderID integer PRIMARY KEY,\n CustomerID integer,\n EmployeeID integer,\n OrderDate datetime,\n ShipperID integer\n);\nCREATE TABLE OrderDetails (\n OrderDetailID integer PRIMARY KEY,\n OrderID integer,\n ProductID integer,\n Quantity integer\n);\n-- 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\n\nHint: is a UK citizen refers to Country = 'UK'\n\nQuestion: How many employees is a UK citizen and are they all covering the same region?"}, {"role": "assistant", "content": "SELECT COUNT(T1.EmployeeID), T3.RegionID 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.Country = 'UK' GROUP BY T3.RegionID"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE station (\n id INTEGER PRIMARY KEY,\n name TEXT,\n lat NUMERIC,\n long NUMERIC,\n dock_count INTEGER,\n city TEXT,\n installation_date TEXT);\n\nQuestion: What is the date, average temperature and mean humidity for the days with the 3 largest maximum gust speeds?"}, {"role": "assistant", "content": "SELECT date , mean_temperature_f , mean_humidity FROM weather ORDER BY max_gust_speed_mph DESC LIMIT 3"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE genre (\n id integer PRIMARY KEY,\n genre_name text\n);\nCREATE TABLE game (\n id integer PRIMARY KEY,\n genre_id integer,\n game_name text\n);\nCREATE TABLE platform (\n id integer PRIMARY KEY,\n platform_name text\n);\nCREATE TABLE publisher (\n id integer PRIMARY KEY,\n publisher_name text\n);\nCREATE TABLE game_publisher (\n id integer PRIMARY KEY,\n game_id integer,\n publisher_id integer\n);\nCREATE TABLE game_platform (\n id integer PRIMARY KEY,\n game_publisher_id integer,\n platform_id integer,\n release_year integer\n);\nCREATE TABLE region (\n id integer PRIMARY KEY,\n region_name text\n);\nCREATE TABLE region_sales (\n region_id integer,\n game_platform_id integer,\n num_sales real\n);\n-- 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\n\nHint: in 2004 refers to release_year = 2004; on PSP refers to platform_name = 'PSP'; percentage = divide(sum(platform_id where platform_name = 'PSP'), count(platform_id)) * 100% where release_year = 2004\n\nQuestion: Among the games released in 2004, what is the percentage of games on PSP?"}, {"role": "assistant", "content": "SELECT CAST(COUNT(CASE WHEN T1.platform_name = 'PSP' THEN T3.game_id ELSE NULL END) AS REAL) * 100 / COUNT(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 T2.release_year = 2004"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE location (\n locationID integer PRIMARY KEY,\n locationcity text,\n address text,\n state text,\n zipcode integer,\n officephone text\n);\nCREATE TABLE position (\n positionID integer PRIMARY KEY,\n positiontitle text,\n educationrequired text,\n minsalary text,\n maxsalary text\n);\nCREATE TABLE employee (\n ssn text PRIMARY KEY,\n lastname text,\n firstname text,\n hiredate text,\n salary text,\n gender text,\n performance text,\n positionID integer,\n locationID integer\n);\n-- foreign keys: employee.positionID -> position.positionID; employee.locationID -> location.locationID\n\nHint: full name = firstname, lastname; the lowest salary refers to MIN(salary)\n\nQuestion: Mention the employee's full name and performance status who got the lowest in salary per year."}, {"role": "assistant", "content": "SELECT firstname, lastname, performance FROM employee ORDER BY salary ASC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE \"list\" ( \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Grade\" INTEGER, \n\t\"Classroom\" INTEGER,\n\tPRIMARY KEY(LastName, FirstName)\n);\nCREATE TABLE \"teachers\" ( \n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Classroom\" INTEGER,\n\tPRIMARY KEY(LastName, FirstName)\n);\n\nQuestion: Report the number of students in each classroom."}, {"role": "assistant", "content": "SELECT classroom , count(*) FROM list GROUP BY classroom"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE divisions (\n division text PRIMARY KEY,\n name text,\n country text\n);\nCREATE TABLE matchs (\n Div text,\n Date date,\n HomeTeam text,\n AwayTeam text,\n FTHG integer,\n FTAG integer,\n FTR text,\n season integer\n);\n-- foreign keys: matchs.Div -> divisions.division\n\nHint: the most 0-0 games means a no-score draw and refers to MAX(COUNT(Div where FTHG = '0' and FTAG = '0'));\n\nQuestion: Give the full name of the divison that had the most 0-0 games."}, {"role": "assistant", "content": "SELECT T2.name FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.FTAG = 0 AND T1.FTHG = 0 GROUP BY T2.division ORDER BY COUNT(T1.FTAG) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Country (\n CountryCode text PRIMARY KEY,\n ShortName text,\n TableName text,\n LongName text,\n Alpha2Code text,\n CurrencyUnit text,\n SpecialNotes text,\n Region text,\n IncomeGroup text,\n Wb2Code text,\n NationalAccountsBaseYear text,\n NationalAccountsReferenceYear text,\n SnaPriceValuation text,\n LendingCategory text,\n OtherGroups text,\n SystemOfNationalAccounts text,\n AlternativeConversionFactor text,\n PppSurveyYear text,\n BalanceOfPaymentsManualInUse text,\n ExternalDebtReportingStatus text,\n SystemOfTrade text,\n GovernmentAccountingConcept text,\n ImfDataDisseminationStandard text,\n LatestPopulationCensus text,\n LatestHouseholdSurvey text,\n SourceOfMostRecentIncomeAndExpenditureData text,\n VitalRegistrationComplete text,\n LatestAgriculturalCensus text,\n LatestIndustrialData integer,\n LatestTradeData integer,\n LatestWaterWithdrawalData integer\n);\nCREATE TABLE Series (\n SeriesCode text PRIMARY KEY,\n Topic text,\n IndicatorName text,\n ShortDefinition text,\n LongDefinition text,\n UnitOfMeasure text,\n Periodicity text,\n BasePeriod text,\n OtherNotes integer,\n AggregationMethod text,\n LimitationsAndExceptions text,\n NotesFromOriginalSource text,\n GeneralComments text,\n Source text,\n StatisticalConceptAndMethodology text,\n DevelopmentRelevance text,\n RelatedSourceLinks text,\n OtherWebLinks integer,\n RelatedIndicators integer,\n LicenseType text\n);\nCREATE TABLE CountryNotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Footnotes (\n Countrycode text PRIMARY KEY,\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\nCREATE TABLE Indicators (\n CountryName text,\n CountryCode text PRIMARY KEY,\n IndicatorName text,\n IndicatorCode text PRIMARY KEY,\n Year integer PRIMARY KEY,\n Value integer\n);\nCREATE TABLE SeriesNotes (\n Seriescode text PRIMARY KEY,\n Year text PRIMARY KEY,\n Description text\n);\n-- foreign keys: CountryNotes.Countrycode -> Country.CountryCode; CountryNotes.Seriescode -> Series.SeriesCode; Footnotes.Countrycode -> Country.CountryCode; Footnotes.Seriescode -> Series.SeriesCode; Indicators.CountryCode -> Country.CountryCode; SeriesNotes.Seriescode -> Series.SeriesCode\n\nHint: Albania is the name of country where Country = 'Albania'\n\nQuestion: Please write down the footnote descriptions of Albania in 1981."}, {"role": "assistant", "content": "SELECT DISTINCT T1.Description FROM FootNotes AS T1 INNER JOIN Country AS T2 ON T1.Countrycode = T2.CountryCode WHERE T1.Year = 'YR1981' AND T2.ShortName = 'Albania'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Employees (\n EmployeeID integer PRIMARY KEY,\n FirstName text,\n MiddleInitial text,\n LastName text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Name text,\n Price real\n);\nCREATE TABLE Sales (\n SalesID integer PRIMARY KEY,\n SalesPersonID integer,\n CustomerID integer,\n ProductID integer,\n Quantity integer\n);\n-- foreign keys: Sales.ProductID -> Products.ProductID; Sales.CustomerID -> Customers.CustomerID; Sales.SalesPersonID -> Employees.EmployeeID\n\nQuestion: What is the first name of employee who handled sales for customer called Abigail?"}, {"role": "assistant", "content": "SELECT DISTINCT T3.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T1.FirstName = 'Abigail'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE institution_details (\n unitid integer PRIMARY KEY,\n chronname text,\n city text,\n state text,\n level text,\n control text,\n basic text,\n hbcu text,\n flagship text,\n long_x real,\n lat_y real,\n site text,\n student_count integer,\n awards_per_value real,\n awards_per_state_value real,\n awards_per_natl_value real,\n exp_award_value integer,\n exp_award_state_value integer,\n exp_award_natl_value integer,\n exp_award_percentile integer,\n ft_pct real,\n fte_value integer,\n fte_percentile integer,\n med_sat_value text,\n med_sat_percentile text,\n aid_value integer,\n aid_percentile integer,\n endow_value text,\n endow_percentile text,\n grad_100_value real,\n grad_100_percentile integer,\n grad_150_value real,\n grad_150_percentile integer,\n pell_value real,\n pell_percentile integer,\n retain_value real,\n retain_percentile integer,\n ft_fac_value real,\n ft_fac_percentile integer,\n vsa_year text,\n vsa_grad_after4_first text,\n vsa_grad_elsewhere_after4_first text,\n vsa_enroll_after4_first text,\n vsa_enroll_elsewhere_after4_first text,\n vsa_grad_after6_first text,\n vsa_grad_elsewhere_after6_first text,\n vsa_enroll_after6_first text,\n vsa_enroll_elsewhere_after6_first text,\n vsa_grad_after4_transfer text,\n vsa_grad_elsewhere_after4_transfer text,\n vsa_enroll_after4_transfer text,\n vsa_enroll_elsewhere_after4_transfer text,\n vsa_grad_after6_transfer text,\n vsa_grad_elsewhere_after6_transfer text,\n vsa_enroll_after6_transfer text,\n vsa_enroll_elsewhere_after6_transfer text,\n similar text,\n state_sector_ct integer,\n carnegie_ct integer,\n counted_pct text,\n nicknames text,\n cohort_size integer\n);\nCREATE TABLE institution_grads (\n unitid integer,\n year integer,\n gender text,\n race text,\n cohort text,\n grad_cohort text,\n grad_100 text,\n grad_150 text,\n grad_100_rate text,\n grad_150_rate text\n);\nCREATE TABLE state_sector_grads (\n stateid integer,\n state text,\n state_abbr text,\n control text,\n level text,\n year integer,\n gender text,\n race text,\n cohort text,\n grad_cohort text,\n grad_100 text,\n grad_150 text,\n grad_100_rate text,\n grad_150_rate text,\n grad_cohort_ct integer\n);\nCREATE TABLE state_sector_details (\n stateid integer PRIMARY KEY,\n state text,\n state_post text,\n level text PRIMARY KEY,\n control text PRIMARY KEY,\n schools_count integer,\n counted_pct text,\n awards_per_state_value text,\n awards_per_natl_value real,\n exp_award_state_value text,\n exp_award_natl_value integer,\n state_appr_value text,\n state_appr_rank text,\n grad_rate_rank text,\n awards_per_rank text\n);\n-- foreign keys: institution_grads.unitid -> institution_details.unitid; state_sector_grads.stateid -> state_sector_details.stateid; state_sector_grads.state -> institution_details.state; state_sector_details.state -> institution_details.state\n\nHint: Alabama refers to state = 'Alabama'; number of students greater than the 90% of average = MULTIPLY(AVG(student_count), 90%) < student_count;\n\nQuestion: List the race of institutions in Alabama with number of students greater than the 90% of average number of students of all institutions?"}, {"role": "assistant", "content": "SELECT DISTINCT T2.race FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T2.unitid = T1.unitid WHERE T1.student_count > ( SELECT AVG(T1.student_count) * 0.9 FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T2.unitid = T1.unitid WHERE T1.state = 'Alabama' ) AND T1.state = 'Alabama'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE cites (\n cited_paper_id text PRIMARY KEY,\n citing_paper_id text PRIMARY KEY\n);\nCREATE TABLE paper (\n paper_id text PRIMARY KEY,\n class_label text\n);\nCREATE TABLE content (\n paper_id text PRIMARY KEY,\n word_cited_id text PRIMARY KEY\n);\n-- foreign keys: content.paper_id -> paper.paper_id\n\nHint: classification refers to class_label; class_label = 'DB';\n\nQuestion: Among the papers under DB classification, which paper has the highest number of words cited?"}, {"role": "assistant", "content": "SELECT T1.paper_id FROM paper AS T1 INNER JOIN content AS T2 ON T1.paper_id = T2.paper_id WHERE T1.class_label = 'DB' GROUP BY T1.paper_id ORDER BY COUNT(T2.word_cited_id) DESC LIMIT 1"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE Customers (\n CustomerID integer PRIMARY KEY,\n Customer Names text\n);\nCREATE TABLE Products (\n ProductID integer PRIMARY KEY,\n Product Name text\n);\nCREATE TABLE Regions (\n StateCode text PRIMARY KEY,\n State text,\n Region text\n);\nCREATE TABLE Sales Team (\n SalesTeamID integer PRIMARY KEY,\n Sales Team text,\n Region text\n);\nCREATE TABLE Store Locations (\n StoreID integer PRIMARY KEY,\n City Name text,\n County text,\n StateCode text,\n State text,\n Type text,\n Latitude real,\n Longitude real,\n AreaCode integer,\n Population integer,\n Household Income integer,\n Median Income integer,\n Land Area integer,\n Water Area integer,\n Time Zone text\n);\nCREATE TABLE Sales Orders (\n OrderNumber text PRIMARY KEY,\n Sales Channel text,\n WarehouseCode text,\n ProcuredDate text,\n OrderDate text,\n ShipDate text,\n DeliveryDate text,\n CurrencyCode text,\n _SalesTeamID integer,\n _CustomerID integer,\n _StoreID integer,\n _ProductID integer,\n Order Quantity integer,\n Discount Applied real,\n Unit Price text,\n Unit Cost text\n);\n-- 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\n\nHint: highest discount applied refers to Max(Discount Applied)\n\nQuestion: What is the highest discount applied by the store located in a city of the state of Colorado whose land area is 111039036."}, {"role": "assistant", "content": "SELECT MAX(T1.`Discount Applied`) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T2.State = 'Colorado' AND T2.`Land Area` = 111039036"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nCREATE TABLE current (\n ballotpedia_id text,\n bioguide_id text PRIMARY KEY,\n birthday_bio date,\n cspan_id real PRIMARY KEY,\n fec_id text,\n first_name text,\n gender_bio text,\n google_entity_id_id text,\n govtrack_id integer,\n house_history_id real,\n icpsr_id real,\n last_name text,\n lis_id text,\n maplight_id real,\n middle_name text,\n nickname_name text,\n official_full_name text,\n opensecrets_id text,\n religion_bio text,\n suffix_name text,\n thomas_id integer,\n votesmart_id real,\n wikidata_id text,\n wikipedia_id text\n);\nCREATE TABLE current-terms (\n address text,\n bioguide text PRIMARY KEY,\n caucus text,\n chamber text,\n class real,\n contact_form text,\n district real,\n end text PRIMARY KEY,\n fax text,\n last text,\n name text,\n office text,\n party text,\n party_affiliations text,\n phone text,\n relation text,\n rss_url text,\n start text,\n state text,\n state_rank text,\n title text,\n type text,\n url text\n);\nCREATE TABLE historical (\n ballotpedia_id text,\n bioguide_id text PRIMARY KEY,\n bioguide_previous_id text,\n birthday_bio text,\n cspan_id text,\n fec_id text,\n first_name text,\n gender_bio text,\n google_entity_id_id text,\n govtrack_id integer,\n house_history_alternate_id text,\n house_history_id real,\n icpsr_id real,\n last_name text,\n lis_id text,\n maplight_id text,\n middle_name text,\n nickname_name text,\n official_full_name text,\n opensecrets_id text,\n religion_bio text,\n suffix_name text,\n thomas_id text,\n votesmart_id text,\n wikidata_id text,\n wikipedia_id text\n);\nCREATE TABLE historical-terms (\n address text,\n bioguide text PRIMARY KEY,\n chamber text,\n class real,\n contact_form text,\n district real,\n end text,\n fax text,\n last text,\n middle text,\n name text,\n office text,\n party text,\n party_affiliations text,\n phone text,\n relation text,\n rss_url text,\n start text,\n state text,\n state_rank text,\n title text,\n type text,\n url text\n);\nCREATE TABLE social-media (\n bioguide text PRIMARY KEY,\n facebook text,\n facebook_id real,\n govtrack real,\n instagram text,\n instagram_id real,\n thomas integer,\n twitter text,\n twitter_id real,\n youtube text,\n youtube_id text\n);\n-- foreign keys: current-terms.bioguide -> current.bioguide_id; historical-terms.bioguide -> historical.bioguide_id; social-media.bioguide -> current.bioguide_id\n\nHint: male refers to gender_bio = 'M'; born between 1955 to 1965 refers to strftime('%Y', birthday_bio) between '1955' and '1965'; percentage = MULTIPLY(DIVIDE(SUM(party = 'Independent' WHERE gender_bio = 'M' AND strftime('%Y', birthday_bio) between '1955' and '1965'), COUNT(party WHERE gender_bio = 'M' AND strftime('%Y', birthday_bio) between '1955' and '1965')), 100.0);\n\nQuestion: Among the male legislators born between 1955 to 1965, what is the percentage of the legislators with an independent party?"}, {"role": "assistant", "content": "SELECT CAST(SUM(CASE WHEN T2.party = 'Independent' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.party) FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.gender_bio = 'M' AND strftime('%Y', T1.birthday_bio) BETWEEN '1955' AND '1965'"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE Services (\nService_ID INTEGER NOT NULL,\nService_Type_Code CHAR(15) NOT NULL,\nPRIMARY KEY (Service_ID)\n);\n\nQuestion: What are all the the participant ids, type code and details?"}, {"role": "assistant", "content": "SELECT Participant_ID , Participant_Type_Code , Participant_Details FROM Participants"}]} {"messages": [{"role": "system", "content": "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."}, {"role": "user", "content": "Schema:\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE \"wrestler\" (\n\"Wrestler_ID\" int,\n\"Name\" text,\n\"Reign\" text,\n\"Days_held\" text,\n\"Location\" text,\n\"Event\" text,\nPRIMARY KEY (\"Wrestler_ID\")\n);\n\nCREATE TABLE \"Elimination\" (\n\"Elimination_ID\" text,\n\"Wrestler_ID\" text,\n\"Team\" text,\n\"Eliminated_By\" text,\n\"Elimination_Move\" text,\n\"Time\" text,\nPRIMARY KEY (\"Elimination_ID\"),\nFOREIGN KEY (\"Wrestler_ID\") REFERENCES \"wrestler\"(\"Wrestler_ID\")\n);\n\nQuestion: What are the reigns and days held of all wrestlers?"}, {"role": "assistant", "content": "SELECT Reign , Days_held FROM wrestler"}]}