messages
listlengths
3
3
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE trip (\n\tid INTEGER, \n\tduration INTEGER, \n\tstart_date TEXT, \n\tstart_station_name TEXT, \n\tstart_station_id INTEGER, \n\tend_date TEXT, \n\tend_station_name TEXT, \n\tend_station_id INTEGER, \n\tbike_id INTEGER, \n\tsubscription_type TEXT, \n\tzip_code INTEGER, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in trip and 3 examples in each column for high cardinality columns :\nid : 900645, 900752, 900524\nduration : 1131, 2146, 1155\nstart_date : 8/21/2015 17:39, 8/21/2015 17:03, 8/21/2015 17:16\nstart_station_name : Howard at 2nd, 2nd at Folsom, Market at 10th\nstart_station_id : 56, 65, 49\nend_date : 8/21/2015 17:19, 8/21/2015 18:08, 8/21/2015 17:32\nend_station_name : Howard at 2nd, 2nd at Folsom, Market at 10th\nend_station_id : 56, 65, 49\nbike_id : 586, 56, 65\nzip_code : 94070, 94530, 94040-1724\n*/\n/*\nColumns in trip and all categories for low cardinality columns :\nsubscription_type : Customer, Subscriber\n*/\n \nCREATE TABLE \"Problems\" (\n\tproblem_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\tclosure_authorised_by_staff_id INTEGER NOT NULL, \n\treported_by_staff_id INTEGER NOT NULL, \n\tdate_problem_reported DATETIME NOT NULL, \n\tdate_problem_closed DATETIME, \n\tproblem_description VARCHAR(255), \n\tother_problem_details VARCHAR(255), \n\tPRIMARY KEY (problem_id), \n\tFOREIGN KEY(reported_by_staff_id) REFERENCES \"Staff\" (staff_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Product\" (product_id), \n\tFOREIGN KEY(closure_authorised_by_staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Problems and 3 examples in each column for high cardinality columns :\nproblem_id : 1, 13, 11\nclosure_authorised_by_staff_id : 1, 13, 2\ndate_problem_reported : 1995-05-14 08:32:56, 1988-11-07 16:09:31, 1986-11-13 07:30:55\ndate_problem_closed : 1974-09-20 13:42:19, 1997-10-18 20:09:57, 2004-06-20 01:08:25\nproblem_description : d, i, s\n*/\n/*\nColumns in Problems and all categories for low cardinality columns :\nproduct_id : 1, 13, 2, 5, 7, 8, 4, 6, 15\nreported_by_staff_id : 1, 13, 11, 2, 5, 7, 4, 14, 10\nother_problem_details : f, m, i, s, k, l, p, v, c\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE category (\n\tcategory_id INTEGER NOT NULL, \n\tname VARCHAR(25) NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (category_id)\n)\n/*\nColumns in category and 3 examples in each column for high cardinality columns :\ncategory_id : 1, 16, 13\nname : Family, Sci-Fi, Action\n*/\n/*\nColumns in category and all categories for low cardinality columns :\nlast_update : 2006-02-15 04:46:27\n*/\n \nCREATE TABLE ship (\n\t\"Ship_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Type\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Tonnage\" INTEGER, \n\tPRIMARY KEY (\"Ship_ID\")\n)\n/*\nColumns in ship and all categories for low cardinality columns :\nShip_ID : 1, 2, 5, 7, 8, 4, 6, 3\nName : Clan McTavish, Farringford, Appam, Author, Dromonby, Corbridge, Trader, Ariadne\nType : Battle ship, Cargo ship\nNationality : United States, United Kingdom\nTonnage : 3035, 3146, 7781, 3496, 3687, 5816, 3627, 3608\n*/\n \nCREATE TABLE member_attendance (\n\t\"Member_ID\" INTEGER, \n\t\"Performance_ID\" INTEGER, \n\t\"Num_of_Pieces\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\", \"Performance_ID\"), \n\tFOREIGN KEY(\"Performance_ID\") REFERENCES performance (\"Performance_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in member_attendance and all categories for low cardinality columns :\nMember_ID : 1, 11, 2, 5, 7, 4, 3\nPerformance_ID : 1, 2, 4, 6, 3\nNum_of_Pieces : 1, 2, 4, 3\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE chip_model (\n\t\"Model_name\" TEXT, \n\t\"Launch_year\" REAL, \n\t\"RAM_MiB\" REAL, \n\t\"ROM_MiB\" REAL, \n\t\"Slots\" TEXT, \n\t\"WiFi\" TEXT, \n\t\"Bluetooth\" TEXT, \n\tPRIMARY KEY (\"Model_name\")\n)\n/*\nColumns in chip_model and 3 examples in each column for high cardinality columns :\nModel_name : X30 mid-range, X50 Advanced, X51 mid-range\n*/\n/*\nColumns in chip_model and all categories for low cardinality columns :\nLaunch_year : 2002.0, 2005.0, 2004.0, 2003.0\nRAM_MiB : 32.0, 64.0\nROM_MiB : 48.0, 256.0, 128.0, 32.0, 64.0\nSlots : 1CFII,1SD, 1SD\nWiFi : 802.11b, No\nBluetooth : 1.2, Yes, No, 1.1\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE mountain (\n\t\"Mountain_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Prominence\" REAL, \n\t\"Range\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (\"Mountain_ID\")\n)\n/*\nColumns in mountain and all categories for low cardinality columns :\nMountain_ID : 1, 2, 5, 7, 4, 6, 3\nName : Ngaliema / Mt Stanley (Margherita Pk), Mount Kenya (Lenana), Kibo (Uhuru Pk), Ngaliema / Mt Stanley (Savoia Pk), Mount Kenya (Batian), Duwoni / Mt Speke (Vittorio Emanuele Pk), Mawenzi (Hans Meyer Pk)\nHeight : 5109.0, 5199.0, 5895.0, 4890.0, 4985.0, 4977.0, 5148.0\nProminence : 720.0, 850.0, 3951.0, 3825.0, 130.0, 5885.0, 110.0\nRange : Kilimanjaro, Mount Kenya, Rwenzori\nCountry : DR Congo Uganda, Uganda, Tanzania, Kenya\n*/\n \nCREATE TABLE \"Restaurant_Type\" (\n\t\"ResTypeID\" INTEGER, \n\t\"ResTypeName\" VARCHAR(40), \n\t\"ResTypeDescription\" VARCHAR(100), \n\tPRIMARY KEY (\"ResTypeID\")\n)\n/*\nColumns in Restaurant_Type and all categories for low cardinality columns :\nResTypeID : 1, 2\nResTypeName : Sandwich, Stir-fry\nResTypeDescription : Classic Chinese cooking., Simplest there is.\n*/\n \nCREATE TABLE farm_competition (\n\t\"Competition_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Theme\" TEXT, \n\t\"Host_city_ID\" INTEGER, \n\t\"Hosts\" TEXT, \n\tPRIMARY KEY (\"Competition_ID\"), \n\tFOREIGN KEY(\"Host_city_ID\") REFERENCES city (\"City_ID\")\n)\n/*\nColumns in farm_competition and all categories for low cardinality columns :\nCompetition_ID : 1, 2, 5, 4, 6, 3\nYear : 2004, 2013, 2005, 2006, 2003, 2002\nTheme : MTV Cube, Valentine's Day, Codehunters, Carnival M is back!, Aliens, MTV Asia Aid\nHost_city_ID : 1, 2, 5, 4, 3\nHosts : Mandy Moore and Ronan Keating, Alicia Keys, Shaggy and Coco Lee, Leehom Wang and Kelly Rowland, Miley Cyrus Jared Leto and Karen Mok, Vanness Wu and Michelle Branch\n*/\n \nCREATE TABLE \"Country\" (\n\tid INTEGER, \n\tname TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Country and 3 examples in each column for high cardinality columns :\nid : 1, 19694, 7809\nname : Scotland, Italy, Spain\n*/\n\n \nCREATE TABLE artist (\n\tartist_name TEXT(50) NOT NULL, \n\tcountry TEXT(20), \n\tgender TEXT(20), \n\tpreferred_genre TEXT(50), \n\tCONSTRAINT a_name PRIMARY KEY (artist_name), \n\tFOREIGN KEY(preferred_genre) REFERENCES genre (g_name) ON DELETE CASCADE\n)\n/*\nColumns in artist and all categories for low cardinality columns :\nartist_name : Prity, Michel, Topu, Shrikanta, Enrique, Farida\ncountry : India, UK, USA, Bangladesh\ngender : Male, Female\npreferred_genre : tagore, folk, modern, nazrul, blues, pop\n*/\n \nCREATE TABLE \"Organizations\" (\n\torganization_id INTEGER NOT NULL, \n\tparent_organization_id INTEGER, \n\torganization_details VARCHAR(255), \n\tPRIMARY KEY (organization_id)\n)\n/*\nColumns in Organizations and all categories for low cardinality columns :\norganization_id : 7, 8, 10\nparent_organization_id : 7, 8\norganization_details : Denesik and Sons Party, Reinger, Hudson and Nolan Group, Robel-Schulist Group\n*/\n \nCREATE TABLE school (\n\t\"School_ID\" INTEGER, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Enrollment\" REAL, \n\t\"Founded\" REAL, \n\t\"Denomination\" TEXT, \n\t\"Boys_or_Girls\" TEXT, \n\t\"Day_or_Boarding\" TEXT, \n\t\"Year_Entered_Competition\" REAL, \n\t\"School_Colors\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 4, 6, 3\nSchool : St Aloysius' College, Cranbrook School, Waverley College, Knox Grammar School, Barker College, Trinity Grammar School\nLocation : Hornsby, Summer Hill, Waverley, Bellevue Hill, Milsons Point, Wahroonga\nEnrollment : 1000.0, 1850.0, 2200.0, 1200.0, 2300.0, 1430.0\nFounded : 1918.0, 1924.0, 1913.0, 1879.0, 1903.0, 1890.0\nDenomination : Catholic, Uniting Church, Anglican\nBoys_or_Girls : Boys only to Yr 9 Co-ed Year 10 to 12, Boys\nDay_or_Boarding : Day, Day & Boarding\nYear_Entered_Competition : 1944.0, 1929.0\nSchool_Colors : Royal Blue and Gold, Black & Blue, Red, White & Blue, Red & Blue, Green and White\n*/\n \nCREATE TABLE flight (\n\tid INTEGER, \n\t\"Vehicle_Flight_number\" TEXT, \n\t\"Date\" TEXT, \n\t\"Pilot\" TEXT, \n\t\"Velocity\" REAL, \n\t\"Altitude\" REAL, \n\tairport_id INTEGER, \n\tcompany_id INTEGER, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(company_id) REFERENCES operate_company (id), \n\tFOREIGN KEY(airport_id) REFERENCES airport (id)\n)\n/*\nColumns in flight and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nVehicle_Flight_number : M2-F1 #14, M2-F1 #61, M2-F1 #0\nDate : July 16, 1965, May 19, 1964, March 28, 1966\n*/\n/*\nColumns in flight and all categories for low cardinality columns :\nPilot : Thompson, Peterson\nVelocity : 240.0, 135.0\nAltitude : 3650.0, 0.0\nairport_id : 1, 2, 5, 8, 4, 6, 3, 9\ncompany_id : 1, 13, 11, 2, 5, 7, 4, 6, 3, 9\n*/\n \nCREATE TABLE \"Type_Of_Restaurant\" (\n\t\"ResID\" INTEGER, \n\t\"ResTypeID\" INTEGER, \n\tFOREIGN KEY(\"ResID\") REFERENCES \"Restaurant\" (\"ResID\"), \n\tFOREIGN KEY(\"ResTypeID\") REFERENCES \"Restaurant_Type\" (\"ResTypeID\")\n)\n/*\nColumns in Type_Of_Restaurant and all categories for low cardinality columns :\nResID : 1, 2\nResTypeID : 1, 2\n*/\n \nCREATE TABLE journalist (\n\t\"journalist_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Age\" TEXT, \n\t\"Years_working\" INTEGER, \n\tPRIMARY KEY (\"journalist_ID\")\n)\n/*\nColumns in journalist and 3 examples in each column for high cardinality columns :\njournalist_ID : 1, 11, 2\nName : Jack Meaney, Herbert Swindells, Jackie Waring\n*/\n/*\nColumns in journalist and all categories for low cardinality columns :\nNationality : Northern Ireland, Wales, England\nAge : 37, 28, 25, 33, 34, 43, 27, 29\nYears_working : 1, 5, 7, 8, 21, 6, 3, 12, 10, 9\n*/\n \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)\n/*\nColumns in list and 3 examples in each column for high cardinality columns :\nLastName : HOUTCHENS, GELL, FLACHS\nFirstName : RAY, EMILE, PATRINA\nClassroom : 109, 110, 106\n*/\n/*\nColumns in list and all categories for low cardinality columns :\nGrade : 1, 2, 5, 4, 6, 3, 0\n*/\n" }, { "role": "user", "content": "How many heads of the departments are older than 56 ?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: head.\nFrom these tables, I'll be using the following columns: age.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM head WHERE age > 56" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE \"Documents_with_Expenses\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Budget_Type_Code\" CHAR(15) NOT NULL, \n\t\"Document_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Budget_Type_Code\") REFERENCES \"Ref_Budget_Codes\" (\"Budget_Type_Code\"), \n\tFOREIGN KEY(\"Document_ID\") REFERENCES \"Documents\" (\"Document_ID\")\n)\n/*\nColumns in Documents_with_Expenses and all categories for low cardinality columns :\nDocument_ID : 300, 240, 309, 226, 367, 371, 383, 227, 192, 57\nBudget_Type_Code : GV, SF, ORG\nDocument_Details : government, safety, organization\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_address_id INTEGER NOT NULL, \n\tcustomer_status_code VARCHAR(15) NOT NULL, \n\tdate_became_customer DATETIME, \n\tdate_of_birth DATETIME, \n\tfirst_name VARCHAR(80), \n\tlast_name VARCHAR(80), \n\tamount_outstanding DOUBLE, \n\temail_address VARCHAR(250), \n\tphone_number VARCHAR(255), \n\tcell_mobile_phone_number VARCHAR(255), \n\tPRIMARY KEY (customer_id), \n\tFOREIGN KEY(customer_address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\ndate_became_customer : 2016-03-18 06:14:18, 2016-05-13 07:38:23, 2017-10-05 14:15:46\ndate_of_birth : 1994-05-07 01:32:16, 1991-12-05 02:50:15, 1998-09-18 04:45:01\nfirst_name : Millie, Dianna, Carole\nlast_name : Schmeler, Tromp, Goodwin\namount_outstanding : 7093.0, 8144.0, 9447.0\nemail_address : mariela28@example.org, wehner.harold@example.com, afranecki@example.com\nphone_number : 1-618-535-9750, 218.550.1362, 753.921.0871\ncell_mobile_phone_number : 578-518-4785x612, (780)719-4206x033, (630)964-2426\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\ncustomer_address_id : 1, 13, 2, 7, 8, 12, 10, 9\ncustomer_status_code : Bad Customer, Good Customer\n*/\n \nCREATE TABLE \"Instruments\" (\n\t\"SongId\" INTEGER, \n\t\"BandmateId\" INTEGER, \n\t\"Instrument\" TEXT, \n\tPRIMARY KEY (\"SongId\", \"BandmateId\", \"Instrument\"), \n\tFOREIGN KEY(\"SongId\") REFERENCES \"Songs\" (\"SongId\"), \n\tFOREIGN KEY(\"BandmateId\") REFERENCES \"Band\" (\"Id\")\n)\n/*\nColumns in Instruments and all categories for low cardinality columns :\nSongId : \nBandmateId : \nInstrument : \n*/\n \nCREATE TABLE \"Apartments\" (\n\tapt_id INTEGER NOT NULL, \n\tbuilding_id INTEGER NOT NULL, \n\tapt_type_code CHAR(15), \n\tapt_number CHAR(10), \n\tbathroom_count INTEGER, \n\tbedroom_count INTEGER, \n\troom_count CHAR(5), \n\tPRIMARY KEY (apt_id), \n\tFOREIGN KEY(building_id) REFERENCES \"Apartment_Buildings\" (building_id), \n\tUNIQUE (apt_id)\n)\n/*\nColumns in Apartments and 3 examples in each column for high cardinality columns :\napt_id : 1, 13, 11\napt_number : Suite 307, Apt. 411, Apt. 585\n*/\n/*\nColumns in Apartments and all categories for low cardinality columns :\nbuilding_id : 153, 673, 808, 744, 624, 790, 191, 734, 225\napt_type_code : Studio, Flat, Duplex\nbathroom_count : 1, 2, 3\nbedroom_count : 5, 4, 6, 3\nroom_count : 5, 7, 8, 6, 3, 9\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_first_name VARCHAR(20), \n\tcustomer_last_name VARCHAR(20), \n\tcustomer_address VARCHAR(255), \n\tcustomer_phone VARCHAR(255), \n\tcustomer_email VARCHAR(255), \n\tother_customer_details VARCHAR(255), \n\tPRIMARY KEY (customer_id)\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\ncustomer_first_name : Armani, Bryce, Nat\ncustomer_last_name : Swift, Lind, Huels\ncustomer_address : 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898, 47286 Mraz Park Apt. 424\nJocelynfurt, OH 59023-2787, 094 Julianne Mill\nWebstertown, KY 91980-4004\ncustomer_phone : (415)237-0701x3115, 679-845-8645x94312, 284.749.0453\ncustomer_email : kyra.murazik@example.org, schaden.katrina@example.net, huels.antonina@example.com\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\nother_customer_details : None\n*/\n \nCREATE TABLE \"Guests\" (\n\tguest_id INTEGER NOT NULL, \n\tgender_code CHAR(1), \n\tguest_first_name VARCHAR(80), \n\tguest_last_name VARCHAR(80), \n\tdate_of_birth DATETIME, \n\tPRIMARY KEY (guest_id), \n\tUNIQUE (guest_id)\n)\n/*\nColumns in Guests and 3 examples in each column for high cardinality columns :\nguest_id : 1, 13, 11\nguest_first_name : Louvenia, Lou, Keith\nguest_last_name : Bode, Mante, Schowalter\ndate_of_birth : 2001-06-18 20:05:55, 1980-06-20 18:15:39, 1997-01-15 17:37:40\n*/\n/*\nColumns in Guests and all categories for low cardinality columns :\ngender_code : Male, Unknown, Female\n*/\n \nCREATE TABLE school_details (\n\t\"School_ID\" INTEGER, \n\t\"Nickname\" TEXT, \n\t\"Colors\" TEXT, \n\t\"League\" TEXT, \n\t\"Class\" TEXT, \n\t\"Division\" TEXT, \n\tPRIMARY KEY (\"School_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in school_details and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 4, 6, 3\nNickname : Auks, Raiders, Silver Eagles, Seahawks, Buccaneers, Tigers\nColors : Dark Green and White, Blue and Yellow, Maroon and White, Blue and Gold, Garnet and White, Silver and Maroon\nLeague : DSHA\nClass : Flight B, Flight A, Fight A\nDivision : Division 1, Division 2, Division 3\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Sex\" TEXT, \n\t\"Name\" TEXT, \n\t\"Date_of_Birth\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and all categories for low cardinality columns :\nPeople_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nSex : F, M\nName : Vincent Montméat, Frantz Granvorka, Loïc De Kergret, Philippe Barça-Cysique, Guillaume Samica, Stéphane Antiga, Dominique Daquin, Laurent Capet, Hubert Henno\nDate_of_Birth : 20.08.1970, 10.03.1976, 05.05.1972, 28.09.1981, 22.04.1977, 01.09.1977, 10.11.1972, 06.10.1976, 03.02.1976\nHeight : 196.0, 195.0, 197.0, 188.0, 193.0, 200.0, 202.0, 194.0\nWeight : 89.0, 82.0, 85.0, 88.0, 90.0, 92.0, 83.0, 94.0\n*/\n \nCREATE TABLE protein (\n\tcommon_name TEXT, \n\tprotein_name TEXT, \n\tdivergence_from_human_lineage REAL, \n\taccession_number TEXT, \n\tsequence_length REAL, \n\tsequence_identity_to_human_protein TEXT, \n\t\"Institution_id\" TEXT, \n\tPRIMARY KEY (common_name), \n\tFOREIGN KEY(\"Institution_id\") REFERENCES \"Institution\" (\"Institution_id\")\n)\n/*\nColumns in protein and all categories for low cardinality columns :\ncommon_name : Tropical Clawed Frog, porkworm, body louse, southern house mosquito, purple sea urchin\nprotein_name : uncharacterized protein LOC578090, conserved hypothetical protein, Centromeric protein E, putative, surface antigen repeat family protein, uncharacterized protein C20orf117-like\ndivergence_from_human_lineage : 937.5, 742.9, 782.7, 371.2\naccession_number : XP_003380263.1, XP_002942331.1, XP_783370.2, XP_002429877.1, XP_001843754.1\nsequence_length : 2030.0, 1587.0, 2086.0, 1584.0, 1878.0\nsequence_identity_to_human_protein : 30%, 47%, 36%, 39%, 32%\nInstitution_id : 1, 5, 9, 3\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tcolor_code VARCHAR(15) NOT NULL, \n\tproduct_category_code VARCHAR(15) NOT NULL, \n\tproduct_name VARCHAR(80), \n\ttypical_buying_price VARCHAR(20), \n\ttypical_selling_price VARCHAR(20), \n\tproduct_description VARCHAR(255), \n\tother_product_details VARCHAR(255), \n\tPRIMARY KEY (product_id), \n\tFOREIGN KEY(color_code) REFERENCES \"Ref_Colors\" (color_code), \n\tFOREIGN KEY(product_category_code) REFERENCES \"Ref_Product_Categories\" (product_category_code)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nproduct_name : peper, cumin, chili\ntypical_buying_price : , 5.578, 503.8431967\ntypical_selling_price : , 149, 10377614.847385\nproduct_description : ut, et, vel\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\ncolor_code : 1, 2, 5, 7, 4, 9\nproduct_category_code : Spices, Seeds, Herbs\nother_product_details : None\n*/\n \nCREATE TABLE film_text (\n\tfilm_id SMALLINT NOT NULL, \n\ttitle VARCHAR(255) NOT NULL, \n\tdescription TEXT, \n\tPRIMARY KEY (film_id)\n)\n/*\nColumns in film_text and all categories for low cardinality columns :\nfilm_id : \ntitle : \ndescription : \n*/\n \nCREATE TABLE \"Student\" (\n\t\"StuID\" INTEGER, \n\t\"LName\" VARCHAR(12), \n\t\"Fname\" VARCHAR(12), \n\t\"Age\" INTEGER, \n\t\"Sex\" VARCHAR(1), \n\t\"Major\" INTEGER, \n\t\"Advisor\" INTEGER, \n\tcity_code VARCHAR(3), \n\tPRIMARY KEY (\"StuID\")\n)\n/*\nColumns in Student and 3 examples in each column for high cardinality columns :\nStuID : 1003, 1017, 1002\nLName : Lee, Han, Brody\nFname : Tracy, Michael, Shiela\nAdvisor : 7723, 7712, 7134\ncity_code : ATL, HOU, LON\n*/\n/*\nColumns in Student and all categories for low cardinality columns :\nAge : 26, 16, 20, 17, 21, 19, 18, 27, 22\nSex : F, M\nMajor : 520, 100, 50, 600, 540, 550\n*/\n \nCREATE TABLE pilot (\n\t\"Pilot_ID\" INTEGER, \n\t\"Pilot_name\" TEXT, \n\t\"Rank\" INTEGER, \n\t\"Age\" INTEGER, \n\t\"Nationality\" TEXT, \n\t\"Position\" TEXT, \n\t\"Join_Year\" INTEGER, \n\t\"Team\" TEXT, \n\tPRIMARY KEY (\"Pilot_ID\")\n)\n/*\nColumns in pilot and all categories for low cardinality columns :\nPilot_ID : 1, 2, 5, 4, 3\nPilot_name : Patrick O'Bryant, Charles Oakley, Dan O'Sullivan, Hakeem Olajuwon, Jermaine O'Neal\nRank : 34, 13, 45, 6\nAge : 37, 33, 40, 32, 22\nNationality : United States, Nigeria, United Kindom\nPosition : Center Team, Forward Team, Forward-Center Team\nJoin_Year : 2009, 2001, 2008, 1999, 2010\nTeam : Fordham, Eau Claire High School, Bradley, Virginia Union, Houston\n*/\n \nCREATE TABLE flight (\n\tid INTEGER, \n\t\"Vehicle_Flight_number\" TEXT, \n\t\"Date\" TEXT, \n\t\"Pilot\" TEXT, \n\t\"Velocity\" REAL, \n\t\"Altitude\" REAL, \n\tairport_id INTEGER, \n\tcompany_id INTEGER, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(company_id) REFERENCES operate_company (id), \n\tFOREIGN KEY(airport_id) REFERENCES airport (id)\n)\n/*\nColumns in flight and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nVehicle_Flight_number : M2-F1 #14, M2-F1 #61, M2-F1 #0\nDate : July 16, 1965, May 19, 1964, March 28, 1966\n*/\n/*\nColumns in flight and all categories for low cardinality columns :\nPilot : Thompson, Peterson\nVelocity : 240.0, 135.0\nAltitude : 3650.0, 0.0\nairport_id : 1, 2, 5, 8, 4, 6, 3, 9\ncompany_id : 1, 13, 11, 2, 5, 7, 4, 6, 3, 9\n*/\n \nCREATE TABLE \"Type_Of_Restaurant\" (\n\t\"ResID\" INTEGER, \n\t\"ResTypeID\" INTEGER, \n\tFOREIGN KEY(\"ResID\") REFERENCES \"Restaurant\" (\"ResID\"), \n\tFOREIGN KEY(\"ResTypeID\") REFERENCES \"Restaurant_Type\" (\"ResTypeID\")\n)\n/*\nColumns in Type_Of_Restaurant and all categories for low cardinality columns :\nResID : 1, 2\nResTypeID : 1, 2\n*/\n" }, { "role": "user", "content": "List the name, born state and age of the heads of departments ordered by age." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: head.\nFrom these tables, I'll be using the following columns: name, born_state, age.\nThe SQL query I'll be generating is:\nSELECT name , born_state , age FROM head ORDER BY age" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Age\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Graduation_College\" TEXT, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and all categories for low cardinality columns :\nPeople_ID : 1, 2, 5, 7, 4, 6, 3\nAge : 37, 25, 30, 34, 27, 31\nName : Tom Sheehey, Reggie Lewis, Brad Lohaus, David Butler, Tim Naegeli, Darryl Kennedy, Jerry Corcoran\nNationality : United States, United Kindom\nGraduation_College : Wisconsin–Stevens Point, California, Virginia, Iowa, Northeastern, Oklahoma\n*/\n \nCREATE TABLE \"People_Addresses\" (\n\tperson_address_id INTEGER NOT NULL, \n\tperson_id INTEGER NOT NULL, \n\taddress_id INTEGER NOT NULL, \n\tdate_from DATETIME, \n\tdate_to DATETIME, \n\tPRIMARY KEY (person_address_id), \n\tFOREIGN KEY(person_id) REFERENCES \"People\" (person_id), \n\tFOREIGN KEY(address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in People_Addresses and all categories for low cardinality columns :\nperson_address_id : 269, 276, 281, 257, 363, 396, 122, 340\nperson_id : 151, 141, 131, 171, 111, 161, 181, 121\naddress_id : 45, 9, 5, 88, 55, 92, 82, 99\ndate_from : 2013-12-26 16:57:01, 2008-07-31 02:17:25, 2012-09-26 13:21:00, 2008-05-26 20:43:41, 2014-05-10 00:32:31, 2010-11-26 05:21:12, 2017-05-01 17:32:26, 2015-05-24 16:14:12\ndate_to : 2018-03-21 09:46:30, 2018-03-08 06:16:47, 2018-02-23 22:44:18, 2018-03-11 20:26:41, 2018-03-09 02:11:12, 2018-03-09 08:45:06, 2018-03-03 16:06:17, 2018-03-12 21:10:02\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Country\" TEXT, \n\t\"Is_Male\" TEXT, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and 3 examples in each column for high cardinality columns :\nPeople_ID : 1, 11, 2\nName : Summer Duval, Annie Mediate, Juli Hanson\n*/\n/*\nColumns in people and all categories for low cardinality columns :\nCountry : Sweden, Canada, United States, Australia, Northern Ireland\nIs_Male : T, F\nAge : 26, 25, 36, 30, 34, 32, 27, 31\n*/\n \nCREATE TABLE farm_competition (\n\t\"Competition_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Theme\" TEXT, \n\t\"Host_city_ID\" INTEGER, \n\t\"Hosts\" TEXT, \n\tPRIMARY KEY (\"Competition_ID\"), \n\tFOREIGN KEY(\"Host_city_ID\") REFERENCES city (\"City_ID\")\n)\n/*\nColumns in farm_competition and all categories for low cardinality columns :\nCompetition_ID : 1, 2, 5, 4, 6, 3\nYear : 2004, 2013, 2005, 2006, 2003, 2002\nTheme : MTV Cube, Valentine's Day, Codehunters, Carnival M is back!, Aliens, MTV Asia Aid\nHost_city_ID : 1, 2, 5, 4, 3\nHosts : Mandy Moore and Ronan Keating, Alicia Keys, Shaggy and Coco Lee, Leehom Wang and Kelly Rowland, Miley Cyrus Jared Leto and Karen Mok, Vanness Wu and Michelle Branch\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE budget (\n\t\"School_id\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Budgeted\" INTEGER, \n\ttotal_budget_percent_budgeted REAL, \n\t\"Invested\" INTEGER, \n\ttotal_budget_percent_invested REAL, \n\t\"Budget_invested_percent\" TEXT, \n\tPRIMARY KEY (\"School_id\", \"Year\"), \n\tFOREIGN KEY(\"School_id\") REFERENCES \"School\" (\"School_id\")\n)\n/*\nColumns in budget and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 4, 3\nYear : 2004, 2001, 2005, 1999, 2000, 2006, 2002, 2003\nBudgeted : 113531, 3666, 61283, 119527, 6803, 4979, 74849\ntotal_budget_percent_budgeted : 1.3, 2.0, 2.4\nInvested : 8335, 5840, 95542, 146102, 2134, 85249, 140102\ntotal_budget_percent_invested : 2.7, 2.2, 2.0\nBudget_invested_percent : 71.3, 228.6, 146.9, 127.6, 228.8, 122.5, 42.9, 159.3\n*/\n \nCREATE TABLE \"Roles\" (\n\t\"Role_Code\" CHAR(15) NOT NULL, \n\t\"Role_Name\" VARCHAR(255), \n\t\"Role_Description\" VARCHAR(255), \n\tPRIMARY KEY (\"Role_Code\")\n)\n/*\nColumns in Roles and all categories for low cardinality columns :\nRole_Code : PR, HR, PT, MG, ED\nRole_Name : Proof Reader, Human Resource, Editor, Photo, Manager\nRole_Description : Itaque dolor ut nemo rerum vitae provident. Vel laborum ipsum velit sint. Et est omnis dignissimos., Ut sed quae eaque mollitia qui hic. Natus ea expedita et odio illum fugiat qui natus. Consequatur velit ut dolorem cum ullam esse deserunt dignissimos. Enim non non rem officiis quis., Aut modi nihil molestias temporibus sit rerum. Sit neque eaque odio omnis incidunt., Vero harum corrupti odit ipsa vero et odio. Iste et recusandae temporibus maxime. Magni aspernatur fugit quis explicabo totam esse corrupti., Et totam est quibusdam aspernatur ut. Vitae perferendis eligendi voluptatem molestiae rem ut enim. Ipsum expedita quae earum unde est. Repellendus ut ipsam nihil accusantium sit. Magni accusantium numquam quod et.\n*/\n \nCREATE TABLE \"Invoices\" (\n\tinvoice_number INTEGER, \n\tinvoice_date DATETIME, \n\tinvoice_details VARCHAR(255), \n\tPRIMARY KEY (invoice_number)\n)\n/*\nColumns in Invoices and 3 examples in each column for high cardinality columns :\ninvoice_number : 1, 13, 11\ninvoice_date : 1987-11-15 15:41:40, 1998-07-30 15:39:12, 1974-07-27 16:18:49\ninvoice_details : doloremque, eveniet, earum\n*/\n\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE club_rank (\n\t\"Rank\" REAL, \n\t\"Club_ID\" INTEGER, \n\t\"Gold\" REAL, \n\t\"Silver\" REAL, \n\t\"Bronze\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Rank\", \"Club_ID\"), \n\tFOREIGN KEY(\"Club_ID\") REFERENCES club (\"Club_ID\")\n)\n/*\nColumns in club_rank and all categories for low cardinality columns :\nRank : 3.0, 1.0, 2.0, 6.0, 4.0, 5.0\nClub_ID : 1, 2, 5, 4, 6, 3\nGold : 8.0, 3.0, 11.0, 7.0, 2.0, 4.0\nSilver : 3.0, 11.0, 1.0, 7.0, 2.0, 4.0\nBronze : 6.0, 9.0, 0.0, 2.0\nTotal : 3.0, 12.0, 13.0, 6.0, 21.0, 31.0\n*/\n \nCREATE TABLE \"Staff\" (\n\tstaff_id INTEGER, \n\tstaff_gender VARCHAR(1), \n\tstaff_name VARCHAR(80), \n\tPRIMARY KEY (staff_id)\n)\n/*\nColumns in Staff and 3 examples in each column for high cardinality columns :\nstaff_id : 1, 13, 11\nstaff_name : Yolanda, Tom, Melody\n*/\n/*\nColumns in Staff and all categories for low cardinality columns :\nstaff_gender : 1, 0\n*/\n \nCREATE TABLE \"Problem_Log\" (\n\tproblem_log_id INTEGER, \n\tassigned_to_staff_id INTEGER NOT NULL, \n\tproblem_id INTEGER NOT NULL, \n\tproblem_category_code VARCHAR(20) NOT NULL, \n\tproblem_status_code VARCHAR(20) NOT NULL, \n\tlog_entry_date DATETIME, \n\tlog_entry_description VARCHAR(255), \n\tlog_entry_fix VARCHAR(255), \n\tother_log_details VARCHAR(255), \n\tPRIMARY KEY (problem_log_id), \n\tFOREIGN KEY(problem_status_code) REFERENCES \"Problem_Status_Codes\" (problem_status_code), \n\tFOREIGN KEY(problem_id) REFERENCES \"Problems\" (problem_id), \n\tFOREIGN KEY(assigned_to_staff_id) REFERENCES \"Staff\" (staff_id), \n\tFOREIGN KEY(problem_category_code) REFERENCES \"Problem_Category_Codes\" (problem_category_code)\n)\n/*\nColumns in Problem_Log and 3 examples in each column for high cardinality columns :\nproblem_log_id : 1, 13, 11\nlog_entry_date : 1997-08-31 08:19:12, 1974-09-13 00:37:26, 2011-11-12 23:30:53\nlog_entry_description : t, d, b\nlog_entry_fix : t, i, s\nother_log_details : d, f, b\n*/\n/*\nColumns in Problem_Log and all categories for low cardinality columns :\nassigned_to_staff_id : 1, 13, 11, 2, 5, 8, 4, 6, 12, 10\nproblem_id : 1, 13, 11, 10, 7, 8, 4, 12, 15\nproblem_category_code : Datatabase, Middleware, GUI\nproblem_status_code : Solved, Reported\n*/\n \nCREATE TABLE \"Invoices\" (\n\tinvoice_number INTEGER, \n\torder_id INTEGER NOT NULL, \n\tinvoice_date DATETIME, \n\tPRIMARY KEY (invoice_number), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Invoices and 3 examples in each column for high cardinality columns :\ninvoice_number : 1, 13, 11\ninvoice_date : 2018-03-16 21:57:43, 2018-03-20 00:21:41, 2018-03-05 08:47:33\n*/\n/*\nColumns in Invoices and all categories for low cardinality columns :\norder_id : 13, 11, 5, 8, 4, 12, 3, 14, 10, 9\n*/\n \nCREATE TABLE \"Customer_Events\" (\n\t\"Customer_Event_ID\" INTEGER NOT NULL, \n\tcustomer_id INTEGER, \n\tdate_moved_in DATETIME, \n\tproperty_id INTEGER, \n\tresident_id INTEGER, \n\tthing_id INTEGER NOT NULL, \n\tPRIMARY KEY (\"Customer_Event_ID\"), \n\tFOREIGN KEY(thing_id) REFERENCES \"Things\" (thing_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(resident_id, property_id, date_moved_in) REFERENCES \"Residents\" (resident_id, property_id, date_moved_in)\n)\n/*\nColumns in Customer_Events and 3 examples in each column for high cardinality columns :\nCustomer_Event_ID : 428, 216, 226\nresident_id : 87, 38, 37\n*/\n/*\nColumns in Customer_Events and all categories for low cardinality columns :\ncustomer_id : 79, 91, 16, 5, 4, 63, 19, 31\ndate_moved_in : 2016-09-27 12:00:00, 2015-03-27 12:00:00\nproperty_id : 954, 120, 108, 605, 629, 748, 669, 445, 879, 107\nthing_id : 1, 46, 10, 80, 2, 92, 14, 85, 68\n*/\n \nCREATE TABLE \"Type_Of_Restaurant\" (\n\t\"ResID\" INTEGER, \n\t\"ResTypeID\" INTEGER, \n\tFOREIGN KEY(\"ResID\") REFERENCES \"Restaurant\" (\"ResID\"), \n\tFOREIGN KEY(\"ResTypeID\") REFERENCES \"Restaurant_Type\" (\"ResTypeID\")\n)\n/*\nColumns in Type_Of_Restaurant and all categories for low cardinality columns :\nResID : 1, 2\nResTypeID : 1, 2\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/*\nColumns in discipline_enrollments and 3 examples in each column for high cardinality columns :\nCampus : 1, 13, 11\nDiscipline : 19, 17, 21\nUndergraduate : 986, 65, 815\nGraduate : 56, 377, 187\n*/\n/*\nColumns in discipline_enrollments and all categories for low cardinality columns :\nYear : 2004\n*/\n \nCREATE TABLE country (\n\t\"Country_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Population\" INTEGER, \n\t\"Area\" INTEGER, \n\t\"Languages\" TEXT, \n\tPRIMARY KEY (\"Country_ID\")\n)\n/*\nColumns in country and all categories for low cardinality columns :\nCountry_ID : 1, 2, 3\nName : Austria, Sweden, Finland\nPopulation : 8206524, 9047752, 5261008\nArea : 83871, 338145, 449964\nLanguages : Swedish, Finnish Swedish, German\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n" }, { "role": "user", "content": "List the creation year, name and budget of each department." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department.\nFrom these tables, I'll be using the following columns: creation, name, budget_in_billions.\nThe SQL query I'll be generating is:\nSELECT creation , name , budget_in_billions FROM department" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \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)\n/*\nColumns in list and 3 examples in each column for high cardinality columns :\nLastName : HOUTCHENS, GELL, FLACHS\nFirstName : RAY, EMILE, PATRINA\nClassroom : 109, 110, 106\n*/\n/*\nColumns in list and all categories for low cardinality columns :\nGrade : 1, 2, 5, 4, 6, 3, 0\n*/\n \nCREATE TABLE \"School\" (\n\t\"School_id\" TEXT, \n\t\"School_name\" TEXT, \n\t\"Location\" TEXT, \n\t\"Mascot\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"IHSAA_Class\" TEXT, \n\t\"IHSAA_Football_Class\" TEXT, \n\t\"County\" TEXT, \n\tPRIMARY KEY (\"School_id\")\n)\n/*\nColumns in School and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 7, 8, 4, 6, 3\nSchool_name : New Prairie 1, Triton, LaVille, Glenn, Culver Community, Jimtown, Knox Community, Bremen\nLocation : Bourbon, Walkerton, Lakeville, Knox, Culver, New Carlisle, Elkhart, Bremen\nMascot : Lancers, Cougars, Cavaliers, Trojans, Redskins, Falcons, Lions, Jimmies\nEnrollment : 601, 605, 287, 495, 620, 379, 852, 316\nIHSAA_Class : AA, A, AAA\nIHSAA_Football_Class : AA, A, AAA, AAAA\nCounty : 20 Elkhart, 50 Marshall, 75 Starke, 71 St. Joseph, 46 LaPorte 71 St. Joseph\n*/\n \nCREATE TABLE chip_model (\n\t\"Model_name\" TEXT, \n\t\"Launch_year\" REAL, \n\t\"RAM_MiB\" REAL, \n\t\"ROM_MiB\" REAL, \n\t\"Slots\" TEXT, \n\t\"WiFi\" TEXT, \n\t\"Bluetooth\" TEXT, \n\tPRIMARY KEY (\"Model_name\")\n)\n/*\nColumns in chip_model and 3 examples in each column for high cardinality columns :\nModel_name : X30 mid-range, X50 Advanced, X51 mid-range\n*/\n/*\nColumns in chip_model and all categories for low cardinality columns :\nLaunch_year : 2002.0, 2005.0, 2004.0, 2003.0\nRAM_MiB : 32.0, 64.0\nROM_MiB : 48.0, 256.0, 128.0, 32.0, 64.0\nSlots : 1CFII,1SD, 1SD\nWiFi : 802.11b, No\nBluetooth : 1.2, Yes, No, 1.1\n*/\n \nCREATE TABLE employment (\n\t\"Company_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Year_working\" INTEGER, \n\tPRIMARY KEY (\"Company_ID\", \"People_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\"), \n\tFOREIGN KEY(\"Company_ID\") REFERENCES company (\"Company_ID\")\n)\n/*\nColumns in employment and all categories for low cardinality columns :\nCompany_ID : 13, 11, 7, 17, 15\nPeople_ID : 1, 2, 7, 4, 3\nYear_working : 1, 2, 4, 3\n*/\n \nCREATE TABLE \"Papers\" (\n\t\"paperID\" INTEGER, \n\ttitle TEXT, \n\tPRIMARY KEY (\"paperID\")\n)\n/*\nColumns in Papers and all categories for low cardinality columns :\npaperID : 201, 204, 205, 200, 206, 203, 202\ntitle : Nameless, Painless, Binders Unbound, Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory, An Equivalence-Preserving CPS Translation via Multi-Language Semantics, Making Standard ML a Practical Database Programming Language, Functional Pearl: Modular Rollback through Control Logging, Just do it: Simple Monadic Equational Reasoning\n*/\n \nCREATE TABLE \"Attribute_Definitions\" (\n\tattribute_id INTEGER, \n\tattribute_name VARCHAR(30), \n\tattribute_data_type VARCHAR(10), \n\tPRIMARY KEY (attribute_id)\n)\n/*\nColumns in Attribute_Definitions and all categories for low cardinality columns :\nattribute_id : 1, 2, 4, 3\nattribute_name : Yellow, Sweet, Green, Black\nattribute_data_type : Bool\n*/\n \nCREATE TABLE player (\n\t\"Player_ID\" INTEGER, \n\t\"Player\" TEXT, \n\t\"Years_Played\" TEXT, \n\t\"Total_WL\" TEXT, \n\t\"Singles_WL\" TEXT, \n\t\"Doubles_WL\" TEXT, \n\t\"Team\" INTEGER, \n\tPRIMARY KEY (\"Player_ID\"), \n\tFOREIGN KEY(\"Team\") REFERENCES team (\"Team_id\")\n)\n/*\nColumns in player and all categories for low cardinality columns :\nPlayer_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nPlayer : Seol Jae-Min (none), An Jae-Sung, Kim Young-Jun (474), Cho Soong-Jae (630), Jeong Suk-Young (793), Lim Yong-Kyu (288), Im Kyu-tae (492), Bae Nam-Ju, Kim Hyun-Joon (908), Chung Hong (717)\nYears_Played : 8 (2003–2005, 2007–2011), 2 (1988, 1990), 3 (2005, 2007–2008), 1 (2011), 2 (2010–2011), 2 (2010-2011), 3 (2009–2011), 4 (2003–2004, 2010–2011)\nTotal_WL : 1–3, 2–2, 0–0, 6–9, 2–0, 3–4, 4–3, 6–4, 7–6, 1–2\nSingles_WL : 6–3, 5–6, 0–0, 1–0, 2–1, 0–2, 5–7, 3–2, 1–2\nDoubles_WL : 1–3, 2–2, 0–0, 1–0, 1–1, 2–0, 0–1, 1–2\nTeam : 1, 2, 8, 4, 6\n*/\n \nCREATE TABLE \"Claims_Processing_Stages\" (\n\t\"Claim_Stage_ID\" INTEGER NOT NULL, \n\t\"Next_Claim_Stage_ID\" INTEGER, \n\t\"Claim_Status_Name\" VARCHAR(255) NOT NULL, \n\t\"Claim_Status_Description\" VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (\"Claim_Stage_ID\")\n)\n/*\nColumns in Claims_Processing_Stages and all categories for low cardinality columns :\nClaim_Stage_ID : 1, 3\nNext_Claim_Stage_ID : 1\nClaim_Status_Name : Open, Close\nClaim_Status_Description : Open a new claim, Close a claim\n*/\n \nCREATE TABLE region (\n\t\"Region_id\" INTEGER, \n\t\"Region_code\" TEXT, \n\t\"Region_name\" TEXT, \n\tPRIMARY KEY (\"Region_id\")\n)\n/*\nColumns in region and 3 examples in each column for high cardinality columns :\nRegion_id : 1, 13, 11\nRegion_code : AG, AI, AQ\nRegion_name : Angola, Cyprus, Denmark\n*/\n\n \nCREATE TABLE school (\n\t\"School_ID\" INTEGER, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Enrollment\" REAL, \n\t\"Founded\" REAL, \n\t\"Denomination\" TEXT, \n\t\"Boys_or_Girls\" TEXT, \n\t\"Day_or_Boarding\" TEXT, \n\t\"Year_Entered_Competition\" REAL, \n\t\"School_Colors\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 4, 6, 3\nSchool : St Aloysius' College, Cranbrook School, Waverley College, Knox Grammar School, Barker College, Trinity Grammar School\nLocation : Hornsby, Summer Hill, Waverley, Bellevue Hill, Milsons Point, Wahroonga\nEnrollment : 1000.0, 1850.0, 2200.0, 1200.0, 2300.0, 1430.0\nFounded : 1918.0, 1924.0, 1913.0, 1879.0, 1903.0, 1890.0\nDenomination : Catholic, Uniting Church, Anglican\nBoys_or_Girls : Boys only to Yr 9 Co-ed Year 10 to 12, Boys\nDay_or_Boarding : Day, Day & Boarding\nYear_Entered_Competition : 1944.0, 1929.0\nSchool_Colors : Royal Blue and Gold, Black & Blue, Red, White & Blue, Red & Blue, Green and White\n*/\n \nCREATE TABLE broadcast_share (\n\t\"Channel_ID\" INTEGER, \n\t\"Program_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Share_in_percent\" REAL, \n\tPRIMARY KEY (\"Channel_ID\", \"Program_ID\"), \n\tFOREIGN KEY(\"Program_ID\") REFERENCES program (\"Program_ID\"), \n\tFOREIGN KEY(\"Channel_ID\") REFERENCES channel (\"Channel_ID\")\n)\n/*\nColumns in broadcast_share and all categories for low cardinality columns :\nChannel_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nProgram_ID : 1, 2, 4, 3\nDate : 03,May, 04,April, 02,May, 10,Jun, 11,May, 01,May, 13,May\nShare_in_percent : 2.1, 1.9, 3.0, 1.1, 3.2, 4.2, 1.8, 3.1, 2.8\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Home Town\" TEXT, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and 3 examples in each column for high cardinality columns :\nPeople_ID : 1, 11, 2\nName : Gary Goodner, Mike Murphy, Tyrone Brayan\n*/\n/*\nColumns in people and all categories for low cardinality columns :\nHeight : 6.6, 6.5, 6.7, 6.1, 6.4, 6.3, 6.8\nWeight : 215.0, 185.0, 170.0, 200.0, 220.0, 205.0, 160.0, 190.0\nHome Town : Beaver Dam, KY, San Antonio, TX, Placentia, CA, Indianapolis, IN, Westport, CT, Denton, TX, Austin, TX, Baton Rouge, LA, Altoona, PA, Los Angeles, CA\n*/\n \nCREATE TABLE \"Individuals\" (\n\tindividual_id INTEGER, \n\tindividual_first_name VARCHAR(80), \n\tindividual_middle_name VARCHAR(80), \n\tinidividual_phone VARCHAR(80), \n\tindividual_email VARCHAR(80), \n\tindividual_address VARCHAR(255), \n\tindividual_last_name VARCHAR(80), \n\tPRIMARY KEY (individual_id)\n)\n/*\nColumns in Individuals and 3 examples in each column for high cardinality columns :\nindividual_id : 1, 13, 11\nindividual_first_name : Daniella, Guy, Allene\nindividual_middle_name : Hosea, Tommie, Colleen\ninidividual_phone : (121)788-2928, 1-727-057-0382x999, 1-818-062-2837\nindividual_email : zlehner@example.net, hickle.ewell@example.com, mbahringer@example.com\nindividual_address : 69578 Baylee Prairie, 104 Bernier Loop, 640 Johns Branch\nindividual_last_name : Rau, Hand, Maggio\n*/\n\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE cinema (\n\t\"Cinema_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Openning_year\" INTEGER, \n\t\"Capacity\" INTEGER, \n\t\"Location\" TEXT, \n\tPRIMARY KEY (\"Cinema_ID\")\n)\n/*\nColumns in cinema and all categories for low cardinality columns :\nCinema_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Glenmore, Oriel, Codling, Dublin Array, Glenough, Grouse Lodge, Carrowleagh, Gortahile, Mount Callan, Moneypoint\nOpenning_year : 2009, 2013, 2015, 2012, 2011, 2010\nCapacity : 330, 305, 368, 364, 325, 203, 908, 208, 1100, 225\nLocation : County Cork, County Louth, County Laois, County Tipperary, County Clare, County Dublin, County Wicklow\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Timed_Locations_of_Things\" (\n\tthing_id INTEGER NOT NULL, \n\t\"Date_and_Time\" DATETIME NOT NULL, \n\t\"Location_Code\" CHAR(15) NOT NULL, \n\tPRIMARY KEY (thing_id, \"Date_and_Time\", \"Location_Code\"), \n\tFOREIGN KEY(thing_id) REFERENCES \"Things\" (thing_id)\n)\n/*\nColumns in Timed_Locations_of_Things and 3 examples in each column for high cardinality columns :\nDate_and_Time : 2017-03-19 13:57:49, 2017-08-31 13:54:13, 2016-12-29 00:39:19\nLocation_Code : 2677 Runolfsson, 288 Lang Ferry, 94425 Nellie Kn\n*/\n/*\nColumns in Timed_Locations_of_Things and all categories for low cardinality columns :\nthing_id : 26, 45, 2, 68, 58, 92, 14, 85, 10\n*/\n \nCREATE TABLE \"Projects\" (\n\t\"Code\" CHAR(4), \n\t\"Name\" CHAR(50) NOT NULL, \n\t\"Hours\" INTEGER, \n\tPRIMARY KEY (\"Code\")\n)\n/*\nColumns in Projects and 3 examples in each column for high cardinality columns :\nCode : Bte2, AeH6, Ast3\nName : Aerodynamics of Air Hockey, Winds: Studying Bernoullis Principle, Aerodynamics and Gas Mileage\nHours : 321, 189, 89\n*/\n\n" }, { "role": "user", "content": "What are the maximum and minimum budget of the departments?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department.\nFrom these tables, I'll be using the following columns: budget_in_billions.\nThe SQL query I'll be generating is:\nSELECT max(budget_in_billions) , min(budget_in_billions) FROM department" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE injury_accident (\n\tgame_id INTEGER, \n\tid INTEGER, \n\t\"Player\" TEXT, \n\t\"Injury\" TEXT, \n\t\"Number_of_matches\" TEXT, \n\t\"Source\" TEXT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(game_id) REFERENCES game (id)\n)\n/*\nColumns in injury_accident and 3 examples in each column for high cardinality columns :\ngame_id : 1, 11, 2\nid : 1, 13, 11\nPlayer : Dejan Stanković, Thiago Motta (2), Iván Córdoba\nInjury : Sustained a biceps femoris strain in his left leg, First-degree strain left hamstring muscles, Sustained posterior thigh strains in his left leg\n*/\n/*\nColumns in injury_accident and all categories for low cardinality columns :\nNumber_of_matches : 1, 4 (6), 2, 7 (17), 1 (2), 4, 12, 3, 10\nSource : inter.it\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE publication (\n\t\"Publication_ID\" INTEGER, \n\t\"Book_ID\" INTEGER, \n\t\"Publisher\" TEXT, \n\t\"Publication_Date\" TEXT, \n\t\"Price\" REAL, \n\tPRIMARY KEY (\"Publication_ID\"), \n\tFOREIGN KEY(\"Book_ID\") REFERENCES book (\"Book_ID\")\n)\n/*\nColumns in publication and all categories for low cardinality columns :\nPublication_ID : 1, 2, 5, 7, 4, 6, 3\nBook_ID : 1, 5, 7, 4, 3, 10, 9\nPublisher : Thomson Reuters, Springer Nature, Bertelsmann, Pearson, Wiley\nPublication_Date : March 2008, October 2005, August 2008, June 2006, April 2007, March 2007\nPrice : 6000000.0, 3000000.0, 4100000.0, 2000000.0, 15000000.0\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE building (\n\tbuilding_id TEXT, \n\t\"Name\" TEXT, \n\t\"Street_address\" TEXT, \n\t\"Years_as_tallest\" TEXT, \n\t\"Height_feet\" INTEGER, \n\t\"Floors\" INTEGER, \n\tPRIMARY KEY (building_id)\n)\n/*\nColumns in building and all categories for low cardinality columns :\nbuilding_id : 1, 2, 5, 7, 4, 6, 3, 0\nName : Bank of America Tower, Franklin Exchange Building, One Tampa City Center, 100 North Tampa, Park Tower, Citizens Bank Building, Floridan Hotel, Tampa City Hall\nStreet_address : 905 Franklin Street, 701 North Franklin Street, 655 North Franklin Street, 315 John F. Kennedy Boulevard, 101 East Kennedy Boulevard, 100 North Tampa Street, 400 North Tampa Street, 201 North Franklin Street\nYears_as_tallest : 1966–1972, 1981–1986, 1913–1915, 1992–present, 1986–1992, 1915–1926, 1926–1966, 1972–1981\nHeight_feet : 204, 537, 458, 577, 145, 579, 160, 280\nFloors : 42, 36, 17, 12, 39, 10, 22\n*/\n \nCREATE TABLE browser (\n\tid INTEGER, \n\tname TEXT, \n\tmarket_share REAL, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in browser and all categories for low cardinality columns :\nid : 1, 2, 4, 3\nname : Opera, Internet Explorer, Safari, Firefox\nmarket_share : 18.11, 8.54, 28.96, 1.2\n*/\n \nCREATE TABLE submission (\n\t\"Submission_ID\" INTEGER, \n\t\"Scores\" REAL, \n\t\"Author\" TEXT, \n\t\"College\" TEXT, \n\tPRIMARY KEY (\"Submission_ID\")\n)\n/*\nColumns in submission and all categories for low cardinality columns :\nSubmission_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nScores : 89.0, 79.0, 82.0, 83.0, 92.0, 93.0, 72.0, 78.0\nAuthor : Rick Engles, Andy Bolton, Jeff Lloyd, Don Bitterlich, Steve Raible, Steve Niehaus, Sherman Smith, Randy Johnson, Sammy Green, Steve Myer\nCollege : Fisk, Georgia Tech, Tulsa, Georgia, Miami (OH), West Texas State, Temple, Notre Dame, Florida, New Mexico\n*/\n \nCREATE TABLE country (\n\tcountry_id INTEGER NOT NULL, \n\tcountry VARCHAR(50) NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (country_id)\n)\n/*\nColumns in country and 3 examples in each column for high cardinality columns :\ncountry_id : 87, 56, 65\ncountry : Belarus, Afghanistan, Runion\n*/\n/*\nColumns in country and all categories for low cardinality columns :\nlast_update : 2006-02-15 04:44:00\n*/\n \nCREATE TABLE \"Catalog_Contents\" (\n\tcatalog_entry_id INTEGER, \n\tcatalog_level_number INTEGER NOT NULL, \n\tparent_entry_id INTEGER, \n\tprevious_entry_id INTEGER, \n\tnext_entry_id INTEGER, \n\tcatalog_entry_name VARCHAR(80), \n\tproduct_stock_number VARCHAR(50), \n\tprice_in_dollars DOUBLE, \n\tprice_in_euros DOUBLE, \n\tprice_in_pounds DOUBLE, \n\tcapacity VARCHAR(20), \n\tlength VARCHAR(20), \n\theight VARCHAR(20), \n\twidth VARCHAR(20), \n\tPRIMARY KEY (catalog_entry_id), \n\tFOREIGN KEY(catalog_level_number) REFERENCES \"Catalog_Structure\" (catalog_level_number)\n)\n/*\nColumns in Catalog_Contents and 3 examples in each column for high cardinality columns :\ncatalog_entry_id : 1, 13, 11\ncatalog_entry_name : Cream Soda, Diet Pepsi, Ramune\nproduct_stock_number : 15 mr, 42 cp, 26 op\nprice_in_dollars : 475.79, 687.59, 616.22\nprice_in_euros : 385.85, 159.84, 537.66\nprice_in_pounds : 440.52, 405.75, 331.43\n*/\n/*\nColumns in Catalog_Contents and all categories for low cardinality columns :\ncatalog_level_number : 1, 8, 9\nparent_entry_id : 5, 7, 4, 6, 3\nprevious_entry_id : 5, 7, 8, 4, 6, 3, 9\nnext_entry_id : 1, 7, 8, 6, 3, 9\ncapacity : 1, 5, 7, 8, 4, 6, 9\nlength : 5, 7, 8, 4, 6, 3, 9\nheight : 1, 2, 5, 7, 8, 4, 6, 3, 9\nwidth : 1, 5, 7, 8, 6, 3, 9\n*/\n \nCREATE TABLE flight (\n\tid INTEGER, \n\t\"Vehicle_Flight_number\" TEXT, \n\t\"Date\" TEXT, \n\t\"Pilot\" TEXT, \n\t\"Velocity\" REAL, \n\t\"Altitude\" REAL, \n\tairport_id INTEGER, \n\tcompany_id INTEGER, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(company_id) REFERENCES operate_company (id), \n\tFOREIGN KEY(airport_id) REFERENCES airport (id)\n)\n/*\nColumns in flight and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nVehicle_Flight_number : M2-F1 #14, M2-F1 #61, M2-F1 #0\nDate : July 16, 1965, May 19, 1964, March 28, 1966\n*/\n/*\nColumns in flight and all categories for low cardinality columns :\nPilot : Thompson, Peterson\nVelocity : 240.0, 135.0\nAltitude : 3650.0, 0.0\nairport_id : 1, 2, 5, 8, 4, 6, 3, 9\ncompany_id : 1, 13, 11, 2, 5, 7, 4, 6, 3, 9\n*/\n \nCREATE TABLE market (\n\t\"Market_ID\" INTEGER, \n\t\"Country\" TEXT, \n\t\"Number_cities\" INTEGER, \n\tPRIMARY KEY (\"Market_ID\")\n)\n/*\nColumns in market and all categories for low cardinality columns :\nMarket_ID : 1, 2, 5, 4, 6, 3\nCountry : Japan, China, France, Russia, USA, Poland\nNumber_cities : 700, 453, 231, 212, 209, 540\n*/\n \nCREATE TABLE \"Bookings\" (\n\tbooking_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tbooking_status_code VARCHAR(10) NOT NULL, \n\treturned_damaged_yn VARCHAR(40), \n\tbooking_start_date DATETIME, \n\tbooking_end_date DATETIME, \n\tcount_hired VARCHAR(40), \n\tamount_payable DECIMAL(19, 4), \n\tamount_of_discount DECIMAL(19, 4), \n\tamount_outstanding DECIMAL(19, 4), \n\tamount_of_refund DECIMAL(19, 4), \n\tPRIMARY KEY (booking_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Bookings and 3 examples in each column for high cardinality columns :\nbooking_id : 1, 13, 11\nbooking_start_date : 2016-04-25 11:04:18, 2016-11-06 20:54:26, 2017-04-28 08:35:56\nbooking_end_date : 2018-03-04 21:42:45, 2018-02-19 21:53:31, 2017-10-02 07:28:09\ncount_hired : 843, 298, 236\namount_payable : 214.3900, 306.2600, 386.9200\namount_of_discount : 48.7300, 61.5500, 45.0600\namount_outstanding : 26.0400, 66.0100, 93.8800\namount_of_refund : 135.9400, 126.1000, 124.9500\n*/\n/*\nColumns in Bookings and all categories for low cardinality columns :\ncustomer_id : 11, 10, 7, 8, 3, 15, 9\nbooking_status_code : Provisional, Confirmed\nreturned_damaged_yn : 1, 0\n*/\n \nCREATE TABLE \"Voting_record\" (\n\t\"StuID\" INTEGER, \n\t\"Registration_Date\" VARCHAR(12), \n\t\"Election_Cycle\" VARCHAR(12), \n\t\"President_Vote\" INTEGER, \n\t\"Vice_President_Vote\" INTEGER, \n\t\"Secretary_Vote\" INTEGER, \n\t\"Treasurer_Vote\" INTEGER, \n\t\"Class_President_Vote\" INTEGER, \n\t\"Class_Senator_Vote\" INTEGER, \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"President_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Vice_President_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Secretary_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Treasurer_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Class_President_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Class_Senator_Vote\") REFERENCES \"Student\" (\"StuID\")\n)\n/*\nColumns in Voting_record and all categories for low cardinality columns :\nStuID : 1003, 1002, 1005, 1001, 1004\nRegistration_Date : 08/30/2014, 08/30/2015, 08/30/2013, 08/30/2012\nElection_Cycle : Fall, Spring\nPresident_Vote : 1014, 1024, 1004\nVice_President_Vote : 1007, 1017\nSecretary_Vote : 1030, 1010, 1020\nTreasurer_Vote : 1035, 1025\nClass_President_Vote : 1011, 1001, 1031, 1021\nClass_Senator_Vote : 1028, 1018\n*/\n \nCREATE TABLE enzyme (\n\tid INTEGER, \n\tname TEXT, \n\t\"Location\" TEXT, \n\t\"Product\" TEXT, \n\t\"Chromosome\" TEXT, \n\t\"OMIM\" INTEGER, \n\t\"Porphyria\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in enzyme and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 3\nname : PBG deaminase, Coproporphyrinogen III oxidase, ALA dehydratase, Uroporphyrinogen III decarboxylase, Ferrochelatase, Uroporphyrinogen III synthase, Protoporphyrinogen oxidase, ALA synthase\nLocation : Mitochondrion, Cytosol\nProduct : Coproporphyrinogen III, δ-Aminolevulinic acid, Hydroxymethyl bilane, Protoporphyrin IX, Heme, Uroporphyrinogen III, Protoporphyrinogen IX, Porphobilinogen\nChromosome : 9q34, 1q22, 18q21.3, 3p21.1, 3q12, 10q25.2-q26.3, 11q23.3, 1p34\nOMIM : 606938, 125270, 600923, 125290, 176000, 177000, 121300, 176100\nPorphyria : porphyria cutanea tarda, congenital erythropoietic porphyria, acute intermittent porphyria, erythropoietic protoporphyria, coproporphyria, none, ALA-Dehydratase deficiency, variegate porphyria\n*/\n \nCREATE TABLE journal_committee (\n\t\"Editor_ID\" INTEGER, \n\t\"Journal_ID\" INTEGER, \n\t\"Work_Type\" TEXT, \n\tPRIMARY KEY (\"Editor_ID\", \"Journal_ID\"), \n\tFOREIGN KEY(\"Journal_ID\") REFERENCES journal (\"Journal_ID\"), \n\tFOREIGN KEY(\"Editor_ID\") REFERENCES editor (\"Editor_ID\")\n)\n/*\nColumns in journal_committee and all categories for low cardinality columns :\nEditor_ID : 1, 8, 4, 6, 3, 9\nJournal_ID : 13, 11, 2, 17, 4, 6, 12\nWork_Type : Title, Article, Photo\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n" }, { "role": "user", "content": "What is the average number of employees of the departments whose rank is between 10 and 15?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department.\nFrom these tables, I'll be using the following columns: num_employees, ranking.\nThe SQL query I'll be generating is:\nSELECT avg(num_employees) FROM department WHERE ranking BETWEEN 10 AND 15" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Age\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Graduation_College\" TEXT, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and all categories for low cardinality columns :\nPeople_ID : 1, 2, 5, 7, 4, 6, 3\nAge : 37, 25, 30, 34, 27, 31\nName : Tom Sheehey, Reggie Lewis, Brad Lohaus, David Butler, Tim Naegeli, Darryl Kennedy, Jerry Corcoran\nNationality : United States, United Kindom\nGraduation_College : Wisconsin–Stevens Point, California, Virginia, Iowa, Northeastern, Oklahoma\n*/\n \nCREATE TABLE \"Invoice_Items\" (\n\t\"Invoice_Item_ID\" INTEGER NOT NULL, \n\t\"Invoice_ID\" INTEGER NOT NULL, \n\t\"Order_ID\" INTEGER NOT NULL, \n\t\"Order_Item_ID\" INTEGER NOT NULL, \n\t\"Product_ID\" INTEGER NOT NULL, \n\t\"Order_Quantity\" INTEGER, \n\t\"Other_Item_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Invoice_Item_ID\"), \n\tFOREIGN KEY(\"Order_Item_ID\") REFERENCES \"Order_Items\" (\"Order_Item_ID\"), \n\tFOREIGN KEY(\"Invoice_ID\") REFERENCES \"Invoices\" (\"Invoice_ID\"), \n\tFOREIGN KEY(\"Order_ID\", \"Product_ID\") REFERENCES \"Bookings_Services\" (\"Order_ID\", \"Product_ID\")\n)\n/*\nColumns in Invoice_Items and all categories for low cardinality columns :\nInvoice_Item_ID : 1, 2\nInvoice_ID : 128, 162\nOrder_ID : 1, 4\nOrder_Item_ID : 5, 6\nProduct_ID : 396, 191\nOrder_Quantity : 2, 6\nOther_Item_Details : None, Good quality\n*/\n \nCREATE TABLE competition_result (\n\t\"Competition_ID\" INTEGER, \n\t\"Club_ID_1\" INTEGER, \n\t\"Club_ID_2\" INTEGER, \n\t\"Score\" TEXT, \n\tPRIMARY KEY (\"Competition_ID\", \"Club_ID_1\", \"Club_ID_2\"), \n\tFOREIGN KEY(\"Competition_ID\") REFERENCES competition (\"Competition_ID\"), \n\tFOREIGN KEY(\"Club_ID_2\") REFERENCES club (\"Club_ID\"), \n\tFOREIGN KEY(\"Club_ID_1\") REFERENCES club (\"Club_ID\")\n)\n/*\nColumns in competition_result and all categories for low cardinality columns :\nCompetition_ID : 1, 2, 5, 4, 6, 10\nClub_ID_1 : 1, 4, 3\nClub_ID_2 : 2, 4, 6\nScore : 11:10, 10:11, 10:3, 13:10, 12:9, 25:2\n*/\n \nCREATE TABLE \"Subjects\" (\n\tsubject_id INTEGER, \n\tsubject_name VARCHAR(120), \n\tPRIMARY KEY (subject_id)\n)\n/*\nColumns in Subjects and all categories for low cardinality columns :\nsubject_id : 1, 2, 3\nsubject_name : Computer Science, Language, Arts\n*/\n \nCREATE TABLE camera_lens (\n\tid INTEGER, \n\tbrand TEXT, \n\tname TEXT, \n\tfocal_length_mm REAL, \n\tmax_aperture REAL, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in camera_lens and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\nname : Panasonic Leica DG Summilux 25mm f /1.4 Asph., Sigma 19mm f2.8 EX DN, Sigma 30mm f2.8 DN\n*/\n/*\nColumns in camera_lens and all categories for low cardinality columns :\nbrand : Sigma, Olympus, Panasonic, Schneider Kreuznach\nfocal_length_mm : 45.0, 30.0, 15.0, 25.0, 150.0, 19.0, 14.0, 42.5, 75.0\nmax_aperture : 1.2, 8.0, 1.4, 2.0, 1.8, 2.8\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Addresses\" (\n\taddress_id INTEGER, \n\tline_1_number_building VARCHAR(80), \n\tcity VARCHAR(50), \n\tzip_postcode VARCHAR(20), \n\tstate_province_county VARCHAR(50), \n\tcountry VARCHAR(50), \n\tPRIMARY KEY (address_id)\n)\n/*\nColumns in Addresses and 3 examples in each column for high cardinality columns :\naddress_id : 1, 13, 11\nline_1_number_building : 9590 Rogahn Point Apt. 466, 6830 Alexanne Forks Apt. 925, 319 Kozey Highway Suite 973\ncity : Edgardoberg, Gibsonfurt, Lake Floyd\nzip_postcode : 770, 116, 740\nstate_province_county : District of Columbia, Louisiana, SouthDakota\n*/\n/*\nColumns in Addresses and all categories for low cardinality columns :\ncountry : USA\n*/\n \nCREATE TABLE club (\n\t\"Club_ID\" INTEGER, \n\t\"Club_name\" TEXT, \n\t\"Region\" TEXT, \n\t\"Start_year\" INTEGER, \n\tPRIMARY KEY (\"Club_ID\")\n)\n/*\nColumns in club and all categories for low cardinality columns :\nClub_ID : 1, 2, 5, 4, 6, 3\nClub_name : BK Häcken, Helsingborgs IF, Djurgårdens IF, Gefle IF, Halmstads BK, AIK\nRegion : Korea, UK, France, Russia, USA\nStart_year : 2009, 2001, 2005, 2000, 1998, 2011\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Birth_Date\" TEXT, \n\t\"Birth_Place\" TEXT, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and all categories for low cardinality columns :\nPeople_ID : 1, 2, 5, 4, 6, 3\nName : Ty Conklin, Jake Gardiner, Al Montoya, Mark Fayne, Jack Campbell, Cam Fowler\nHeight : 215.0, 182.0, 195.0, 205.0, 192.0, 196.0\nWeight : 89.0, 100.0, 90.0, 102.0, 80.0, 92.0\nBirth_Date : December 5, 1991, May 5, 1987, July 4, 1990, February 13, 1985, March 30, 1976, January 1, 1992\nBirth_Place : Farmington Hills, Michigan, Anchorage, Alaska, Glenview, Illinois, Nashua, New Hampshire, Minnetonka, Minnesota, Port Huron, Michigan\n*/\n \nCREATE TABLE \"Member_of_club\" (\n\t\"StuID\" INTEGER, \n\t\"ClubID\" INTEGER, \n\t\"Position\" VARCHAR(40), \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"ClubID\") REFERENCES \"Club\" (\"ClubID\")\n)\n/*\nColumns in Member_of_club and all categories for low cardinality columns :\nStuID : 1008, 1001, 1010, 1007\nClubID : 1, 2, 4\nPosition : Teaching Coordinator, CTO, Vice-President, President\n*/\n \nCREATE TABLE affected_region (\n\t\"Region_id\" INTEGER, \n\t\"Storm_ID\" INTEGER, \n\t\"Number_city_affected\" REAL, \n\tPRIMARY KEY (\"Region_id\", \"Storm_ID\"), \n\tFOREIGN KEY(\"Storm_ID\") REFERENCES storm (\"Storm_ID\"), \n\tFOREIGN KEY(\"Region_id\") REFERENCES region (\"Region_id\")\n)\n/*\nColumns in affected_region and all categories for low cardinality columns :\nRegion_id : 1, 2, 12, 3\nStorm_ID : 1, 5, 4, 3\nNumber_city_affected : 12.0, 30.0, 15.0, 10.0, 22.0, 37.0\n*/\n \nCREATE TABLE \"Manufacturers\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Headquarter\" VARCHAR(255) NOT NULL, \n\t\"Founder\" VARCHAR(255) NOT NULL, \n\t\"Revenue\" REAL, \n\tPRIMARY KEY (\"Code\")\n)\n/*\nColumns in Manufacturers and all categories for low cardinality columns :\nCode : 1, 2, 5, 4, 6, 3\nName : Winchester, Fujitsu, Iomega, Hewlett-Packard, Creative Labs, Sony\nHeadquarter : Beijing, Los Angeles, Austin, Tokyo, Paris, Taiwan\nFounder : Owen, Mary, James, John, Robert, Andy\nRevenue : 30.0, 100.0, 130.0, 200.0, 50.0, 120.0\n*/\n \nCREATE TABLE \"Student\" (\n\t\"StuID\" INTEGER, \n\t\"LName\" VARCHAR(12), \n\t\"Fname\" VARCHAR(12), \n\t\"Age\" INTEGER, \n\t\"Sex\" VARCHAR(1), \n\t\"Major\" INTEGER, \n\t\"Advisor\" INTEGER, \n\tcity_code VARCHAR(3), \n\tPRIMARY KEY (\"StuID\")\n)\n/*\nColumns in Student and 3 examples in each column for high cardinality columns :\nStuID : 1003, 1017, 1002\nLName : Lee, Han, Brody\nFname : Tracy, Michael, Shiela\nAdvisor : 7723, 7712, 7134\ncity_code : ATL, HOU, LON\n*/\n/*\nColumns in Student and all categories for low cardinality columns :\nAge : 26, 16, 20, 17, 21, 19, 18, 27, 22\nSex : F, M\nMajor : 520, 100, 50, 600, 540, 550\n*/\n \nCREATE TABLE film (\n\t\"Film_ID\" INTEGER, \n\t\"Rank_in_series\" INTEGER, \n\t\"Number_in_season\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Directed_by\" TEXT, \n\t\"Original_air_date\" TEXT, \n\t\"Production_code\" TEXT, \n\tPRIMARY KEY (\"Film_ID\")\n)\n/*\nColumns in film and all categories for low cardinality columns :\nFilm_ID : 1, 2, 5, 4, 3\nRank_in_series : 26, 28, 30, 27, 29\nNumber_in_season : 1, 2, 5, 4, 3\nTitle : The Case: Off the Record, The Case of the Mystery Weekend, The Case of the Piggy Banker, The Case of the Smart Dummy, The Case of the Bermuda Triangle\nDirected_by : Bill Schreiner, Jesus Salvador Treviño\nOriginal_air_date : October 5–9, 1992, September 28–October 2, 1992, October 19–23, 1992, October 12–16, 1992, September 21–25, 1992\nProduction_code : 50241–50245, 50011–50015, 50251–50255, 50231–50235, 50021–50025\n*/\n \nCREATE TABLE playlists (\n\tid INTEGER, \n\tname VARCHAR(120), \n\tPRIMARY KEY (id)\n)\n/*\nColumns in playlists and 3 examples in each column for high cardinality columns :\nid : 1, 16, 13\nname : Heavy Metal Classic, 90’s Music, Classical 101 - Deep Cuts\n*/\n\n \nCREATE TABLE \"Drama_Workshop_Groups\" (\n\t\"Workshop_Group_ID\" INTEGER NOT NULL, \n\t\"Address_ID\" INTEGER NOT NULL, \n\t\"Currency_Code\" CHAR(15) NOT NULL, \n\t\"Marketing_Region_Code\" CHAR(15) NOT NULL, \n\t\"Store_Name\" VARCHAR(255), \n\t\"Store_Phone\" VARCHAR(255), \n\t\"Store_Email_Address\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Workshop_Group_ID\"), \n\tFOREIGN KEY(\"Address_ID\") REFERENCES \"Addresses\" (\"Address_ID\"), \n\tUNIQUE (\"Workshop_Group_ID\")\n)\n/*\nColumns in Drama_Workshop_Groups and 3 examples in each column for high cardinality columns :\nWorkshop_Group_ID : 954, 431, 838\nAddress_ID : 230, 110, 180\nStore_Name : Hansen Print, Welch Flower, Roo Place\nStore_Phone : 492-463-5967, (256)743-0310, (636)443-4067\nStore_Email_Address : arturo.orn@example.org, bednar.michael@example.org, hansen.krista@example.net\n*/\n/*\nColumns in Drama_Workshop_Groups and all categories for low cardinality columns :\nCurrency_Code : EU, USD\nMarketing_Region_Code : FR, PT, MX, US, DE, IE, ES, RU\nOther_Details : Good, None, Bad\n*/\n \nCREATE TABLE \"Tracklists\" (\n\t\"AlbumId\" INTEGER, \n\t\"Position\" INTEGER, \n\t\"SongId\" INTEGER, \n\tPRIMARY KEY (\"AlbumId\", \"Position\"), \n\tFOREIGN KEY(\"SongId\") REFERENCES \"Songs\" (\"SongId\"), \n\tFOREIGN KEY(\"AlbumId\") REFERENCES \"Albums\" (\"AId\")\n)\n/*\nColumns in Tracklists and all categories for low cardinality columns :\nAlbumId : \nPosition : \nSongId : \n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE train (\n\t\"Train_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Time\" TEXT, \n\t\"Service\" TEXT, \n\tPRIMARY KEY (\"Train_ID\")\n)\n/*\nColumns in train and 3 examples in each column for high cardinality columns :\nTrain_ID : 1, 11, 2\nTime : 10:38, 16:59, 11:15\n*/\n/*\nColumns in train and all categories for low cardinality columns :\nName : Parasuram Express, Island Express, Ananthapuri Express, Madurai Fast Passenger, Quilon Fast Passenger, Jayanthi Janatha Express, Guruvayur Express\nService : Daily\n*/\n \nCREATE TABLE \"Product\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Product and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nproduct_name : life, messager, wechat\nproduct_details : d, m, q\n*/\n\n" }, { "role": "user", "content": "What are the names of the heads who are born outside the California state?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: head.\nFrom these tables, I'll be using the following columns: name, born_state.\nThe SQL query I'll be generating is:\nSELECT name FROM head WHERE born_state != 'California'" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE actor (\n\tactor_id INTEGER NOT NULL, \n\tfirst_name VARCHAR(45) NOT NULL, \n\tlast_name VARCHAR(45) NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (actor_id)\n)\n/*\nColumns in actor and 3 examples in each column for high cardinality columns :\nactor_id : 87, 56, 65\nfirst_name : WALTER, KIM, REESE\nlast_name : WITHERSPOON, OLIVIER, ALLEN\n*/\n/*\nColumns in actor and all categories for low cardinality columns :\nlast_update : 2006-02-15 04:34:33\n*/\n \nCREATE TABLE college (\n\t\"College_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Leader_Name\" TEXT, \n\t\"College_Location\" TEXT, \n\tPRIMARY KEY (\"College_ID\")\n)\n/*\nColumns in college and all categories for low cardinality columns :\nCollege_ID : 1, 2, 5, 4, 3\nName : Toronto School, Saskatchewan School, B.C. School, Calgary School, Edmonton School\nLeader_Name : Samir Chahine, Andre Arlain, Ryan Thelwell, Roger Dunbrack, Ousame Tounkara\nCollege_Location : St. Francis Xavier, McGill, Ottawa, Western Ontario, Minnesota\n*/\n \nCREATE TABLE \"Claims_Documents\" (\n\t\"Claim_ID\" INTEGER NOT NULL, \n\t\"Document_Type_Code\" CHAR(15) NOT NULL, \n\t\"Created_by_Staff_ID\" INTEGER, \n\t\"Created_Date\" INTEGER, \n\tPRIMARY KEY (\"Claim_ID\", \"Document_Type_Code\"), \n\tFOREIGN KEY(\"Claim_ID\") REFERENCES \"Claim_Headers\" (\"Claim_Header_ID\"), \n\tFOREIGN KEY(\"Created_by_Staff_ID\") REFERENCES \"Staff\" (\"Staff_ID\")\n)\n/*\nColumns in Claims_Documents and all categories for low cardinality columns :\nClaim_ID : 69, 45, 90, 24, 82, 62, 39, 27, 81, 73\nDocument_Type_Code : Medical, Document, Photo\nCreated_by_Staff_ID : 427, 771, 986, 673, 687, 589, 735, 803, 718\nCreated_Date : 1, 2, 7, 8, 6, 3, 9\n*/\n \nCREATE TABLE \"Timed_Locations_of_Things\" (\n\tthing_id INTEGER NOT NULL, \n\t\"Date_and_Time\" DATETIME NOT NULL, \n\t\"Location_Code\" CHAR(15) NOT NULL, \n\tPRIMARY KEY (thing_id, \"Date_and_Time\", \"Location_Code\"), \n\tFOREIGN KEY(thing_id) REFERENCES \"Things\" (thing_id)\n)\n/*\nColumns in Timed_Locations_of_Things and 3 examples in each column for high cardinality columns :\nDate_and_Time : 2017-03-19 13:57:49, 2017-08-31 13:54:13, 2016-12-29 00:39:19\nLocation_Code : 2677 Runolfsson, 288 Lang Ferry, 94425 Nellie Kn\n*/\n/*\nColumns in Timed_Locations_of_Things and all categories for low cardinality columns :\nthing_id : 26, 45, 2, 68, 58, 92, 14, 85, 10\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE pilot (\n\t\"Pilot_ID\" INTEGER, \n\t\"Pilot_name\" TEXT, \n\t\"Rank\" INTEGER, \n\t\"Age\" INTEGER, \n\t\"Nationality\" TEXT, \n\t\"Position\" TEXT, \n\t\"Join_Year\" INTEGER, \n\t\"Team\" TEXT, \n\tPRIMARY KEY (\"Pilot_ID\")\n)\n/*\nColumns in pilot and all categories for low cardinality columns :\nPilot_ID : 1, 2, 5, 4, 3\nPilot_name : Patrick O'Bryant, Charles Oakley, Dan O'Sullivan, Hakeem Olajuwon, Jermaine O'Neal\nRank : 34, 13, 45, 6\nAge : 37, 33, 40, 32, 22\nNationality : United States, Nigeria, United Kindom\nPosition : Center Team, Forward Team, Forward-Center Team\nJoin_Year : 2009, 2001, 2008, 1999, 2010\nTeam : Fordham, Eau Claire High School, Bradley, Virginia Union, Houston\n*/\n \nCREATE TABLE \"Campuses\" (\n\t\"Id\" INTEGER, \n\t\"Campus\" TEXT, \n\t\"Location\" TEXT, \n\t\"County\" TEXT, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Id\")\n)\n/*\nColumns in Campuses and 3 examples in each column for high cardinality columns :\nId : 17, 21, 9\nCampus : California State University-Chico, California State University-Sacramento, San Francisco State University\nLocation : San Bernardino, Seaside, Pomona\nCounty : Monterey, San Bernardino, Los Angeles\nYear : 1913, 1989, 1949\n*/\n\n \nCREATE TABLE \"Documents_Mailed\" (\n\tdocument_id INTEGER NOT NULL, \n\tmailed_to_address_id INTEGER NOT NULL, \n\tmailing_date DATETIME, \n\tPRIMARY KEY (document_id, mailed_to_address_id), \n\tFOREIGN KEY(document_id) REFERENCES \"Documents\" (document_id), \n\tFOREIGN KEY(mailed_to_address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in Documents_Mailed and 3 examples in each column for high cardinality columns :\nmailing_date : 2007-01-01 22:32:11, 2007-03-20 05:22:01, 1992-11-07 15:03:41\n*/\n/*\nColumns in Documents_Mailed and all categories for low cardinality columns :\ndocument_id : 13, 20, 2, 7, 24, 23, 4, 12, 14, 10\nmailed_to_address_id : 2, 5, 7, 8, 4, 3, 9, 0\n*/\n \nCREATE TABLE member (\n\t\"Member_ID\" INTEGER, \n\t\"Member_Name\" TEXT, \n\t\"Party_ID\" TEXT, \n\t\"In_office\" TEXT, \n\tPRIMARY KEY (\"Member_ID\"), \n\tFOREIGN KEY(\"Party_ID\") REFERENCES party (\"Party_ID\")\n)\n/*\nColumns in member and 3 examples in each column for high cardinality columns :\nMember_ID : 1, 13, 11\nMember_Name : Hon Bob Baldwin, Hon Kim Beazley, Kerry Bartlett\nIn_office : 1980–2007, 1996–2007, 1990–2010\n*/\n/*\nColumns in member and all categories for low cardinality columns :\nParty_ID : 1, 2, 3\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE repair (\n\t\"repair_ID\" INTEGER, \n\tname TEXT, \n\t\"Launch_Date\" TEXT, \n\t\"Notes\" TEXT, \n\tPRIMARY KEY (\"repair_ID\")\n)\n/*\nColumns in repair and all categories for low cardinality columns :\nrepair_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nname : OPS 3042, OPS 3491, OPS 3360, OPS 3754, OPS 3467, Discoverer 3, Discoverer 1, OPS 3236, Discoverer\nLaunch_Date : 10 Jun 2014, 13 Jun 2014, 05 Aug 2014, 28 Feb 2009, 24 Mar 2014, 21 Jan 2009, 18 Nov 2014, 19 Jun 2014, 03 Jun 2009\nNotes : Out-of-focus area on some film., repair failed. Guidance system failed. No orbit., repair Failed. Failed to achieve orbit, First object in polar orbit, repair failed. Failed to achieve orbit, Cameras operated successfully., Cameras operated satisfactorily\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE phone_market (\n\t\"Market_ID\" INTEGER, \n\t\"Phone_ID\" TEXT, \n\t\"Num_of_stock\" INTEGER, \n\tPRIMARY KEY (\"Market_ID\", \"Phone_ID\"), \n\tFOREIGN KEY(\"Phone_ID\") REFERENCES phone (\"Phone_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in phone_market and all categories for low cardinality columns :\nMarket_ID : 1, 2, 5, 6\nPhone_ID : 1, 2, 4, 3\nNum_of_stock : 2232, 874, 4324, 682, 908, 1632\n*/\n \nCREATE TABLE match_season (\n\t\"Season\" REAL, \n\t\"Player\" TEXT, \n\t\"Position\" TEXT, \n\t\"Country\" INTEGER, \n\t\"Team\" INTEGER, \n\t\"Draft_Pick_Number\" INTEGER, \n\t\"Draft_Class\" TEXT, \n\t\"College\" TEXT, \n\tPRIMARY KEY (\"Season\"), \n\tFOREIGN KEY(\"Team\") REFERENCES team (\"Team_id\"), \n\tFOREIGN KEY(\"Country\") REFERENCES country (\"Country_id\")\n)\n/*\nColumns in match_season and 3 examples in each column for high cardinality columns :\nSeason : 2003.0, 2001.0, 2006.0\nPlayer : Carlos Bocanegra Category:Articles with hCards, Ben Olsen Category:Articles with hCards, Rodrigo Faria Category:Articles with hCards\nDraft_Pick_Number : 87, 1, 13\nDraft_Class : 2005 MLS SuperDraft, 2004 MLS SuperDraft, 1996 MLS Inaugural Player Draft\nCollege : Cal State Northridge, Duke, Furman\n*/\n/*\nColumns in match_season and all categories for low cardinality columns :\nPosition : Midfielder, Defender, Forward\nCountry : 1, 4, 6, 5\nTeam : 1, 2, 5, 4, 3, 10, 9\n*/\n \nCREATE TABLE player (\n\t\"Player_ID\" INTEGER, \n\t\"Sponsor_name\" TEXT, \n\t\"Player_name\" TEXT, \n\t\"Gender\" TEXT, \n\t\"Residence\" TEXT, \n\t\"Occupation\" TEXT, \n\t\"Votes\" INTEGER, \n\t\"Rank\" TEXT, \n\tPRIMARY KEY (\"Player_ID\")\n)\n/*\nColumns in player and 3 examples in each column for high cardinality columns :\nPlayer_ID : 1, 13, 11\nSponsor_name : Elmwood—Transcona, Brandon—Souris, Winnipeg South Centre\nPlayer_name : Mohamed Alli, Matt Schaubroeck, Jean Luc Bouché\nOccupation : Parliamentarian, Distribution Centre Associate, Product Consultant - MLCC\nVotes : 4673, 14097, 7190\n*/\n/*\nColumns in player and all categories for low cardinality columns :\nGender : F, M\nResidence : Selkirk, Thompson, Brandon, Birtle, Oakbank, Winnipeg\nRank : 4th, 3rd, 2nd, 1st\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_first_name VARCHAR(20), \n\tcustomer_last_name VARCHAR(20), \n\tcustomer_address VARCHAR(255), \n\tcustomer_phone VARCHAR(255), \n\tcustomer_email VARCHAR(255), \n\tother_customer_details VARCHAR(255), \n\tPRIMARY KEY (customer_id)\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\ncustomer_first_name : Armani, Bryce, Nat\ncustomer_last_name : Swift, Lind, Huels\ncustomer_address : 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898, 47286 Mraz Park Apt. 424\nJocelynfurt, OH 59023-2787, 094 Julianne Mill\nWebstertown, KY 91980-4004\ncustomer_phone : (415)237-0701x3115, 679-845-8645x94312, 284.749.0453\ncustomer_email : kyra.murazik@example.org, schaden.katrina@example.net, huels.antonina@example.com\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\nother_customer_details : None\n*/\n \nCREATE TABLE candidate (\n\t\"Candidate_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Poll_Source\" TEXT, \n\t\"Date\" TEXT, \n\t\"Support_rate\" REAL, \n\t\"Consider_rate\" REAL, \n\t\"Oppose_rate\" REAL, \n\t\"Unsure_rate\" REAL, \n\tPRIMARY KEY (\"Candidate_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in candidate and all categories for low cardinality columns :\nCandidate_ID : 1, 2, 5, 4, 6, 3\nPeople_ID : 1, 7, 4, 6, 3, 9\nPoll_Source : Newsweek Poll, FOX News/Opinion Dynamics Poll, WNBC/Marist Poll\nDate : Feb 12–15, 2007, Nov 9–10, 2006, Feb 13–14, 2007\nSupport_rate : 0.18, 0.25, 0.17, 0.33, 0.24\nConsider_rate : 0.34, 0.27, 0.42, 0.3, 0.2\nOppose_rate : 0.32, 0.44, 0.45, 0.43\nUnsure_rate : 0.4, 0.3, 0.2, 0.9\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tpayment_method VARCHAR(15) NOT NULL, \n\tcustomer_name VARCHAR(80), \n\tcustomer_phone VARCHAR(80), \n\tcustomer_email VARCHAR(80), \n\tcustomer_address VARCHAR(255), \n\tcustomer_login VARCHAR(80), \n\tcustomer_password VARCHAR(10), \n\tPRIMARY KEY (customer_id)\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\ncustomer_name : Kyle, Ruthie, Elvera\ncustomer_phone : 698-327-5792, +66(7)1491041398, 203-036-0511x96487\ncustomer_email : kristina85@example.org, davis.rosamond@example.net, marc.schiller@example.com\ncustomer_address : 80569 Crona Path Suite 165, 5514 Ophelia Cliffs Apt. 266, 56955 Desmond Lake Apt. 120\ncustomer_password : 9dc50bc5b6, f64f0fd096, 0b9f651030\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\npayment_method : Credit Card, Direct Debit\ncustomer_login : None\n*/\n" }, { "role": "user", "content": "What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department, management, head.\nFrom these tables, I'll be using the following columns: department.creation, department.department_id, management.department_id, management.head_id, head.head_id, head.born_state.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T1.creation FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T3.born_state = 'Alabama'" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE region (\n\t\"Region_id\" INTEGER, \n\t\"Region_code\" TEXT, \n\t\"Region_name\" TEXT, \n\tPRIMARY KEY (\"Region_id\")\n)\n/*\nColumns in region and 3 examples in each column for high cardinality columns :\nRegion_id : 1, 13, 11\nRegion_code : AG, AI, AQ\nRegion_name : Angola, Cyprus, Denmark\n*/\n\n \nCREATE TABLE \"driverStandings\" (\n\t\"driverStandingsId\" INTEGER, \n\t\"raceId\" INTEGER, \n\t\"driverId\" INTEGER, \n\tpoints REAL, \n\tposition INTEGER, \n\t\"positionText\" TEXT, \n\twins INTEGER, \n\tPRIMARY KEY (\"driverStandingsId\"), \n\tFOREIGN KEY(\"raceId\") REFERENCES races (\"raceId\"), \n\tFOREIGN KEY(\"driverId\") REFERENCES drivers (\"driverId\")\n)\n/*\nColumns in driverStandings and 3 examples in each column for high cardinality columns :\ndriverStandingsId : 87, 56, 65\ndriverId : 17, 21, 9\npoints : 8.0, 3.0, 29.0\nposition : 17, 21, 9\npositionText : 17, 21, 9\n*/\n/*\nColumns in driverStandings and all categories for low cardinality columns :\nraceId : 26, 20, 25, 24, 23, 21, 19, 18, 27, 22\nwins : 1, 2, 4, 3, 0\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE budget (\n\t\"School_id\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Budgeted\" INTEGER, \n\ttotal_budget_percent_budgeted REAL, \n\t\"Invested\" INTEGER, \n\ttotal_budget_percent_invested REAL, \n\t\"Budget_invested_percent\" TEXT, \n\tPRIMARY KEY (\"School_id\", \"Year\"), \n\tFOREIGN KEY(\"School_id\") REFERENCES \"School\" (\"School_id\")\n)\n/*\nColumns in budget and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 4, 3\nYear : 2004, 2001, 2005, 1999, 2000, 2006, 2002, 2003\nBudgeted : 113531, 3666, 61283, 119527, 6803, 4979, 74849\ntotal_budget_percent_budgeted : 1.3, 2.0, 2.4\nInvested : 8335, 5840, 95542, 146102, 2134, 85249, 140102\ntotal_budget_percent_invested : 2.7, 2.2, 2.0\nBudget_invested_percent : 71.3, 228.6, 146.9, 127.6, 228.8, 122.5, 42.9, 159.3\n*/\n \nCREATE TABLE \"Person\" (\n\tname VARCHAR(20), \n\tage INTEGER, \n\tcity TEXT, \n\tgender TEXT, \n\tjob TEXT, \n\tPRIMARY KEY (name)\n)\n/*\nColumns in Person and all categories for low cardinality columns :\nname : Alice, Zach, Dan, Bob\nage : 26, 25, 45, 35\ncity : austin, salt lake city, chicago, new york city\ngender : female, male\njob : student, engineer, doctor\n*/\n \nCREATE TABLE \"Policies\" (\n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_Type_Code\" CHAR(15) NOT NULL, \n\t\"Start_Date\" DATETIME, \n\t\"End_Date\" DATETIME, \n\tPRIMARY KEY (\"Policy_ID\"), \n\tFOREIGN KEY(\"Customer_ID\") REFERENCES \"Customers\" (\"Customer_ID\")\n)\n/*\nColumns in Policies and 3 examples in each column for high cardinality columns :\nPolicy_ID : 703, 151, 768\nStart_Date : 2018-03-13 12:30:19, 2018-02-10 08:56:30, 2018-07-21 10:36:53\nEnd_Date : 2017-10-07 08:29:25, 2018-01-19 22:45:33, 2018-03-07 13:52:47\n*/\n/*\nColumns in Policies and all categories for low cardinality columns :\nCustomer_ID : 588, 858, 808, 334, 252, 994, 380, 430, 857, 435\nPolicy_Type_Code : Uniformed, Normal, Jurisdiction, Deputy\n*/\n \nCREATE TABLE musical (\n\t\"Musical_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Year\" INTEGER, \n\t\"Award\" TEXT, \n\t\"Category\" TEXT, \n\t\"Nominee\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"Musical_ID\")\n)\n/*\nColumns in musical and all categories for low cardinality columns :\nMusical_ID : 1, 2, 5, 7, 4, 6, 3\nName : The Book of Mormon, Les Misérables, Rent, Chicago, West Side Story, The Phantom of the Opera, Wicked\nYear : 1986\nAward : Drama Desk Award, Tony Award\nCategory : Outstanding Director of a Musical, Best Direction of a Musical, Best Choreography, Best Performance by a Leading Actor in a Musical, Outstanding Choreography, Best Book of a Musical, Outstanding Actor in a Musical\nNominee : Bob Fosse, Cleavant Derricks\nResult : Nominated, Won\n*/\n \nCREATE TABLE \"Images\" (\n\timage_id INTEGER, \n\timage_alt_text VARCHAR(80), \n\timage_name VARCHAR(40), \n\timage_url VARCHAR(255), \n\tPRIMARY KEY (image_id)\n)\n/*\nColumns in Images and 3 examples in each column for high cardinality columns :\nimage_id : 1, 13, 11\nimage_alt_text : Chaya, Ashtyn, Marianna\nimage_name : chapter3, data1, data2\nimage_url : http://www.bernierconnelly.com/1.jpg, http://www.hermann.com/1.jpg, http://connellykertzmann.org/1.jpg\n*/\n\n \nCREATE TABLE \"Vehicles\" (\n\tvehicle_id INTEGER, \n\tvehicle_details VARCHAR(255), \n\tPRIMARY KEY (vehicle_id)\n)\n/*\nColumns in Vehicles and all categories for low cardinality columns :\nvehicle_id : 1, 2, 3\nvehicle_details : Car, Van, Truck\n*/\n \nCREATE TABLE record (\n\t\"ID\" INTEGER, \n\t\"Result\" TEXT, \n\t\"Swimmer_ID\" INTEGER, \n\t\"Event_ID\" INTEGER, \n\tPRIMARY KEY (\"Swimmer_ID\", \"Event_ID\"), \n\tFOREIGN KEY(\"Swimmer_ID\") REFERENCES swimmer (\"ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES event (\"ID\")\n)\n/*\nColumns in record and 3 examples in each column for high cardinality columns :\nID : 1, 13, 11\n*/\n/*\nColumns in record and all categories for low cardinality columns :\nResult : Loss, Win, NC\nSwimmer_ID : 1, 2, 5, 4, 6, 3\nEvent_ID : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"Shipments\" (\n\tshipment_id INTEGER, \n\torder_id INTEGER NOT NULL, \n\tinvoice_number INTEGER NOT NULL, \n\tshipment_tracking_number VARCHAR(80), \n\tshipment_date DATETIME, \n\tother_shipment_details VARCHAR(255), \n\tPRIMARY KEY (shipment_id), \n\tFOREIGN KEY(invoice_number) REFERENCES \"Invoices\" (invoice_number), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Shipments and 3 examples in each column for high cardinality columns :\nshipment_id : 1, 13, 11\norder_id : 13, 2, 5\nshipment_tracking_number : 5991, 0182, 2323\nshipment_date : 1977-11-10 12:11:25, 1982-01-24 12:13:16, 1981-11-13 23:20:42\n*/\n/*\nColumns in Shipments and all categories for low cardinality columns :\ninvoice_number : 13, 10, 2, 5, 3, 15, 9\nother_shipment_details : None\n*/\n \nCREATE TABLE \"Problems\" (\n\tproblem_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\tclosure_authorised_by_staff_id INTEGER NOT NULL, \n\treported_by_staff_id INTEGER NOT NULL, \n\tdate_problem_reported DATETIME NOT NULL, \n\tdate_problem_closed DATETIME, \n\tproblem_description VARCHAR(255), \n\tother_problem_details VARCHAR(255), \n\tPRIMARY KEY (problem_id), \n\tFOREIGN KEY(reported_by_staff_id) REFERENCES \"Staff\" (staff_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Product\" (product_id), \n\tFOREIGN KEY(closure_authorised_by_staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Problems and 3 examples in each column for high cardinality columns :\nproblem_id : 1, 13, 11\nclosure_authorised_by_staff_id : 1, 13, 2\ndate_problem_reported : 1995-05-14 08:32:56, 1988-11-07 16:09:31, 1986-11-13 07:30:55\ndate_problem_closed : 1974-09-20 13:42:19, 1997-10-18 20:09:57, 2004-06-20 01:08:25\nproblem_description : d, i, s\n*/\n/*\nColumns in Problems and all categories for low cardinality columns :\nproduct_id : 1, 13, 2, 5, 7, 8, 4, 6, 15\nreported_by_staff_id : 1, 13, 11, 2, 5, 7, 4, 14, 10\nother_problem_details : f, m, i, s, k, l, p, v, c\n*/\n \nCREATE TABLE \"Maintenance_Contracts\" (\n\tmaintenance_contract_id INTEGER, \n\tmaintenance_contract_company_id INTEGER NOT NULL, \n\tcontract_start_date DATETIME, \n\tcontract_end_date DATETIME, \n\tother_contract_details VARCHAR(255), \n\tPRIMARY KEY (maintenance_contract_id), \n\tFOREIGN KEY(maintenance_contract_company_id) REFERENCES \"Third_Party_Companies\" (company_id)\n)\n/*\nColumns in Maintenance_Contracts and 3 examples in each column for high cardinality columns :\nmaintenance_contract_id : 1, 13, 11\ncontract_start_date : 2017-12-06 20:09:39, 2017-10-28 05:13:21, 2017-07-23 05:07:37\ncontract_end_date : 2018-03-15 06:45:00, 2018-03-14 10:17:43, 2018-03-20 14:02:54\n*/\n/*\nColumns in Maintenance_Contracts and all categories for low cardinality columns :\nmaintenance_contract_company_id : 13, 11, 10, 7, 8, 4, 6, 14, 15, 9\nother_contract_details : None\n*/\n \nCREATE TABLE \"Papers\" (\n\t\"paperID\" INTEGER, \n\ttitle TEXT, \n\tPRIMARY KEY (\"paperID\")\n)\n/*\nColumns in Papers and all categories for low cardinality columns :\npaperID : 201, 204, 205, 200, 206, 203, 202\ntitle : Nameless, Painless, Binders Unbound, Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory, An Equivalence-Preserving CPS Translation via Multi-Language Semantics, Making Standard ML a Practical Database Programming Language, Functional Pearl: Modular Rollback through Control Logging, Just do it: Simple Monadic Equational Reasoning\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE actor (\n\tactor_id INTEGER NOT NULL, \n\tfirst_name VARCHAR(45) NOT NULL, \n\tlast_name VARCHAR(45) NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (actor_id)\n)\n/*\nColumns in actor and 3 examples in each column for high cardinality columns :\nactor_id : 87, 56, 65\nfirst_name : WALTER, KIM, REESE\nlast_name : WITHERSPOON, OLIVIER, ALLEN\n*/\n/*\nColumns in actor and all categories for low cardinality columns :\nlast_update : 2006-02-15 04:34:33\n*/\n \nCREATE TABLE airlines (\n\talid INTEGER, \n\tname TEXT, \n\tiata VARCHAR(2), \n\ticao VARCHAR(3), \n\tcallsign TEXT, \n\tcountry TEXT, \n\tactive VARCHAR(2), \n\tPRIMARY KEY (alid)\n)\n/*\nColumns in airlines and 3 examples in each column for high cardinality columns :\nalid : 87, 56, 65\nname : Arab Agricultural Aviation Company, Avion Taxi, Amadeus Global Travel Distribution\niata : , U3, JP\nicao : , ADP, UVS\ncallsign : , ALGOMA, SECUREX\ncountry : , Afghanistan, Gabon\n*/\n/*\nColumns in airlines and all categories for low cardinality columns :\nactive : Y, N\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE \"Student\" (\n\t\"StuID\" INTEGER, \n\t\"LName\" VARCHAR(12), \n\t\"Fname\" VARCHAR(12), \n\t\"Age\" INTEGER, \n\t\"Sex\" VARCHAR(1), \n\t\"Major\" INTEGER, \n\t\"Advisor\" INTEGER, \n\tcity_code VARCHAR(3), \n\tPRIMARY KEY (\"StuID\")\n)\n/*\nColumns in Student and 3 examples in each column for high cardinality columns :\nStuID : 1003, 1017, 1002\nLName : Lee, Han, Brody\nFname : Tracy, Michael, Shiela\nAdvisor : 7723, 7712, 7134\ncity_code : ATL, HOU, LON\n*/\n/*\nColumns in Student and all categories for low cardinality columns :\nAge : 26, 16, 20, 17, 21, 19, 18, 27, 22\nSex : F, M\nMajor : 520, 100, 50, 600, 540, 550\n*/\n" }, { "role": "user", "content": "What are the names of the states where at least 3 heads were born?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: head.\nFrom these tables, I'll be using the following columns: born_state.\nThe SQL query I'll be generating is:\nSELECT born_state FROM head GROUP BY born_state HAVING count(*) >= 3" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE prereq (\n\tcourse_id VARCHAR(8), \n\tprereq_id VARCHAR(8), \n\tPRIMARY KEY (course_id, prereq_id), \n\tFOREIGN KEY(course_id) REFERENCES course (course_id), \n\tFOREIGN KEY(prereq_id) REFERENCES course (course_id)\n)\n/*\nColumns in prereq and 3 examples in each column for high cardinality columns :\ncourse_id : 241, 586, 628\nprereq_id : 304, 628, 927\n*/\n\n \nCREATE TABLE artwork (\n\t\"Artwork_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Artwork_ID\")\n)\n/*\nColumns in artwork and all categories for low cardinality columns :\nArtwork_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nType : Presenter Talent Show, Program Talent Show, Presenter Music/Variety Show, Program Music/Variety Show\nName : Why, I Know, Martin, Indonesian Idol, Loving you, Daniel Mananta, Back Home, Cats, Boys\n*/\n \nCREATE TABLE exhibition (\n\t\"Exhibition_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Theme\" TEXT, \n\t\"Artist_ID\" INTEGER, \n\t\"Ticket_Price\" REAL, \n\tPRIMARY KEY (\"Exhibition_ID\"), \n\tFOREIGN KEY(\"Artist_ID\") REFERENCES artist (\"Artist_ID\")\n)\n/*\nColumns in exhibition and all categories for low cardinality columns :\nExhibition_ID : 1, 2, 5, 4, 6, 3\nYear : 2004, 2009, 2005, 2008, 2006, 2007\nTheme : Christmas Tree, Santa Claus and Rudolph the Red-Nosed Reindeer, Summer, Christmas stocking, Spring, Santa Claus\nArtist_ID : 1, 2, 4, 6, 3\nTicket_Price : 19.95, 9.95, 29.95, 14.95, 16.95\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Problems\" (\n\tproblem_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\tclosure_authorised_by_staff_id INTEGER NOT NULL, \n\treported_by_staff_id INTEGER NOT NULL, \n\tdate_problem_reported DATETIME NOT NULL, \n\tdate_problem_closed DATETIME, \n\tproblem_description VARCHAR(255), \n\tother_problem_details VARCHAR(255), \n\tPRIMARY KEY (problem_id), \n\tFOREIGN KEY(reported_by_staff_id) REFERENCES \"Staff\" (staff_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Product\" (product_id), \n\tFOREIGN KEY(closure_authorised_by_staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Problems and 3 examples in each column for high cardinality columns :\nproblem_id : 1, 13, 11\nclosure_authorised_by_staff_id : 1, 13, 2\ndate_problem_reported : 1995-05-14 08:32:56, 1988-11-07 16:09:31, 1986-11-13 07:30:55\ndate_problem_closed : 1974-09-20 13:42:19, 1997-10-18 20:09:57, 2004-06-20 01:08:25\nproblem_description : d, i, s\n*/\n/*\nColumns in Problems and all categories for low cardinality columns :\nproduct_id : 1, 13, 2, 5, 7, 8, 4, 6, 15\nreported_by_staff_id : 1, 13, 11, 2, 5, 7, 4, 14, 10\nother_problem_details : f, m, i, s, k, l, p, v, c\n*/\n \nCREATE TABLE \"Physician\" (\n\t\"EmployeeID\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(30) NOT NULL, \n\t\"Position\" VARCHAR(30) NOT NULL, \n\t\"SSN\" INTEGER NOT NULL, \n\tCONSTRAINT pk_physician PRIMARY KEY (\"EmployeeID\")\n)\n/*\nColumns in Physician and all categories for low cardinality columns :\nEmployeeID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : John Dorian, Bob Kelso, Todd Quinlan, Elliot Reid, John Wen, Keith Dudemeister, Molly Clock, Percival Cox, Christopher Turk\nPosition : Senior Attending Physician, Head Chief of Medicine, Staff Internist, Attending Physician, Surgical Attending Physician, Attending Psychiatrist, MD Resident\nSSN : 888888888, 999999999, 111111111, 444444444, 777777777, 222222222, 333333333, 555555555, 666666666\n*/\n \nCREATE TABLE \"Tryout\" (\n\t\"pID\" NUMERIC(5, 0), \n\t\"cName\" VARCHAR(20), \n\t\"pPos\" VARCHAR(8), \n\tdecision VARCHAR(3), \n\tPRIMARY KEY (\"pID\", \"cName\"), \n\tFOREIGN KEY(\"pID\") REFERENCES \"Player\" (\"pID\"), \n\tFOREIGN KEY(\"cName\") REFERENCES \"College\" (\"cName\")\n)\n/*\nColumns in Tryout and all categories for low cardinality columns :\npID : 20002, 40004, 50005, 30003, 10001\ncName : FSU, OU, ASU, LSU\npPos : striker, goalie, mid\ndecision : yes, no\n*/\n \nCREATE TABLE \"Participants\" (\n\t\"Participant_ID\" INTEGER NOT NULL, \n\t\"Participant_Type_Code\" CHAR(15) NOT NULL, \n\t\"Participant_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Participant_ID\")\n)\n/*\nColumns in Participants and 3 examples in each column for high cardinality columns :\nParticipant_ID : 26, 38, 37\nParticipant_Details : Karlee Batz, Miss Kaci Lebsack, Neil Blick\n*/\n/*\nColumns in Participants and all categories for low cardinality columns :\nParticipant_Type_Code : Organizer, Participant\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE stadium (\n\tid INTEGER, \n\tname TEXT, \n\t\"Home_Games\" INTEGER, \n\t\"Average_Attendance\" REAL, \n\t\"Total_Attendance\" REAL, \n\t\"Capacity_Percentage\" REAL, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in stadium and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nname : Gillette Stadium, Lincoln Financial Field, New Meadowlands Stadium\nAverage_Attendance : 70038.0, 87047.0, 71227.0\nTotal_Attendance : 553144.0, 566362.0, 550048.0\n*/\n/*\nColumns in stadium and all categories for low cardinality columns :\nHome_Games : 8\nCapacity_Percentage : 96.0, 108.8, 100.3, 100.0, 95.8, 90.7, 102.3, 98.4, 97.1, 95.3\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE \"Regular_Order_Products\" (\n\tregular_order_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tFOREIGN KEY(regular_order_id) REFERENCES \"Regular_Orders\" (regular_order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Regular_Order_Products and 3 examples in each column for high cardinality columns :\nregular_order_id : 1, 13, 2\n*/\n/*\nColumns in Regular_Order_Products and all categories for low cardinality columns :\nproduct_id : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE climber (\n\t\"Climber_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Country\" TEXT, \n\t\"Time\" TEXT, \n\t\"Points\" REAL, \n\t\"Mountain_ID\" INTEGER, \n\tPRIMARY KEY (\"Climber_ID\"), \n\tFOREIGN KEY(\"Mountain_ID\") REFERENCES mountain (\"Mountain_ID\")\n)\n/*\nColumns in climber and all categories for low cardinality columns :\nClimber_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Hans Luthringhauser, Charlie Freedman, Georg Auerbacher, Klaus Enders, Arseneus Butscher, Horst Owesle, Jean Claude Castella, Mick Horsepole, Siegfried Schauzu, L Currie\nCountry : West Germany, Switzerland, United Kingdom\nTime : 1:17.22.0, 1:25.02.8, 1:25.40.6, 1:27.28.8, 1:13.05.6, 1:18.14.6, 1:21.35.6, 1:17.16.0, 1:16.58.0, 1:14.56.4\nPoints : 8.0, 3.0, 12.0, 15.0, 10.0, 1.0, 6.0, 2.0, 4.0, 5.0\nMountain_ID : 1, 2, 5, 7, 3\n*/\n \nCREATE TABLE journal (\n\t\"Journal_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Theme\" TEXT, \n\t\"Sales\" INTEGER, \n\tPRIMARY KEY (\"Journal_ID\")\n)\n/*\nColumns in journal and 3 examples in each column for high cardinality columns :\nJournal_ID : 1, 16, 13\nDate : September 23, 2001, November 25, 2001, October 21, 2001\nTheme : Cleveland Browns, at Baltimore Ravens, Baltimore Ravens\nSales : 3798, 5342, 2804\n*/\n\n \nCREATE TABLE broadcast (\n\t\"Channel_ID\" INTEGER, \n\t\"Program_ID\" INTEGER, \n\t\"Time_of_day\" TEXT, \n\tPRIMARY KEY (\"Channel_ID\", \"Program_ID\"), \n\tFOREIGN KEY(\"Program_ID\") REFERENCES program (\"Program_ID\"), \n\tFOREIGN KEY(\"Channel_ID\") REFERENCES channel (\"Channel_ID\")\n)\n/*\nColumns in broadcast and all categories for low cardinality columns :\nChannel_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nProgram_ID : 1, 2, 4, 3\nTime_of_day : Morning, Night, Noon\n*/\n \nCREATE TABLE departments (\n\t\"DEPARTMENT_ID\" DECIMAL(4, 0) DEFAULT '0' NOT NULL, \n\t\"DEPARTMENT_NAME\" VARCHAR(30) NOT NULL, \n\t\"MANAGER_ID\" DECIMAL(6, 0) DEFAULT NULL, \n\t\"LOCATION_ID\" DECIMAL(4, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"DEPARTMENT_ID\")\n)\n/*\nColumns in departments and 3 examples in each column for high cardinality columns :\nDEPARTMENT_ID : 170, 160, 120\nDEPARTMENT_NAME : Shipping, Purchasing, Corporate Tax\nMANAGER_ID : 114, 201, 108\n*/\n/*\nColumns in departments and all categories for low cardinality columns :\nLOCATION_ID : 1700, 1800, 2700, 2400, 2500, 1500, 1400\n*/\n \nCREATE TABLE mill (\n\tarchitect_id INTEGER, \n\tid INTEGER, \n\tlocation TEXT, \n\tname TEXT, \n\ttype TEXT, \n\tbuilt_year INTEGER, \n\tnotes TEXT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(architect_id) REFERENCES architect (id)\n)\n/*\nColumns in mill and all categories for low cardinality columns :\narchitect_id : 1, 2, 4, 3\nid : 1, 2, 5, 4, 6, 3\nlocation : Donceel, Momalle, Fexhe-le-haut-Clocher, Othée, Pousset, Coswarem\nname : Le Vieux Molen, Moulin de Pousset, Moulin de Momalle, Moulin Bertrand, Moulin de Fexhe, Moulin du Château\ntype : Bergmolen, Grondzeiler\nbuilt_year : 1840, 1819, 1856, 1843, 1850, 1890\nnotes : Molenechos (Dutch)\n*/\n \nCREATE TABLE building (\n\tbuilding_id TEXT, \n\t\"Name\" TEXT, \n\t\"Street_address\" TEXT, \n\t\"Years_as_tallest\" TEXT, \n\t\"Height_feet\" INTEGER, \n\t\"Floors\" INTEGER, \n\tPRIMARY KEY (building_id)\n)\n/*\nColumns in building and all categories for low cardinality columns :\nbuilding_id : 1, 2, 5, 7, 4, 6, 3, 0\nName : Bank of America Tower, Franklin Exchange Building, One Tampa City Center, 100 North Tampa, Park Tower, Citizens Bank Building, Floridan Hotel, Tampa City Hall\nStreet_address : 905 Franklin Street, 701 North Franklin Street, 655 North Franklin Street, 315 John F. Kennedy Boulevard, 101 East Kennedy Boulevard, 100 North Tampa Street, 400 North Tampa Street, 201 North Franklin Street\nYears_as_tallest : 1966–1972, 1981–1986, 1913–1915, 1992–present, 1986–1992, 1915–1926, 1926–1966, 1972–1981\nHeight_feet : 204, 537, 458, 577, 145, 579, 160, 280\nFloors : 42, 36, 17, 12, 39, 10, 22\n*/\n \nCREATE TABLE \"Shipment_Items\" (\n\tshipment_id INTEGER NOT NULL, \n\torder_item_id INTEGER NOT NULL, \n\tFOREIGN KEY(shipment_id) REFERENCES \"Shipments\" (shipment_id), \n\tFOREIGN KEY(order_item_id) REFERENCES \"Order_Items\" (order_item_id)\n)\n/*\nColumns in Shipment_Items and all categories for low cardinality columns :\nshipment_id : 13, 11, 2, 5, 15, 4, 14, 3, 12, 10\norder_item_id : 13, 11, 2, 5, 15, 7, 4, 12, 10\n*/\n \nCREATE TABLE chip_model (\n\t\"Model_name\" TEXT, \n\t\"Launch_year\" REAL, \n\t\"RAM_MiB\" REAL, \n\t\"ROM_MiB\" REAL, \n\t\"Slots\" TEXT, \n\t\"WiFi\" TEXT, \n\t\"Bluetooth\" TEXT, \n\tPRIMARY KEY (\"Model_name\")\n)\n/*\nColumns in chip_model and 3 examples in each column for high cardinality columns :\nModel_name : X30 mid-range, X50 Advanced, X51 mid-range\n*/\n/*\nColumns in chip_model and all categories for low cardinality columns :\nLaunch_year : 2002.0, 2005.0, 2004.0, 2003.0\nRAM_MiB : 32.0, 64.0\nROM_MiB : 48.0, 256.0, 128.0, 32.0, 64.0\nSlots : 1CFII,1SD, 1SD\nWiFi : 802.11b, No\nBluetooth : 1.2, Yes, No, 1.1\n*/\n" }, { "role": "user", "content": "In which year were most departments established?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department.\nFrom these tables, I'll be using the following columns: creation.\nThe SQL query I'll be generating is:\nSELECT creation FROM department GROUP BY creation ORDER BY count(*) DESC LIMIT 1" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE phone (\n\t\"Company_name\" TEXT, \n\t\"Hardware_Model_name\" TEXT, \n\t\"Accreditation_type\" TEXT, \n\t\"Accreditation_level\" TEXT, \n\t\"Date\" TEXT, \n\tchip_model TEXT, \n\tscreen_mode TEXT, \n\tPRIMARY KEY (\"Hardware_Model_name\"), \n\tFOREIGN KEY(chip_model) REFERENCES chip_model (\"Model_name\"), \n\tFOREIGN KEY(screen_mode) REFERENCES screen_mode (\"Graphics_mode\")\n)\n/*\nColumns in phone and all categories for low cardinality columns :\nCompany_name : Samsung Electronics Co Ltd, Huawei Technologies Co.Ltd., HTC Corporation, Nokia Corporation, LG Electronics, Sony Mobile Communications\nHardware_Model_name : GT-I9300, U8815 Asura, Lumia 920, Lumia 820, Lumia 620, GT-I9100, Nokia 700, LG-P760, Z520e, XPERIA T, XPERIA J\nAccreditation_type : Provisional, Full\nAccreditation_level : joyn Hot Fixes, joyn\nDate : Approved (valid until 03.05.13), Approved (valid until 06.04.13), Approved (awarded 19.11.12), Approved (awarded 05.12.12), Approved (valid until 14.09.13), Approved (awarded 23.10.12), Approved (awarded 15.11.12)\nchip_model : X50 Advanced, X5, X3i, X51v, X30 low-end, X50 Standard\nscreen_mode : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE \"Movie\" (\n\t\"mID\" INTEGER, \n\ttitle TEXT, \n\tyear INTEGER, \n\tdirector TEXT, \n\tPRIMARY KEY (\"mID\")\n)\n/*\nColumns in Movie and all categories for low cardinality columns :\nmID : 108, 106, 103, 102, 101, 104, 107, 105\ntitle : Avatar, Raiders of the Lost Ark, Titanic, E.T., Gone with the Wind, Snow White, Star Wars, The Sound of Music\nyear : 1937, 2009, 1982, 1997, 1939, 1965, 1981, 1977\ndirector : Robert Wise, James Cameron, George Lucas, Victor Fleming, Steven Spielberg, None\n*/\n \nCREATE TABLE \"Tryout\" (\n\t\"pID\" NUMERIC(5, 0), \n\t\"cName\" VARCHAR(20), \n\t\"pPos\" VARCHAR(8), \n\tdecision VARCHAR(3), \n\tPRIMARY KEY (\"pID\", \"cName\"), \n\tFOREIGN KEY(\"pID\") REFERENCES \"Player\" (\"pID\"), \n\tFOREIGN KEY(\"cName\") REFERENCES \"College\" (\"cName\")\n)\n/*\nColumns in Tryout and all categories for low cardinality columns :\npID : 20002, 40004, 50005, 30003, 10001\ncName : FSU, OU, ASU, LSU\npPos : striker, goalie, mid\ndecision : yes, no\n*/\n \nCREATE TABLE music_festival (\n\t\"ID\" INTEGER, \n\t\"Music_Festival\" TEXT, \n\t\"Date_of_ceremony\" TEXT, \n\t\"Category\" TEXT, \n\t\"Volume\" INTEGER, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tFOREIGN KEY(\"Volume\") REFERENCES volume (\"Volume_ID\")\n)\n/*\nColumns in music_festival and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nMusic_Festival : 34th Japan Academy Prize, 35th China Academy Prize, 37th Canadian Academy Prize, 40th Japan Academy Prize, 34th USA Academy Prize, 34th England Academy Prize, 37th Sweden Academy Prize, 36th Japan Academy Prize, 34th European Academy Prize\nDate_of_ceremony : 18 February 2011\nCategory : Best Sound Song, Best Song, Best Lyrics\nVolume : 1, 2, 5, 7, 8, 4, 6, 3, 9\nResult : Nominated, Awarded\n*/\n \nCREATE TABLE \"MediaType\" (\n\t\"MediaTypeId\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(120) DEFAULT NULL, \n\tPRIMARY KEY (\"MediaTypeId\")\n)\n/*\nColumns in MediaType and all categories for low cardinality columns :\nMediaTypeId : 1, 2, 5, 4, 3\nName : Protected AAC audio file, Protected MPEG-4 video file, Purchased AAC audio file, AAC audio file, MPEG audio file\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tcolor_code VARCHAR(15) NOT NULL, \n\tproduct_category_code VARCHAR(15) NOT NULL, \n\tproduct_name VARCHAR(80), \n\ttypical_buying_price VARCHAR(20), \n\ttypical_selling_price VARCHAR(20), \n\tproduct_description VARCHAR(255), \n\tother_product_details VARCHAR(255), \n\tPRIMARY KEY (product_id), \n\tFOREIGN KEY(color_code) REFERENCES \"Ref_Colors\" (color_code), \n\tFOREIGN KEY(product_category_code) REFERENCES \"Ref_Product_Categories\" (product_category_code)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nproduct_name : peper, cumin, chili\ntypical_buying_price : , 5.578, 503.8431967\ntypical_selling_price : , 149, 10377614.847385\nproduct_description : ut, et, vel\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\ncolor_code : 1, 2, 5, 7, 4, 9\nproduct_category_code : Spices, Seeds, Herbs\nother_product_details : None\n*/\n \nCREATE TABLE \"Draft_Copies\" (\n\tdocument_id INTEGER NOT NULL, \n\tdraft_number INTEGER NOT NULL, \n\tcopy_number INTEGER NOT NULL, \n\tPRIMARY KEY (document_id, draft_number, copy_number), \n\tFOREIGN KEY(document_id, draft_number) REFERENCES \"Document_Drafts\" (document_id, draft_number)\n)\n/*\nColumns in Draft_Copies and all categories for low cardinality columns :\ndocument_id : 1, 20, 2, 23, 4, 12, 10\ndraft_number : 1, 20, 2, 8, 17, 12, 9\ncopy_number : 5, 15, 4, 6, 10\n*/\n \nCREATE TABLE musical (\n\t\"Musical_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Year\" INTEGER, \n\t\"Award\" TEXT, \n\t\"Category\" TEXT, \n\t\"Nominee\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"Musical_ID\")\n)\n/*\nColumns in musical and all categories for low cardinality columns :\nMusical_ID : 1, 2, 5, 7, 4, 6, 3\nName : The Book of Mormon, Les Misérables, Rent, Chicago, West Side Story, The Phantom of the Opera, Wicked\nYear : 1986\nAward : Drama Desk Award, Tony Award\nCategory : Outstanding Director of a Musical, Best Direction of a Musical, Best Choreography, Best Performance by a Leading Actor in a Musical, Outstanding Choreography, Best Book of a Musical, Outstanding Actor in a Musical\nNominee : Bob Fosse, Cleavant Derricks\nResult : Nominated, Won\n*/\n \nCREATE TABLE mountain (\n\t\"Mountain_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Prominence\" REAL, \n\t\"Range\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (\"Mountain_ID\")\n)\n/*\nColumns in mountain and all categories for low cardinality columns :\nMountain_ID : 1, 2, 5, 7, 4, 6, 3\nName : Ngaliema / Mt Stanley (Margherita Pk), Mount Kenya (Lenana), Kibo (Uhuru Pk), Ngaliema / Mt Stanley (Savoia Pk), Mount Kenya (Batian), Duwoni / Mt Speke (Vittorio Emanuele Pk), Mawenzi (Hans Meyer Pk)\nHeight : 5109.0, 5199.0, 5895.0, 4890.0, 4985.0, 4977.0, 5148.0\nProminence : 720.0, 850.0, 3951.0, 3825.0, 130.0, 5885.0, 110.0\nRange : Kilimanjaro, Mount Kenya, Rwenzori\nCountry : DR Congo Uganda, Uganda, Tanzania, Kenya\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Reservations\" (\n\t\"Code\" INTEGER, \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\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Room\") REFERENCES \"Rooms\" (\"RoomId\")\n)\n/*\nColumns in Reservations and 3 examples in each column for high cardinality columns :\nCode : 38017, 23850, 20991\nCheckIn : 25-SEP-10, 14-DEC-10, 15-JUN-10\nCheckOut : 19-JAN-10, 09-MAY-10, 06-MAY-10\nRate : 287.5, 115.0, 218.75\nLastName : ESPINO, ECKERT, NORSWORTHY\nFirstName : JEFFEREY, ALLEN, ELVINA\n*/\n/*\nColumns in Reservations and all categories for low cardinality columns :\nRoom : IBD, IBS, RTE, CAS, FNA, HBB, AOB, MWC, TAA, RND\nAdults : 1, 2, 4, 3\nKids : 1, 2, 3, 0\n*/\n \nCREATE TABLE camera_lens (\n\tid INTEGER, \n\tbrand TEXT, \n\tname TEXT, \n\tfocal_length_mm REAL, \n\tmax_aperture REAL, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in camera_lens and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\nname : Panasonic Leica DG Summilux 25mm f /1.4 Asph., Sigma 19mm f2.8 EX DN, Sigma 30mm f2.8 DN\n*/\n/*\nColumns in camera_lens and all categories for low cardinality columns :\nbrand : Sigma, Olympus, Panasonic, Schneider Kreuznach\nfocal_length_mm : 45.0, 30.0, 15.0, 25.0, 150.0, 19.0, 14.0, 42.5, 75.0\nmax_aperture : 1.2, 8.0, 1.4, 2.0, 1.8, 2.8\n*/\n \nCREATE TABLE route (\n\ttrain_id INTEGER, \n\tstation_id INTEGER, \n\tPRIMARY KEY (train_id, station_id), \n\tFOREIGN KEY(station_id) REFERENCES station (id), \n\tFOREIGN KEY(train_id) REFERENCES train (id)\n)\n/*\nColumns in route and all categories for low cardinality columns :\ntrain_id : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nstation_id : 1, 2, 5, 7, 8, 4, 6, 3, 9\n*/\n \nCREATE TABLE tracks (\n\tid INTEGER, \n\tname VARCHAR(200) NOT NULL, \n\talbum_id INTEGER, \n\tmedia_type_id INTEGER NOT NULL, \n\tgenre_id INTEGER, \n\tcomposer VARCHAR(220), \n\tmilliseconds INTEGER NOT NULL, \n\tbytes INTEGER, \n\tunit_price NUMERIC(10, 2) NOT NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(album_id) REFERENCES albums (id), \n\tFOREIGN KEY(genre_id) REFERENCES genres (id), \n\tFOREIGN KEY(media_type_id) REFERENCES media_types (id)\n)\n/*\nColumns in tracks and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\nname : Snoopy's search-Red baron, The Winner Loses, Leave My Girl Alone\nalbum_id : 17, 9, 16\ncomposer : Ned Fairchild, Tony Iommi, Bill Ward, Geezer Butler, Ozzy Osbourne, Berry Gordy, Jr./Janie Bradford\nmilliseconds : 263497, 307617, 204721\nbytes : 6859518, 2301989, 6420530\n*/\n/*\nColumns in tracks and all categories for low cardinality columns :\nmedia_type_id : 1, 2\ngenre_id : 1, 2, 5, 4, 6, 3\nunit_price : 0.99\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE representative (\n\t\"Representative_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"State\" TEXT, \n\t\"Party\" TEXT, \n\t\"Lifespan\" TEXT, \n\tPRIMARY KEY (\"Representative_ID\")\n)\n/*\nColumns in representative and all categories for low cardinality columns :\nRepresentative_ID : 1, 2, 5, 7, 4, 6, 3\nName : Dan Quayle, James M. Quigley, Al Quie, James L. Quinn, Jack Quinn, John Quayle, Jimmy Quillen\nState : Pennsylvania, Tennessee, New York, Indiana, Minnesota\nParty : Democratic, Republican\nLifespan : 1947–, 1923–, 1916–2003, 1868–1930, 1951–, 1875–1960, 1918–\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE event (\n\t\"ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Stadium_ID\" INTEGER, \n\t\"Year\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tFOREIGN KEY(\"Stadium_ID\") REFERENCES stadium (\"ID\")\n)\n/*\nColumns in event and all categories for low cardinality columns :\nID : 1, 2, 5, 4, 6, 3\nName : Pacific, European FINA, FINA, World Master, IPC, World Junior\nStadium_ID : 1, 2, 8, 4, 3, 10\nYear : 2016, 2013, 2012, 2017, 2011, 2014\n*/\n" }, { "role": "user", "content": "Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department, management.\nFrom these tables, I'll be using the following columns: department.name, department.num_employees, department.department_id, management.department_id, management.temporary_acting.\nThe SQL query I'll be generating is:\nSELECT T1.name , T1.num_employees FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id WHERE T2.temporary_acting = 'Yes'" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE party (\n\t\"Party_ID\" INTEGER, \n\t\"Year\" REAL, \n\t\"Party\" TEXT, \n\t\"Governor\" TEXT, \n\t\"Lieutenant_Governor\" TEXT, \n\t\"Comptroller\" TEXT, \n\t\"Attorney_General\" TEXT, \n\t\"US_Senate\" TEXT, \n\tPRIMARY KEY (\"Party_ID\")\n)\n/*\nColumns in party and all categories for low cardinality columns :\nParty_ID : 1, 2, 5, 7, 4, 6, 3\nYear : 2002.0, 2006.0, 1998.0\nParty : Working Families, Democratic, Independence, Liberal\nGovernor : Betsy McCaughey Ross, Tom Golisano, Peter Vallone, Carl McCall, Eliot Spitzer\nLieutenant_Governor : Sandra Frankel, Mary Donohue, Dennis Mehiel, David Paterson, Jonathan Reiter\nComptroller : Carl McCall, Alan Hevesi, John Faso\nAttorney_General : Eliot Spitzer, Andrew Cuomo, Jeanine Pirro\nUS_Senate : Hillary Rodham Clinton, Charles Schumer, (no election)\n*/\n \nCREATE TABLE \"Part_Faults\" (\n\tpart_fault_id INTEGER, \n\tpart_id INTEGER NOT NULL, \n\tfault_short_name VARCHAR(20), \n\tfault_description VARCHAR(255), \n\tother_fault_details VARCHAR(255), \n\tPRIMARY KEY (part_fault_id), \n\tFOREIGN KEY(part_id) REFERENCES \"Parts\" (part_id)\n)\n/*\nColumns in Part_Faults and 3 examples in each column for high cardinality columns :\npart_fault_id : 1, 13, 11\n*/\n/*\nColumns in Part_Faults and all categories for low cardinality columns :\npart_id : 1, 2, 3\nfault_short_name : PW, TW, MW\nfault_description : Medium Scale Wrong, Top Parts Wrong, Package Wrong\nother_fault_details : None\n*/\n \nCREATE TABLE \"Ship\" (\n\t\"Ship_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Type\" TEXT, \n\t\"Built_Year\" REAL, \n\t\"Class\" TEXT, \n\t\"Flag\" TEXT, \n\tPRIMARY KEY (\"Ship_ID\")\n)\n/*\nColumns in Ship and all categories for low cardinality columns :\nShip_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : HMS Trojan, HMS Destiny, HMS Phalarope, HMS Undine, HMS Manxman, HM Cutter Avenger, HM Sloop Sparrow, HM Schooner Hotspur, HMS Gorgon\nType : Panamax\nBuilt_Year : 1997.0, 1998.0\nClass : GL, KR\nFlag : Panama, Malta\n*/\n \nCREATE TABLE \"Tryout\" (\n\t\"pID\" NUMERIC(5, 0), \n\t\"cName\" VARCHAR(20), \n\t\"pPos\" VARCHAR(8), \n\tdecision VARCHAR(3), \n\tPRIMARY KEY (\"pID\", \"cName\"), \n\tFOREIGN KEY(\"pID\") REFERENCES \"Player\" (\"pID\"), \n\tFOREIGN KEY(\"cName\") REFERENCES \"College\" (\"cName\")\n)\n/*\nColumns in Tryout and all categories for low cardinality columns :\npID : 20002, 40004, 50005, 30003, 10001\ncName : FSU, OU, ASU, LSU\npPos : striker, goalie, mid\ndecision : yes, no\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Birth_Date\" TEXT, \n\t\"Birth_Place\" TEXT, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and all categories for low cardinality columns :\nPeople_ID : 1, 2, 5, 4, 6, 3\nName : Ty Conklin, Jake Gardiner, Al Montoya, Mark Fayne, Jack Campbell, Cam Fowler\nHeight : 215.0, 182.0, 195.0, 205.0, 192.0, 196.0\nWeight : 89.0, 100.0, 90.0, 102.0, 80.0, 92.0\nBirth_Date : December 5, 1991, May 5, 1987, July 4, 1990, February 13, 1985, March 30, 1976, January 1, 1992\nBirth_Place : Farmington Hills, Michigan, Anchorage, Alaska, Glenview, Illinois, Nashua, New Hampshire, Minnetonka, Minnesota, Port Huron, Michigan\n*/\n \nCREATE TABLE \"Settlements\" (\n\t\"Settlement_ID\" INTEGER NOT NULL, \n\t\"Claim_ID\" INTEGER NOT NULL, \n\t\"Date_Claim_Made\" DATE, \n\t\"Date_Claim_Settled\" DATE, \n\t\"Amount_Claimed\" INTEGER, \n\t\"Amount_Settled\" INTEGER, \n\t\"Customer_Policy_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Settlement_ID\"), \n\tFOREIGN KEY(\"Claim_ID\") REFERENCES \"Claims\" (\"Claim_ID\")\n)\n/*\nColumns in Settlements and 3 examples in each column for high cardinality columns :\nSettlement_ID : 756, 616, 527\nDate_Claim_Made : 2017-05-19, 2016-09-05, 2018-05-12\nDate_Claim_Settled : 2017-12-24, 2017-11-15, 2018-02-20\nAmount_Claimed : 37302, 20569, 25078\nAmount_Settled : 1676, 1181, 930\nCustomer_Policy_ID : 943, 839, 590\n*/\n/*\nColumns in Settlements and all categories for low cardinality columns :\nClaim_ID : 843, 563, 801, 957, 761, 621, 486, 571, 569\n*/\n \nCREATE TABLE club (\n\t\"Club_ID\" INTEGER, \n\t\"Club_name\" TEXT, \n\t\"Region\" TEXT, \n\t\"Start_year\" INTEGER, \n\tPRIMARY KEY (\"Club_ID\")\n)\n/*\nColumns in club and all categories for low cardinality columns :\nClub_ID : 1, 2, 5, 4, 6, 3\nClub_name : BK Häcken, Helsingborgs IF, Djurgårdens IF, Gefle IF, Halmstads BK, AIK\nRegion : Korea, UK, France, Russia, USA\nStart_year : 2009, 2001, 2005, 2000, 1998, 2011\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE region (\n\t\"Region_ID\" INTEGER, \n\t\"Region_name\" TEXT, \n\t\"Date\" TEXT, \n\t\"Label\" TEXT, \n\t\"Format\" TEXT, \n\t\"Catalogue\" TEXT, \n\tPRIMARY KEY (\"Region_ID\")\n)\n/*\nColumns in region and all categories for low cardinality columns :\nRegion_ID : 1, 2, 5, 4, 3\nRegion_name : Japan, United Kingdom, United States\nDate : 1 July 2002, 16 July 2002, 3 July 2002\nLabel : Toshiba-EMI, Astralwerks, Parlophone\nFormat : CD digipak, 2× LP, CD\nCatalogue : ASW 40362, ASW 40522, 539 9821, TOCP-66045, 540 3622\n*/\n \nCREATE TABLE \"Grants\" (\n\tgrant_id INTEGER, \n\torganisation_id INTEGER NOT NULL, \n\tgrant_amount DECIMAL(19, 4) DEFAULT 0 NOT NULL, \n\tgrant_start_date DATETIME NOT NULL, \n\tgrant_end_date DATETIME NOT NULL, \n\tother_details VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (grant_id), \n\tFOREIGN KEY(organisation_id) REFERENCES \"Organisations\" (organisation_id)\n)\n/*\nColumns in Grants and 3 examples in each column for high cardinality columns :\ngrant_id : 1, 13, 11\ngrant_amount : 24.7000, 1.9848, 0.0000\ngrant_start_date : 2016-11-20 00:18:51, 2011-05-10 22:44:08, 2015-12-14 13:02:11\ngrant_end_date : 2004-10-24 09:09:39, 1982-03-11 15:27:55, 2001-05-22 21:02:43\nother_details : aliquam, occaecati, qui\n*/\n/*\nColumns in Grants and all categories for low cardinality columns :\norganisation_id : 11, 2, 5, 7, 8, 14, 3, 12, 10, 9\n*/\n \nCREATE TABLE races (\n\t\"raceId\" INTEGER, \n\tyear INTEGER, \n\tround INTEGER, \n\t\"circuitId\" INTEGER, \n\tname TEXT, \n\tdate TEXT, \n\ttime TEXT, \n\turl TEXT, \n\tPRIMARY KEY (\"raceId\"), \n\tFOREIGN KEY(\"circuitId\") REFERENCES circuits (\"circuitId\")\n)\n/*\nColumns in races and 3 examples in each column for high cardinality columns :\nraceId : 87, 56, 65\nyear : 2004, 2009, 2001\nround : 17, 9, 16\ncircuitId : 19, 17, 21\nname : Turkish Grand Prix, Chinese Grand Prix, Belgian Grand Prix\ndate : 2009-07-12, 2008-05-11, 2005-04-03\ntime : , 16:00:00, 09:00:00\nurl : http://en.wikipedia.org/wiki/2004_Spanish_Grand_Prix, http://en.wikipedia.org/wiki/2000_San_Marino_Grand_Prix, http://en.wikipedia.org/wiki/1999_Austrian_Grand_Prix\n*/\n\n \nCREATE TABLE driver (\n\t\"Driver_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Party\" TEXT, \n\t\"Home_city\" TEXT, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (\"Driver_ID\")\n)\n/*\nColumns in driver and 3 examples in each column for high cardinality columns :\nDriver_ID : 1, 11, 2\nName : Edwin Vargas, Henry Genga, Douglas McCrory\n*/\n/*\nColumns in driver and all categories for low cardinality columns :\nParty : Rep, Dem\nHome_city : Coventry, East Hartford, Hartford, Bethel, Manchester\nAge : 38, 45, 46, 37, 40, 36, 30, 52, 42, 35\n*/\n \nCREATE TABLE prereq (\n\tcourse_id VARCHAR(8), \n\tprereq_id VARCHAR(8), \n\tPRIMARY KEY (course_id, prereq_id), \n\tFOREIGN KEY(course_id) REFERENCES course (course_id), \n\tFOREIGN KEY(prereq_id) REFERENCES course (course_id)\n)\n/*\nColumns in prereq and 3 examples in each column for high cardinality columns :\ncourse_id : 241, 586, 628\nprereq_id : 304, 628, 927\n*/\n\n \nCREATE TABLE protein (\n\tcommon_name TEXT, \n\tprotein_name TEXT, \n\tdivergence_from_human_lineage REAL, \n\taccession_number TEXT, \n\tsequence_length REAL, \n\tsequence_identity_to_human_protein TEXT, \n\t\"Institution_id\" TEXT, \n\tPRIMARY KEY (common_name), \n\tFOREIGN KEY(\"Institution_id\") REFERENCES \"Institution\" (\"Institution_id\")\n)\n/*\nColumns in protein and all categories for low cardinality columns :\ncommon_name : Tropical Clawed Frog, porkworm, body louse, southern house mosquito, purple sea urchin\nprotein_name : uncharacterized protein LOC578090, conserved hypothetical protein, Centromeric protein E, putative, surface antigen repeat family protein, uncharacterized protein C20orf117-like\ndivergence_from_human_lineage : 937.5, 742.9, 782.7, 371.2\naccession_number : XP_003380263.1, XP_002942331.1, XP_783370.2, XP_002429877.1, XP_001843754.1\nsequence_length : 2030.0, 1587.0, 2086.0, 1584.0, 1878.0\nsequence_identity_to_human_protein : 30%, 47%, 36%, 39%, 32%\nInstitution_id : 1, 5, 9, 3\n*/\n \nCREATE TABLE wedding (\n\t\"Church_ID\" INTEGER, \n\t\"Male_ID\" INTEGER, \n\t\"Female_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Church_ID\", \"Male_ID\", \"Female_ID\"), \n\tFOREIGN KEY(\"Female_ID\") REFERENCES people (\"People_ID\"), \n\tFOREIGN KEY(\"Male_ID\") REFERENCES people (\"People_ID\"), \n\tFOREIGN KEY(\"Church_ID\") REFERENCES church (\"Church_ID\")\n)\n/*\nColumns in wedding and all categories for low cardinality columns :\nChurch_ID : 1, 4, 5, 3\nMale_ID : 1, 7, 5, 3\nFemale_ID : 8, 2, 4, 6\nYear : 2015, 2016, 2014\n*/\n \nCREATE TABLE \"Country\" (\n\tid INTEGER, \n\tname TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Country and 3 examples in each column for high cardinality columns :\nid : 1, 19694, 7809\nname : Scotland, Italy, Spain\n*/\n\n \nCREATE TABLE airports (\n\tapid INTEGER, \n\tname TEXT NOT NULL, \n\tcity TEXT, \n\tcountry TEXT, \n\tx REAL, \n\ty REAL, \n\televation BIGINT, \n\tiata TEXT(3), \n\ticao TEXT(4), \n\tPRIMARY KEY (apid)\n)\n/*\nColumns in airports and 3 examples in each column for high cardinality columns :\napid : 87, 56, 65\nname : Rouyn Noranda Airport, Edmonton International Airport, Val-d'Or Airport\ncity : Medicine Hat, Sarnia, Fort Saint John\nx : -117.4469985961914, -122.054000854, -135.067001343\ny : 45.5175018311, 50.29029846191406, 47.697400654599996\nelevation : 87, 586, 56\niata : NULL, YYE, YXJ\nicao : CYXD, CYBK, CYMO\n*/\n/*\nColumns in airports and all categories for low cardinality columns :\ncountry : Iceland, Papua New Guinea, Greenland, Canada\n*/\n \nCREATE TABLE \"Visitors\" (\n\t\"Tourist_ID\" INTEGER NOT NULL, \n\t\"Tourist_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Tourist_ID\"), \n\tUNIQUE (\"Tourist_ID\")\n)\n/*\nColumns in Visitors and 3 examples in each column for high cardinality columns :\nTourist_ID : 241, 377, 779\nTourist_Details : Aleen, Lizzie, Vivian\n*/\n\n" }, { "role": "user", "content": "How many acting statuses are there?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: management.\nFrom these tables, I'll be using the following columns: temporary_acting.\nThe SQL query I'll be generating is:\nSELECT count(DISTINCT temporary_acting) FROM management" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE \"pitStops\" (\n\t\"raceId\" INTEGER, \n\t\"driverId\" INTEGER, \n\tstop INTEGER, \n\tlap INTEGER, \n\ttime TEXT, \n\tduration TEXT, \n\tmilliseconds INTEGER, \n\tPRIMARY KEY (\"raceId\", \"driverId\", stop), \n\tFOREIGN KEY(\"raceId\") REFERENCES races (\"raceId\"), \n\tFOREIGN KEY(\"driverId\") REFERENCES drivers (\"driverId\")\n)\n/*\nColumns in pitStops and all categories for low cardinality columns :\nraceId : \ndriverId : \nstop : \nlap : \ntime : \nduration : \nmilliseconds : \n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Inst\" (\n\t\"instID\" INTEGER, \n\tname TEXT, \n\tcountry TEXT, \n\tPRIMARY KEY (\"instID\")\n)\n/*\nColumns in Inst and all categories for low cardinality columns :\ninstID : 1060, 1010, 1000, 1040, 1050, 1030, 1020, 1070\nname : Northeastern University, INRIA, University of Oxford, Indiana University, Tohoku University, University of Pennsylvania, Portland State University, Google\ncountry : Japan, UK, USA, France\n*/\n \nCREATE TABLE \"Bookings\" (\n\tbooking_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tbooking_status_code VARCHAR(10) NOT NULL, \n\treturned_damaged_yn VARCHAR(40), \n\tbooking_start_date DATETIME, \n\tbooking_end_date DATETIME, \n\tcount_hired VARCHAR(40), \n\tamount_payable DECIMAL(19, 4), \n\tamount_of_discount DECIMAL(19, 4), \n\tamount_outstanding DECIMAL(19, 4), \n\tamount_of_refund DECIMAL(19, 4), \n\tPRIMARY KEY (booking_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Bookings and 3 examples in each column for high cardinality columns :\nbooking_id : 1, 13, 11\nbooking_start_date : 2016-04-25 11:04:18, 2016-11-06 20:54:26, 2017-04-28 08:35:56\nbooking_end_date : 2018-03-04 21:42:45, 2018-02-19 21:53:31, 2017-10-02 07:28:09\ncount_hired : 843, 298, 236\namount_payable : 214.3900, 306.2600, 386.9200\namount_of_discount : 48.7300, 61.5500, 45.0600\namount_outstanding : 26.0400, 66.0100, 93.8800\namount_of_refund : 135.9400, 126.1000, 124.9500\n*/\n/*\nColumns in Bookings and all categories for low cardinality columns :\ncustomer_id : 11, 10, 7, 8, 3, 15, 9\nbooking_status_code : Provisional, Confirmed\nreturned_damaged_yn : 1, 0\n*/\n \nCREATE TABLE \"Elimination\" (\n\t\"Elimination_ID\" TEXT, \n\t\"Wrestler_ID\" TEXT, \n\t\"Team\" TEXT, \n\t\"Eliminated_By\" TEXT, \n\t\"Elimination_Move\" TEXT, \n\t\"Time\" TEXT, \n\tPRIMARY KEY (\"Elimination_ID\"), \n\tFOREIGN KEY(\"Wrestler_ID\") REFERENCES wrestler (\"Wrestler_ID\")\n)\n/*\nColumns in Elimination and all categories for low cardinality columns :\nElimination_ID : 1, 2, 5, 4, 6, 3\nWrestler_ID : 1, 2, 5, 7, 4, 9\nTeam : Team Orton, Team Batista\nEliminated_By : Punk, Henry, Benjamin, Orton, Batista, Rhodes\nElimination_Move : Spear, World's Strongest Slam, Silver Spoon DDT, Rope hung DDT, Paydirt, Go To Sleep\nTime : 13:06, 14:22, 07:38, 14:32, 00:11, 10:45\n*/\n \nCREATE TABLE chip_model (\n\t\"Model_name\" TEXT, \n\t\"Launch_year\" REAL, \n\t\"RAM_MiB\" REAL, \n\t\"ROM_MiB\" REAL, \n\t\"Slots\" TEXT, \n\t\"WiFi\" TEXT, \n\t\"Bluetooth\" TEXT, \n\tPRIMARY KEY (\"Model_name\")\n)\n/*\nColumns in chip_model and 3 examples in each column for high cardinality columns :\nModel_name : X30 mid-range, X50 Advanced, X51 mid-range\n*/\n/*\nColumns in chip_model and all categories for low cardinality columns :\nLaunch_year : 2002.0, 2005.0, 2004.0, 2003.0\nRAM_MiB : 32.0, 64.0\nROM_MiB : 48.0, 256.0, 128.0, 32.0, 64.0\nSlots : 1CFII,1SD, 1SD\nWiFi : 802.11b, No\nBluetooth : 1.2, Yes, No, 1.1\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Birth_Date\" TEXT, \n\t\"Birth_Place\" TEXT, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and all categories for low cardinality columns :\nPeople_ID : 1, 2, 5, 4, 6, 3\nName : Ty Conklin, Jake Gardiner, Al Montoya, Mark Fayne, Jack Campbell, Cam Fowler\nHeight : 215.0, 182.0, 195.0, 205.0, 192.0, 196.0\nWeight : 89.0, 100.0, 90.0, 102.0, 80.0, 92.0\nBirth_Date : December 5, 1991, May 5, 1987, July 4, 1990, February 13, 1985, March 30, 1976, January 1, 1992\nBirth_Place : Farmington Hills, Michigan, Anchorage, Alaska, Glenview, Illinois, Nashua, New Hampshire, Minnetonka, Minnesota, Port Huron, Michigan\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Birth_Date\" TEXT, \n\t\"Birth_Place\" TEXT, \n\tPRIMARY KEY (\"People_ID\")\n)\n/*\nColumns in people and all categories for low cardinality columns :\nPeople_ID : 1, 2, 5, 4, 6, 3\nName : Ty Conklin, Jake Gardiner, Al Montoya, Mark Fayne, Jack Campbell, Cam Fowler\nHeight : 215.0, 182.0, 195.0, 205.0, 192.0, 196.0\nWeight : 89.0, 100.0, 90.0, 102.0, 80.0, 92.0\nBirth_Date : December 5, 1991, May 5, 1987, July 4, 1990, February 13, 1985, March 30, 1976, January 1, 1992\nBirth_Place : Farmington Hills, Michigan, Anchorage, Alaska, Glenview, Illinois, Nashua, New Hampshire, Minnetonka, Minnesota, Port Huron, Michigan\n*/\n \nCREATE TABLE airlines (\n\talid INTEGER, \n\tname TEXT, \n\tiata VARCHAR(2), \n\ticao VARCHAR(3), \n\tcallsign TEXT, \n\tcountry TEXT, \n\tactive VARCHAR(2), \n\tPRIMARY KEY (alid)\n)\n/*\nColumns in airlines and 3 examples in each column for high cardinality columns :\nalid : 87, 56, 65\nname : Arab Agricultural Aviation Company, Avion Taxi, Amadeus Global Travel Distribution\niata : , U3, JP\nicao : , ADP, UVS\ncallsign : , ALGOMA, SECUREX\ncountry : , Afghanistan, Gabon\n*/\n/*\nColumns in airlines and all categories for low cardinality columns :\nactive : Y, N\n*/\n \nCREATE TABLE mountain (\n\t\"Mountain_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Prominence\" REAL, \n\t\"Range\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (\"Mountain_ID\")\n)\n/*\nColumns in mountain and all categories for low cardinality columns :\nMountain_ID : 1, 2, 5, 7, 4, 6, 3\nName : Ngaliema / Mt Stanley (Margherita Pk), Mount Kenya (Lenana), Kibo (Uhuru Pk), Ngaliema / Mt Stanley (Savoia Pk), Mount Kenya (Batian), Duwoni / Mt Speke (Vittorio Emanuele Pk), Mawenzi (Hans Meyer Pk)\nHeight : 5109.0, 5199.0, 5895.0, 4890.0, 4985.0, 4977.0, 5148.0\nProminence : 720.0, 850.0, 3951.0, 3825.0, 130.0, 5885.0, 110.0\nRange : Kilimanjaro, Mount Kenya, Rwenzori\nCountry : DR Congo Uganda, Uganda, Tanzania, Kenya\n*/\n \nCREATE TABLE customers (\n\tid INTEGER, \n\tfirst_name VARCHAR(40) NOT NULL, \n\tlast_name VARCHAR(20) NOT NULL, \n\tcompany VARCHAR(80), \n\taddress VARCHAR(70), \n\tcity VARCHAR(40), \n\tstate VARCHAR(40), \n\tcountry VARCHAR(40), \n\tpostal_code VARCHAR(10), \n\tphone VARCHAR(24), \n\tfax VARCHAR(24), \n\temail VARCHAR(60) NOT NULL, \n\tsupport_rep_id INTEGER, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(support_rep_id) REFERENCES employees (id)\n)\n/*\nColumns in customers and 3 examples in each column for high cardinality columns :\nid : 53, 56, 49\nfirst_name : Astrid, Emma, Fynn\nlast_name : Sullivan, Schneider, Mercier\ncompany : Apple Inc., Microsoft Corporation, Rogers Canada\naddress : 696 Osborne Street, 796 Dundas Street West, Grétrystraat 63\ncity : Oslo, Lisbon, Mountain View\nstate : AZ, NSW, Dublin\ncountry : Sweden, Australia, India\npostal_code : 85719, B3S 1C5, 1106\nphone : +1 (801) 531-7272, +49 030 26550280, +33 05 56 96 96 96\nfax : +1 (212) 221-4679, +55 (12) 3923-5566, +1 (650) 253-0000\nemail : mphilips12@shaw.ca, luisg@embraer.com.br, marc.dubois@hotmail.com\n*/\n/*\nColumns in customers and all categories for low cardinality columns :\nsupport_rep_id : 4, 5, 3\n*/\n \nCREATE TABLE \"Apartment_Buildings\" (\n\tbuilding_id INTEGER NOT NULL, \n\tbuilding_short_name CHAR(15), \n\tbuilding_full_name VARCHAR(80), \n\tbuilding_description VARCHAR(255), \n\tbuilding_address VARCHAR(255), \n\tbuilding_manager VARCHAR(50), \n\tbuilding_phone VARCHAR(80), \n\tPRIMARY KEY (building_id), \n\tUNIQUE (building_id)\n)\n/*\nColumns in Apartment_Buildings and 3 examples in each column for high cardinality columns :\nbuilding_id : 153, 734, 556\nbuilding_short_name : VIA 57 WEST, Petersfield, The Clinton\nbuilding_full_name : VIA 57 WEST, Petersfield, The Clinton\nbuilding_address : 012 Arnoldo Mountain\nGerholdland, ID 23342, 489 Josh Orchard Apt. 998\nSipesview, DE 69053, 601 Graham Roads\nPort Luz, VA 29660-6703\nbuilding_manager : Kyle, Emma, Kathlyn\nbuilding_phone : (948)040-1064x387, 1-724-982-9507x640, 544-148-5565x2847\n*/\n/*\nColumns in Apartment_Buildings and all categories for low cardinality columns :\nbuilding_description : Studio, Flat, Duplex\n*/\n \nCREATE TABLE member_attendance (\n\t\"Member_ID\" INTEGER, \n\t\"Performance_ID\" INTEGER, \n\t\"Num_of_Pieces\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\", \"Performance_ID\"), \n\tFOREIGN KEY(\"Performance_ID\") REFERENCES performance (\"Performance_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in member_attendance and all categories for low cardinality columns :\nMember_ID : 1, 11, 2, 5, 7, 4, 3\nPerformance_ID : 1, 2, 4, 6, 3\nNum_of_Pieces : 1, 2, 4, 3\n*/\n \nCREATE TABLE \"Allergy_Type\" (\n\t\"Allergy\" VARCHAR(20), \n\t\"AllergyType\" VARCHAR(20), \n\tPRIMARY KEY (\"Allergy\")\n)\n/*\nColumns in Allergy_Type and 3 examples in each column for high cardinality columns :\nAllergy : Soy, Milk, Eggs\n*/\n/*\nColumns in Allergy_Type and all categories for low cardinality columns :\nAllergyType : food, animal, environmental\n*/\n \nCREATE TABLE country (\n\t\"Country_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Population\" INTEGER, \n\t\"Area\" INTEGER, \n\t\"Languages\" TEXT, \n\tPRIMARY KEY (\"Country_ID\")\n)\n/*\nColumns in country and all categories for low cardinality columns :\nCountry_ID : 1, 2, 3\nName : Austria, Sweden, Finland\nPopulation : 8206524, 9047752, 5261008\nArea : 83871, 338145, 449964\nLanguages : Swedish, Finnish Swedish, German\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n" }, { "role": "user", "content": "How many departments are led by heads who are not mentioned?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department, management.\nFrom these tables, I'll be using the following columns: department_id.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM department WHERE department_id NOT IN (SELECT department_id FROM management);" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE party_events (\n\t\"Event_ID\" INTEGER, \n\t\"Event_Name\" TEXT, \n\t\"Party_ID\" INTEGER, \n\t\"Member_in_charge_ID\" INTEGER, \n\tPRIMARY KEY (\"Event_ID\"), \n\tFOREIGN KEY(\"Member_in_charge_ID\") REFERENCES member (\"Member_ID\"), \n\tFOREIGN KEY(\"Party_ID\") REFERENCES party (\"Party_ID\")\n)\n/*\nColumns in party_events and all categories for low cardinality columns :\nEvent_ID : 1, 2, 5, 7, 8, 4, 6, 3\nEvent_Name : Election Meeting, Annaual Meeting, Conference, Budget Meeting\nParty_ID : 1, 2, 3\nMember_in_charge_ID : 11, 2, 15, 4, 12, 3, 10\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Detention\" (\n\tdetention_id INTEGER, \n\tdetention_type_code VARCHAR(10) NOT NULL, \n\tteacher_id INTEGER, \n\tdatetime_detention_start DATETIME, \n\tdatetime_detention_end DATETIME, \n\tdetention_summary VARCHAR(255), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (detention_id), \n\tFOREIGN KEY(teacher_id) REFERENCES \"Teachers\" (teacher_id), \n\tFOREIGN KEY(detention_type_code) REFERENCES \"Ref_Detention_Type\" (detention_type_code)\n)\n/*\nColumns in Detention and 3 examples in each column for high cardinality columns :\ndetention_id : 1, 13, 11\ndatetime_detention_start : 2017-09-05 00:38:25, 2018-01-29 20:43:45, 2017-08-25 12:00:46\ndatetime_detention_end : 2018-03-13 20:37:39, 2018-03-22 20:15:47, 2018-03-05 03:31:24\n*/\n/*\nColumns in Detention and all categories for low cardinality columns :\ndetention_type_code : LUNCH, AFTER, BREAK \nteacher_id : 11, 10, 5, 7, 8, 14, 3, 12, 15\ndetention_summary : None\nother_details : None\n*/\n \nCREATE TABLE \"Reservations\" (\n\t\"Code\" INTEGER, \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\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Room\") REFERENCES \"Rooms\" (\"RoomId\")\n)\n/*\nColumns in Reservations and 3 examples in each column for high cardinality columns :\nCode : 38017, 23850, 20991\nCheckIn : 25-SEP-10, 14-DEC-10, 15-JUN-10\nCheckOut : 19-JAN-10, 09-MAY-10, 06-MAY-10\nRate : 287.5, 115.0, 218.75\nLastName : ESPINO, ECKERT, NORSWORTHY\nFirstName : JEFFEREY, ALLEN, ELVINA\n*/\n/*\nColumns in Reservations and all categories for low cardinality columns :\nRoom : IBD, IBS, RTE, CAS, FNA, HBB, AOB, MWC, TAA, RND\nAdults : 1, 2, 4, 3\nKids : 1, 2, 3, 0\n*/\n \nCREATE TABLE \"Projects\" (\n\t\"Code\" CHAR(4), \n\t\"Name\" CHAR(50) NOT NULL, \n\t\"Hours\" INTEGER, \n\tPRIMARY KEY (\"Code\")\n)\n/*\nColumns in Projects and 3 examples in each column for high cardinality columns :\nCode : Bte2, AeH6, Ast3\nName : Aerodynamics of Air Hockey, Winds: Studying Bernoullis Principle, Aerodynamics and Gas Mileage\nHours : 321, 189, 89\n*/\n\n \nCREATE TABLE \"Voting_record\" (\n\t\"StuID\" INTEGER, \n\t\"Registration_Date\" VARCHAR(12), \n\t\"Election_Cycle\" VARCHAR(12), \n\t\"President_Vote\" INTEGER, \n\t\"Vice_President_Vote\" INTEGER, \n\t\"Secretary_Vote\" INTEGER, \n\t\"Treasurer_Vote\" INTEGER, \n\t\"Class_President_Vote\" INTEGER, \n\t\"Class_Senator_Vote\" INTEGER, \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"President_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Vice_President_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Secretary_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Treasurer_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Class_President_Vote\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Class_Senator_Vote\") REFERENCES \"Student\" (\"StuID\")\n)\n/*\nColumns in Voting_record and all categories for low cardinality columns :\nStuID : 1003, 1002, 1005, 1001, 1004\nRegistration_Date : 08/30/2014, 08/30/2015, 08/30/2013, 08/30/2012\nElection_Cycle : Fall, Spring\nPresident_Vote : 1014, 1024, 1004\nVice_President_Vote : 1007, 1017\nSecretary_Vote : 1030, 1010, 1020\nTreasurer_Vote : 1035, 1025\nClass_President_Vote : 1011, 1001, 1031, 1021\nClass_Senator_Vote : 1028, 1018\n*/\n \nCREATE TABLE \"Photos\" (\n\t\"Photo_ID\" INTEGER NOT NULL, \n\t\"Tourist_Attraction_ID\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(255), \n\t\"Description\" VARCHAR(255), \n\t\"Filename\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Photo_ID\"), \n\tFOREIGN KEY(\"Tourist_Attraction_ID\") REFERENCES \"Tourist_Attractions\" (\"Tourist_Attraction_ID\")\n)\n/*\nColumns in Photos and 3 examples in each column for high cardinality columns :\nPhoto_ID : 428, 303, 332\nTourist_Attraction_ID : 5076, 6523, 5265\nName : fun3, din2, park1\nFilename : 863, 695, 392\n*/\n/*\nColumns in Photos and all categories for low cardinality columns :\nDescription : None\nOther_Details : None\n*/\n \nCREATE TABLE station_company (\n\t\"Station_ID\" INTEGER, \n\t\"Company_ID\" INTEGER, \n\t\"Rank_of_the_Year\" INTEGER, \n\tPRIMARY KEY (\"Station_ID\", \"Company_ID\"), \n\tFOREIGN KEY(\"Company_ID\") REFERENCES company (\"Company_ID\"), \n\tFOREIGN KEY(\"Station_ID\") REFERENCES gas_station (\"Station_ID\")\n)\n/*\nColumns in station_company and all categories for low cardinality columns :\nStation_ID : 1, 11, 7, 4, 6, 10\nCompany_ID : 1, 6, 3, 10, 9\nRank_of_the_Year : 1, 13, 2, 4, 3, 9\n*/\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE representative (\n\t\"Representative_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"State\" TEXT, \n\t\"Party\" TEXT, \n\t\"Lifespan\" TEXT, \n\tPRIMARY KEY (\"Representative_ID\")\n)\n/*\nColumns in representative and all categories for low cardinality columns :\nRepresentative_ID : 1, 2, 5, 7, 4, 6, 3\nName : Dan Quayle, James M. Quigley, Al Quie, James L. Quinn, Jack Quinn, John Quayle, Jimmy Quillen\nState : Pennsylvania, Tennessee, New York, Indiana, Minnesota\nParty : Democratic, Republican\nLifespan : 1947–, 1923–, 1916–2003, 1868–1930, 1951–, 1875–1960, 1918–\n*/\n \nCREATE TABLE event (\n\t\"Event_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\t\"Event_Attendance\" INTEGER, \n\tPRIMARY KEY (\"Event_ID\")\n)\n/*\nColumns in event and all categories for low cardinality columns :\nEvent_ID : 1, 2, 5, 4, 3\nDate : 9 April 2014, 7 October 2010, 11 October 2007, 13 October 2008, 20 June 2018\nVenue : Motagua, Platense, Hispano, Victoria, Marathon\nName : Global Awarding, Public Debating, Special Exhibition, Government Hearing, Olympia Games Openning\nEvent_Attendance : 369, 1675, 2356, 6650, 225\n*/\n \nCREATE TABLE \"Apartment_Bookings\" (\n\tapt_booking_id INTEGER NOT NULL, \n\tapt_id INTEGER, \n\tguest_id INTEGER NOT NULL, \n\tbooking_status_code CHAR(15) NOT NULL, \n\tbooking_start_date DATETIME, \n\tbooking_end_date DATETIME, \n\tPRIMARY KEY (apt_booking_id), \n\tFOREIGN KEY(apt_id) REFERENCES \"Apartments\" (apt_id), \n\tFOREIGN KEY(guest_id) REFERENCES \"Guests\" (guest_id), \n\tUNIQUE (apt_booking_id)\n)\n/*\nColumns in Apartment_Bookings and 3 examples in each column for high cardinality columns :\napt_booking_id : 365, 577, 343\nbooking_start_date : 2017-07-03 14:15:56, 2017-03-04 02:23:49, 2016-06-07 05:05:18\nbooking_end_date : 2017-10-07 11:38:48, 2018-02-19 16:59:08, 2017-10-03 01:56:21\n*/\n/*\nColumns in Apartment_Bookings and all categories for low cardinality columns :\napt_id : 11, 2, 15, 7, 8, 4, 6, 12, 10, 9\nguest_id : 3, 13, 2, 5, 7, 8, 4, 12, 14, 15\nbooking_status_code : Provisional, Confirmed\n*/\n \nCREATE TABLE \"Customers_Cards\" (\n\tcard_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tcard_type_code VARCHAR(15) NOT NULL, \n\tcard_number VARCHAR(80), \n\tdate_valid_from DATETIME, \n\tdate_valid_to DATETIME, \n\tother_card_details VARCHAR(255), \n\tPRIMARY KEY (card_id)\n)\n/*\nColumns in Customers_Cards and 3 examples in each column for high cardinality columns :\ncard_id : 1, 13, 11\ncustomer_id : 3, 13, 10\ncard_number : 4560596484842, 4716674779726, 348237249146948\ndate_valid_from : 2013-05-23 07:55:36, 2012-05-22 02:05:41, 2013-11-17 02:58:22\ndate_valid_to : 2018-03-14 14:00:07, 2018-03-12 02:16:45, 2018-03-24 00:38:54\nother_card_details : 6011771512810699, 4916493714393, 5428692691195935\n*/\n/*\nColumns in Customers_Cards and all categories for low cardinality columns :\ncard_type_code : Credit, Debit\n*/\n \nCREATE TABLE song (\n\tsong_name TEXT(50), \n\tartist_name TEXT(50), \n\tcountry TEXT(20), \n\tf_id NUMERIC(10), \n\tgenre_is TEXT(20), \n\trating NUMERIC(10), \n\tlanguages TEXT(20), \n\treleasedate DATE, \n\tresolution NUMERIC(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\tCHECK (rating>0 and rating<11)\n) \nCREATE TABLE \"Draft_Copies\" (\n\tdocument_id INTEGER NOT NULL, \n\tdraft_number INTEGER NOT NULL, \n\tcopy_number INTEGER NOT NULL, \n\tPRIMARY KEY (document_id, draft_number, copy_number), \n\tFOREIGN KEY(document_id, draft_number) REFERENCES \"Document_Drafts\" (document_id, draft_number)\n)\n/*\nColumns in Draft_Copies and all categories for low cardinality columns :\ndocument_id : 1, 20, 2, 23, 4, 12, 10\ndraft_number : 1, 20, 2, 8, 17, 12, 9\ncopy_number : 5, 15, 4, 6, 10\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE membership_register_branch (\n\t\"Member_ID\" INTEGER, \n\t\"Branch_ID\" TEXT, \n\t\"Register_Year\" TEXT, \n\tPRIMARY KEY (\"Member_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\"), \n\tFOREIGN KEY(\"Branch_ID\") REFERENCES branch (\"Branch_ID\")\n)\n/*\nColumns in membership_register_branch and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3\nBranch_ID : 1, 2, 5, 8, 4, 6\nRegister_Year : 2016, 2017\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n" }, { "role": "user", "content": "What are the distinct ages of the heads who are acting?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: management, head.\nFrom these tables, I'll be using the following columns: head.age, head.head_id, management.head_id, management.temporary_acting.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id = T2.head_id WHERE T2.temporary_acting = 'Yes'" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE \"Manufacturers\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Headquarter\" VARCHAR(255) NOT NULL, \n\t\"Founder\" VARCHAR(255) NOT NULL, \n\t\"Revenue\" REAL, \n\tPRIMARY KEY (\"Code\")\n)\n/*\nColumns in Manufacturers and all categories for low cardinality columns :\nCode : 1, 2, 5, 4, 6, 3\nName : Winchester, Fujitsu, Iomega, Hewlett-Packard, Creative Labs, Sony\nHeadquarter : Beijing, Los Angeles, Austin, Tokyo, Paris, Taiwan\nFounder : Owen, Mary, James, John, Robert, Andy\nRevenue : 30.0, 100.0, 130.0, 200.0, 50.0, 120.0\n*/\n \nCREATE TABLE \"Ref_Detention_Type\" (\n\tdetention_type_code VARCHAR(10), \n\tdetention_type_description VARCHAR(80), \n\tPRIMARY KEY (detention_type_code)\n)\n/*\nColumns in Ref_Detention_Type and all categories for low cardinality columns :\ndetention_type_code : LUNCH, BREAK , AFTER\ndetention_type_description : After School, During Break time, Lunch-time\n*/\n \nCREATE TABLE membership_register_branch (\n\t\"Member_ID\" INTEGER, \n\t\"Branch_ID\" TEXT, \n\t\"Register_Year\" TEXT, \n\tPRIMARY KEY (\"Member_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\"), \n\tFOREIGN KEY(\"Branch_ID\") REFERENCES branch (\"Branch_ID\")\n)\n/*\nColumns in membership_register_branch and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3\nBranch_ID : 1, 2, 5, 8, 4, 6\nRegister_Year : 2016, 2017\n*/\n \nCREATE TABLE pilot (\n\t\"Pilot_ID\" INTEGER, \n\t\"Pilot_name\" TEXT, \n\t\"Rank\" INTEGER, \n\t\"Age\" INTEGER, \n\t\"Nationality\" TEXT, \n\t\"Position\" TEXT, \n\t\"Join_Year\" INTEGER, \n\t\"Team\" TEXT, \n\tPRIMARY KEY (\"Pilot_ID\")\n)\n/*\nColumns in pilot and all categories for low cardinality columns :\nPilot_ID : 1, 2, 5, 4, 3\nPilot_name : Patrick O'Bryant, Charles Oakley, Dan O'Sullivan, Hakeem Olajuwon, Jermaine O'Neal\nRank : 34, 13, 45, 6\nAge : 37, 33, 40, 32, 22\nNationality : United States, Nigeria, United Kindom\nPosition : Center Team, Forward Team, Forward-Center Team\nJoin_Year : 2009, 2001, 2008, 1999, 2010\nTeam : Fordham, Eau Claire High School, Bradley, Virginia Union, Houston\n*/\n \nCREATE TABLE \"Forms\" (\n\tform_id INTEGER, \n\tform_type_code VARCHAR(15) NOT NULL, \n\tservice_id INTEGER, \n\tform_number VARCHAR(50), \n\tform_name VARCHAR(80), \n\tform_description VARCHAR(255), \n\tPRIMARY KEY (form_id), \n\tFOREIGN KEY(service_id) REFERENCES \"Services\" (service_id)\n)\n/*\nColumns in Forms and all categories for low cardinality columns :\nform_id : 1, 2, 5, 4, 6, 3\nform_type_code : Basic, Complex\nservice_id : 13, 2, 7, 14, 3, 9\nform_number : 9173, 8069, 9837, 6673, 9130, 2675\nform_name : Marriage Certificate, Account Application, Divorce Certificate, Moving Form, Property Change, SSN Application\nform_description : Form for SSN Application, Form for moving house, Form for Property Change, Marriage Certificate, Divorce Certificate, Form for Account Application\n*/\n \nCREATE TABLE \"Inst\" (\n\t\"instID\" INTEGER, \n\tname TEXT, \n\tcountry TEXT, \n\tPRIMARY KEY (\"instID\")\n)\n/*\nColumns in Inst and all categories for low cardinality columns :\ninstID : 1060, 1010, 1000, 1040, 1050, 1030, 1020, 1070\nname : Northeastern University, INRIA, University of Oxford, Indiana University, Tohoku University, University of Pennsylvania, Portland State University, Google\ncountry : Japan, UK, USA, France\n*/\n \nCREATE TABLE teachers (\n\t\"LastName\" TEXT, \n\t\"FirstName\" TEXT, \n\t\"Classroom\" INTEGER, \n\tPRIMARY KEY (\"LastName\", \"FirstName\")\n)\n/*\nColumns in teachers and 3 examples in each column for high cardinality columns :\nLastName : MOYER, NIBLER, ONDERSMA\nFirstName : CHARMAINE, JEROME, KIRK\nClassroom : 109, 108, 106\n*/\n\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE advisor (\n\t\"s_ID\" VARCHAR(5), \n\t\"i_ID\" VARCHAR(5), \n\tPRIMARY KEY (\"s_ID\"), \n\tFOREIGN KEY(\"i_ID\") REFERENCES instructor (\"ID\"), \n\tFOREIGN KEY(\"s_ID\") REFERENCES student (\"ID\")\n)\n/*\nColumns in advisor and 3 examples in each column for high cardinality columns :\ns_ID : 93061, 97679, 35175\ni_ID : 99052, 6569, 79081\n*/\n\n \nCREATE TABLE \"Locations\" (\n\t\"Location_ID\" INTEGER NOT NULL, \n\t\"Location_Name\" VARCHAR(255), \n\t\"Address\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Location_ID\")\n)\n/*\nColumns in Locations and 3 examples in each column for high cardinality columns :\nLocation_ID : 867, 858, 861\nLocation_Name : Castle, Film Festival, UK Gallery\nAddress : 4411 Sabrina Radial Suite 582, 5536 Betsy Street Apt. 646, 660 Shea Crescent\n*/\n/*\nColumns in Locations and all categories for low cardinality columns :\nOther_Details : None\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/*\nColumns in faculty and 3 examples in each column for high cardinality columns :\nCampus : 17, 21, 9\nFaculty : 449.8, 117.7, 1027.6\n*/\n/*\nColumns in faculty and all categories for low cardinality columns :\nYear : 2002, 2003, 2004\n*/\n \nCREATE TABLE perpetrator (\n\t\"Perpetrator_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Year\" REAL, \n\t\"Location\" TEXT, \n\t\"Country\" TEXT, \n\t\"Killed\" INTEGER, \n\t\"Injured\" INTEGER, \n\tPRIMARY KEY (\"Perpetrator_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in perpetrator and all categories for low cardinality columns :\nPerpetrator_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 8, 4, 6, 3\nDate : 05.21 May 21, 04.26 April 26/27, 04.00 April, 11.18 Nov. 18, 09.20 Sep. 20\nYear : 1995.0, 1982.0, 1938.0, 1994.0, 1950.0\nLocation : Beijing, Uiryeong, Kaio, Zhaodong, Nainital\nCountry : Japan, South Korea, India, China\nKilled : 56, 30, 23, 32, 22\nInjured : 16, 37, 80, 3, 0\n*/\n \nCREATE TABLE \"AssignedTo\" (\n\t\"Scientist\" INTEGER NOT NULL, \n\t\"Project\" CHAR(4) NOT NULL, \n\tPRIMARY KEY (\"Scientist\", \"Project\"), \n\tFOREIGN KEY(\"Scientist\") REFERENCES \"Scientists\" (\"SSN\"), \n\tFOREIGN KEY(\"Project\") REFERENCES \"Projects\" (\"Code\")\n)\n/*\nColumns in AssignedTo and 3 examples in each column for high cardinality columns :\nScientist : 546523478, 332569843, 845657246\n*/\n/*\nColumns in AssignedTo and all categories for low cardinality columns :\nProject : Ast3, AeH3, AeH1, Ast1, AeH4, Ast2, Bte1, Che1\n*/\n \nCREATE TABLE party (\n\t\"Party_ID\" INTEGER, \n\t\"Year\" REAL, \n\t\"Party\" TEXT, \n\t\"Governor\" TEXT, \n\t\"Lieutenant_Governor\" TEXT, \n\t\"Comptroller\" TEXT, \n\t\"Attorney_General\" TEXT, \n\t\"US_Senate\" TEXT, \n\tPRIMARY KEY (\"Party_ID\")\n)\n/*\nColumns in party and all categories for low cardinality columns :\nParty_ID : 1, 2, 5, 7, 4, 6, 3\nYear : 2002.0, 2006.0, 1998.0\nParty : Working Families, Democratic, Independence, Liberal\nGovernor : Betsy McCaughey Ross, Tom Golisano, Peter Vallone, Carl McCall, Eliot Spitzer\nLieutenant_Governor : Sandra Frankel, Mary Donohue, Dennis Mehiel, David Paterson, Jonathan Reiter\nComptroller : Carl McCall, Alan Hevesi, John Faso\nAttorney_General : Eliot Spitzer, Andrew Cuomo, Jeanine Pirro\nUS_Senate : Hillary Rodham Clinton, Charles Schumer, (no election)\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE \"Catalog_Structure\" (\n\tcatalog_level_number INTEGER, \n\tcatalog_id INTEGER NOT NULL, \n\tcatalog_level_name VARCHAR(50), \n\tPRIMARY KEY (catalog_level_number), \n\tFOREIGN KEY(catalog_id) REFERENCES \"Catalogs\" (catalog_id)\n)\n/*\nColumns in Catalog_Structure and all categories for low cardinality columns :\ncatalog_level_number : 1, 8, 9\ncatalog_id : 1, 8, 2\ncatalog_level_name : Product, Category, Sub-Category\n*/\n \nCREATE TABLE \"Student\" (\n\t\"StuID\" INTEGER, \n\t\"LName\" VARCHAR(12), \n\t\"Fname\" VARCHAR(12), \n\t\"Age\" INTEGER, \n\t\"Sex\" VARCHAR(1), \n\t\"Major\" INTEGER, \n\t\"Advisor\" INTEGER, \n\tcity_code VARCHAR(3), \n\tPRIMARY KEY (\"StuID\")\n)\n/*\nColumns in Student and 3 examples in each column for high cardinality columns :\nStuID : 1003, 1017, 1002\nLName : Lee, Han, Brody\nFname : Tracy, Michael, Shiela\nAdvisor : 7723, 7712, 7134\ncity_code : ATL, HOU, LON\n*/\n/*\nColumns in Student and all categories for low cardinality columns :\nAge : 26, 16, 20, 17, 21, 19, 18, 27, 22\nSex : F, M\nMajor : 520, 100, 50, 600, 540, 550\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Rent_Arrears\" (\n\tcouncil_tax_id INTEGER NOT NULL, \n\tcmi_cross_ref_id INTEGER NOT NULL, \n\tPRIMARY KEY (council_tax_id), \n\tFOREIGN KEY(cmi_cross_ref_id) REFERENCES \"CMI_Cross_References\" (cmi_cross_ref_id)\n)\n/*\nColumns in Rent_Arrears and all categories for low cardinality columns :\ncouncil_tax_id : 1, 7, 2, 6\ncmi_cross_ref_id : 8, 2, 59, 100\n*/\n \nCREATE TABLE \"Student_Course_Enrolment\" (\n\tregistration_id INTEGER, \n\tstudent_id INTEGER NOT NULL, \n\tcourse_id INTEGER NOT NULL, \n\tdate_of_enrolment DATETIME NOT NULL, \n\tdate_of_completion DATETIME NOT NULL, \n\tPRIMARY KEY (registration_id), \n\tFOREIGN KEY(student_id) REFERENCES \"Students\" (student_id), \n\tFOREIGN KEY(course_id) REFERENCES \"Courses\" (course_id)\n)\n/*\nColumns in Student_Course_Enrolment and 3 examples in each column for high cardinality columns :\nregistration_id : 17, 9, 16\nstudent_id : 3, 13, 11\ndate_of_enrolment : 2017-12-16 15:53:06, 2017-10-10 10:05:03, 2017-12-07 02:21:13\ndate_of_completion : 2018-03-01 07:12:39, 2018-03-22 18:04:54, 2018-03-07 09:45:48\n*/\n/*\nColumns in Student_Course_Enrolment and all categories for low cardinality columns :\ncourse_id : 1, 11, 2, 15, 7, 8, 4, 14, 10, 9\n*/\n \nCREATE TABLE certificate (\n\teid NUMERIC(9, 0), \n\taid NUMERIC(9, 0), \n\tPRIMARY KEY (eid, aid), \n\tFOREIGN KEY(aid) REFERENCES aircraft (aid), \n\tFOREIGN KEY(eid) REFERENCES employee (eid)\n)\n/*\nColumns in certificate and 3 examples in each column for high cardinality columns :\neid : 573284895, 90873519, 552455318\naid : 1, 13, 11\n*/\n\n \nCREATE TABLE book (\n\t\"Book_ID\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Issues\" REAL, \n\t\"Writer\" TEXT, \n\tPRIMARY KEY (\"Book_ID\")\n)\n/*\nColumns in book and all categories for low cardinality columns :\nBook_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nTitle : Bloody Mary, Cyberella, The Black Lamb, Sheva's War, BrainBanx, Dead Corps, Gemini Blood, Bloody Mary : Lady Liberty, Michael Moorcock's Multiverse, The Dome: Ground Zero\nIssues : 12.0, 1.0, 9.0, 6.0, 4.0, 5.0\nWriter : Christopher Hinz, Timothy Truman, Christopher Moeller, Dave Gibbons, Elaine Lee, Michael Moorcock, Garth Ennis, Howard Chaykin\n*/\n" }, { "role": "user", "content": "List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: department, management, head.\nFrom these tables, I'll be using the following columns: head.born_state, department.department_id, management.department_id, management.head_id, head.head_id, department.name.\nThe SQL query I'll be generating is:\nSELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Homeland Security'" } ]
[ { "role": "system", "content": "\nYou are an assistant that is an expert in generating sqlite SQL queries.\nHaving the access to database content, generate a correct sqlite SQL query for the given question.\n### Database content ###\n \nCREATE TABLE machine (\n\t\"Machine_ID\" INTEGER, \n\t\"Making_Year\" INTEGER, \n\t\"Class\" TEXT, \n\t\"Team\" TEXT, \n\t\"Machine_series\" TEXT, \n\tvalue_points REAL, \n\tquality_rank INTEGER, \n\tPRIMARY KEY (\"Machine_ID\")\n)\n/*\nColumns in machine and all categories for low cardinality columns :\nMachine_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nMaking_Year : 1992, 1993, 1994, 1999, 1991, 1996, 1997, 1998, 1995\nClass : 125cc\nTeam : Honda, Team Givi- Honda LCR, Givi Racing- Honda, Marlboro Pileri - Honda, Hero Sports TS- Honda\nMachine_series : RS125\nvalue_points : 238.0, 105.0, 171.0, 129.0, 57.0, 62.0, 126.0, 194.0, 65.0\nquality_rank : 1, 13, 11, 2, 5, 7, 8, 4, 3\n*/\n \nCREATE TABLE wrestler (\n\t\"Wrestler_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Reign\" TEXT, \n\t\"Days_held\" TEXT, \n\t\"Location\" TEXT, \n\t\"Event\" TEXT, \n\tPRIMARY KEY (\"Wrestler_ID\")\n)\n/*\nColumns in wrestler and all categories for low cardinality columns :\nWrestler_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Fishman, El Samurai §, Rey Misterio Sr., Último Dragón §, Shinjiro Otani §, Gran Hamada, Jushin Liger §, Villaño IV, The Great Sasuke §, El Samurai\nReign : 1, 2\nDays_held : 1, 113, 35, 56, 183, 1285, 960, 344, 99, 54\nLocation : Nagoya , Japan, Tijuana , Mexico, Sapporo , Japan, Tokyo , Japan, Osaka , Japan\nEvent : Wrestling World 1997, Live event\n*/\n \nCREATE TABLE captain (\n\t\"Captain_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Ship_ID\" INTEGER, \n\tage TEXT, \n\t\"Class\" TEXT, \n\t\"Rank\" TEXT, \n\tPRIMARY KEY (\"Captain_ID\"), \n\tFOREIGN KEY(\"Ship_ID\") REFERENCES \"Ship\" (\"Ship_ID\")\n)\n/*\nColumns in captain and all categories for low cardinality columns :\nCaptain_ID : 1, 2, 5, 7, 4, 6, 3\nName : Lieutenant Hugh Bolitho, Captain Gilbert Pears, Commander Richard Bolitho, Captain Sir Henry Langford, Captain Beves Conway, Captain Henry Dumaresq, Lieutenant Montagu Verling\nShip_ID : 1, 2, 5, 4, 3\nage : 38, 45, 40, 60, 43, 54\nClass : Sloop-of-war, Armed schooner, Third-rate ship of the line, Frigate, Cutter\nRank : Midshipman, Lieutenant, Commander, junior captain\n*/\n \nCREATE TABLE useracct (\n\tu_id INTEGER NOT NULL, \n\tname VARCHAR(128) DEFAULT NULL, \n\tPRIMARY KEY (u_id)\n)\n/*\nColumns in useracct and all categories for low cardinality columns :\nu_id : 1, 2, 5, 7, 4, 6, 3\nname : Rosie, Emily, Roxi, Helen, Terry, Mark, Nancy\n*/\n \nCREATE TABLE county (\n\t\"County_Id\" INTEGER, \n\t\"County_name\" TEXT, \n\t\"Population\" REAL, \n\t\"Zip_code\" TEXT, \n\tPRIMARY KEY (\"County_Id\")\n)\n/*\nColumns in county and all categories for low cardinality columns :\nCounty_Id : 1, 2, 5, 4, 3\nCounty_name : Baltimore County, Howard, Colony, Manning, Mansfield\nPopulation : 87200.0, 13300.0, 21000.0, 79000.0, 90000.0\nZip_code : D09, D02, D21, D11, D08\n*/\n \nCREATE TABLE \"Ref_Service_Types\" (\n\t\"Service_Type_Code\" CHAR(15) NOT NULL, \n\t\"Parent_Service_Type_Code\" CHAR(15), \n\t\"Service_Type_Description\" VARCHAR(255), \n\tPRIMARY KEY (\"Service_Type_Code\"), \n\tUNIQUE (\"Service_Type_Code\")\n)\n/*\nColumns in Ref_Service_Types and all categories for low cardinality columns :\nService_Type_Code : 1, 2, 4, 3\nParent_Service_Type_Code : 1\nService_Type_Description : provide photo service, provide dinning service, provide adv promoting service, provide filming service\n*/\n \nCREATE TABLE airport (\n\tid INTEGER, \n\t\"City\" TEXT, \n\t\"Country\" TEXT, \n\t\"IATA\" TEXT, \n\t\"ICAO\" TEXT, \n\tname TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in airport and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 3, 9\nCity : Amsterdam, Anchorage, Bergen, Barcelona, Akureyri, Billund, Brussels, Boston, Baltimore\nCountry : Spain, Belgium, Iceland, United States, Norway, Netherlands, Denmark\nIATA : BRU, AMS, BGO, ANC, BCN, BLL, BOS, BWI, AEY\nICAO : EKBI, EHAM, KBWI, LEBL, BIAR, EBBR, PANC, KBOS, ENBR\nname : Schiphol Airport, Logan International Airport, Billund Airport, Akureyri Airport, Baltimore-Washington Airport, National Airport, Ted Stevens Airport, Bergen Airport, El Prat Airport\n*/\n \nCREATE TABLE \"Enrolled_in\" (\n\t\"StuID\" INTEGER, \n\t\"CID\" VARCHAR(7), \n\t\"Grade\" VARCHAR(2), \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"CID\") REFERENCES \"Course\" (\"CID\"), \n\tFOREIGN KEY(\"Grade\") REFERENCES \"Gradeconversion\" (lettergrade)\n)\n/*\nColumns in Enrolled_in and 3 examples in each column for high cardinality columns :\nStuID : 1003, 1017, 1002\nCID : 550.413, 520.345, 600.437\nGrade : D+, B-, C\n*/\n\n \nCREATE TABLE head (\n\t\"head_ID\" INTEGER, \n\tname TEXT, \n\tborn_state TEXT, \n\tage REAL, \n\tPRIMARY KEY (\"head_ID\")\n)\n/*\nColumns in head and all categories for low cardinality columns :\nhead_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Jeff Maggert, Pádraig Harrington, Billy Mayfair, K. J. Choi, Dudley Hart, Sergio García, Stewart Cink, Tiger Woods, Nick Faldo, Franklin Langham\nborn_state : Delaware, Connecticut, Alabama, California, Florida\nage : 69.0, 67.0, 68.0, 53.0, 56.0, 52.0, 50.0, 43.0\n*/\n \nCREATE TABLE management (\n\t\"department_ID\" INTEGER, \n\t\"head_ID\" INTEGER, \n\ttemporary_acting TEXT, \n\tPRIMARY KEY (\"department_ID\", \"head_ID\"), \n\tFOREIGN KEY(\"head_ID\") REFERENCES head (\"head_ID\"), \n\tFOREIGN KEY(\"department_ID\") REFERENCES department (\"Department_ID\")\n)\n/*\nColumns in management and all categories for low cardinality columns :\ndepartment_ID : 7, 15, 2, 11\nhead_ID : 5, 4, 6, 3, 10\ntemporary_acting : Yes, No\n*/\n \nCREATE TABLE \"Acceptance\" (\n\t\"Submission_ID\" INTEGER, \n\t\"Workshop_ID\" INTEGER, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"Submission_ID\", \"Workshop_ID\"), \n\tFOREIGN KEY(\"Workshop_ID\") REFERENCES workshop (\"Workshop_ID\"), \n\tFOREIGN KEY(\"Submission_ID\") REFERENCES submission (\"Submission_ID\")\n)\n/*\nColumns in Acceptance and all categories for low cardinality columns :\nSubmission_ID : 1, 2, 5, 4, 3\nWorkshop_ID : 1, 2, 5, 6, 3\nResult : Accepted, Rejected\n*/\n \nCREATE TABLE match_result (\n\t\"Rank\" INTEGER, \n\t\"Club_ID\" INTEGER, \n\t\"Gold\" INTEGER, \n\t\"Big_Silver\" INTEGER, \n\t\"Small_Silver\" INTEGER, \n\t\"Bronze\" INTEGER, \n\t\"Points\" INTEGER, \n\tPRIMARY KEY (\"Rank\", \"Club_ID\"), \n\tFOREIGN KEY(\"Club_ID\") REFERENCES club (\"Club_ID\")\n)\n/*\nColumns in match_result and all categories for low cardinality columns :\nRank : 1, 2, 5, 4, 6, 3\nClub_ID : 1, 2, 5, 4, 6, 3\nGold : 13, 20, 5, 7, 6, 12\nBig_Silver : 11, 7, 6, 12, 14, 9\nSmall_Silver : 16, 4, 6, 10, 9\nBronze : 7, 8, 6, 10, 9\nPoints : 89, 102, 84, 66, 139, 168\n*/\n \nCREATE TABLE phone (\n\t\"Company_name\" TEXT, \n\t\"Hardware_Model_name\" TEXT, \n\t\"Accreditation_type\" TEXT, \n\t\"Accreditation_level\" TEXT, \n\t\"Date\" TEXT, \n\tchip_model TEXT, \n\tscreen_mode TEXT, \n\tPRIMARY KEY (\"Hardware_Model_name\"), \n\tFOREIGN KEY(chip_model) REFERENCES chip_model (\"Model_name\"), \n\tFOREIGN KEY(screen_mode) REFERENCES screen_mode (\"Graphics_mode\")\n)\n/*\nColumns in phone and all categories for low cardinality columns :\nCompany_name : Samsung Electronics Co Ltd, Huawei Technologies Co.Ltd., HTC Corporation, Nokia Corporation, LG Electronics, Sony Mobile Communications\nHardware_Model_name : GT-I9300, U8815 Asura, Lumia 920, Lumia 820, Lumia 620, GT-I9100, Nokia 700, LG-P760, Z520e, XPERIA T, XPERIA J\nAccreditation_type : Provisional, Full\nAccreditation_level : joyn Hot Fixes, joyn\nDate : Approved (valid until 03.05.13), Approved (valid until 06.04.13), Approved (awarded 19.11.12), Approved (awarded 05.12.12), Approved (valid until 14.09.13), Approved (awarded 23.10.12), Approved (awarded 15.11.12)\nchip_model : X50 Advanced, X5, X3i, X51v, X30 low-end, X50 Standard\nscreen_mode : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE pilot (\n\t\"Pilot_ID\" INTEGER, \n\t\"Pilot_name\" TEXT, \n\t\"Rank\" INTEGER, \n\t\"Age\" INTEGER, \n\t\"Nationality\" TEXT, \n\t\"Position\" TEXT, \n\t\"Join_Year\" INTEGER, \n\t\"Team\" TEXT, \n\tPRIMARY KEY (\"Pilot_ID\")\n)\n/*\nColumns in pilot and all categories for low cardinality columns :\nPilot_ID : 1, 2, 5, 4, 3\nPilot_name : Patrick O'Bryant, Charles Oakley, Dan O'Sullivan, Hakeem Olajuwon, Jermaine O'Neal\nRank : 34, 13, 45, 6\nAge : 37, 33, 40, 32, 22\nNationality : United States, Nigeria, United Kindom\nPosition : Center Team, Forward Team, Forward-Center Team\nJoin_Year : 2009, 2001, 2008, 1999, 2010\nTeam : Fordham, Eau Claire High School, Bradley, Virginia Union, Houston\n*/\n \nCREATE TABLE party_host (\n\t\"Party_ID\" INTEGER, \n\t\"Host_ID\" INTEGER, \n\t\"Is_Main_in_Charge\" BOOLEAN, \n\tPRIMARY KEY (\"Party_ID\", \"Host_ID\"), \n\tFOREIGN KEY(\"Party_ID\") REFERENCES party (\"Party_ID\"), \n\tFOREIGN KEY(\"Host_ID\") REFERENCES host (\"Host_ID\")\n)\n/*\nColumns in party_host and all categories for low cardinality columns :\nParty_ID : 1, 2, 8, 4, 6\nHost_ID : 1, 2, 5, 7, 3, 10\nIs_Main_in_Charge : True\n*/\n \nCREATE TABLE department (\n\t\"Department_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Creation\" TEXT, \n\t\"Ranking\" INTEGER, \n\t\"Budget_in_Billions\" REAL, \n\t\"Num_Employees\" REAL, \n\tPRIMARY KEY (\"Department_ID\")\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\nDepartment_ID : 1, 13, 11\nName : Energy, Interior, Health and Human Services\nCreation : 1913, 1979, 1989\nRanking : 1, 13, 11\nBudget_in_Billions : 10.7, 77.6, 59.7\nNum_Employees : 112557.0, 3000000.0, 235000.0\n*/\n\n \nCREATE TABLE \"Ship\" (\n\t\"Ship_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Type\" TEXT, \n\t\"Built_Year\" REAL, \n\t\"Class\" TEXT, \n\t\"Flag\" TEXT, \n\tPRIMARY KEY (\"Ship_ID\")\n)\n/*\nColumns in Ship and all categories for low cardinality columns :\nShip_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : HMS Trojan, HMS Destiny, HMS Phalarope, HMS Undine, HMS Manxman, HM Cutter Avenger, HM Sloop Sparrow, HM Schooner Hotspur, HMS Gorgon\nType : Panamax\nBuilt_Year : 1997.0, 1998.0\nClass : GL, KR\nFlag : Panama, Malta\n*/\n \nCREATE TABLE \"Performance\" (\n\t\"SongId\" INTEGER, \n\t\"Bandmate\" INTEGER, \n\t\"StagePosition\" TEXT, \n\tPRIMARY KEY (\"SongId\", \"Bandmate\"), \n\tFOREIGN KEY(\"SongId\") REFERENCES \"Songs\" (\"SongId\"), \n\tFOREIGN KEY(\"Bandmate\") REFERENCES \"Band\" (\"Id\")\n)\n/*\nColumns in Performance and all categories for low cardinality columns :\nSongId : \nBandmate : \nStagePosition : \n*/\n \nCREATE TABLE basketball_match (\n\t\"Team_ID\" INTEGER, \n\t\"School_ID\" INTEGER, \n\t\"Team_Name\" TEXT, \n\t\"ACC_Regular_Season\" TEXT, \n\t\"ACC_Percent\" TEXT, \n\t\"ACC_Home\" TEXT, \n\t\"ACC_Road\" TEXT, \n\t\"All_Games\" TEXT, \n\t\"All_Games_Percent\" INTEGER, \n\t\"All_Home\" TEXT, \n\t\"All_Road\" TEXT, \n\t\"All_Neutral\" TEXT, \n\tPRIMARY KEY (\"Team_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES university (\"School_ID\")\n)\n/*\nColumns in basketball_match and all categories for low cardinality columns :\nTeam_ID : 1, 2, 4, 3\nSchool_ID : 1, 2, 4, 5\nTeam_Name : Virginia Tech, North Carolina, Clemson, Duke\nACC_Regular_Season : 9–7, 14–2, 10–6, 13–3\nACC_Percent : .813, .625, .563, .875\nACC_Home : 7–1, 6–2\nACC_Road : 3–5, 6–2, 8–0\nAll_Games : 21–14, 35–2, 24–10, 28–6\nAll_Games_Percent : 0.824, 0.6, 0.706, 0.946\nAll_Home : 14–3, 14–2, 15–1\nAll_Road : 4–8, 8–2, 13–0, 6–5\nAll_Neutral : 9–1, 4–3, 3–3, 5–3\n*/\n" }, { "role": "user", "content": "Which department has more than 1 head at a time? List the id, name and the number of heads." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: management, department.\nFrom these tables, I'll be using the following columns: department.department_id, department.name, management.department_id.\nThe SQL query I'll be generating is:\nSELECT T1.department_id , T1.name , count(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id = T2.department_id GROUP BY T1.department_id HAVING count(*) > 1" } ]
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card