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 mission (\n\t\"Mission_ID\" INTEGER, \n\t\"Ship_ID\" INTEGER, \n\t\"Code\" TEXT, \n\t\"Launched_Year\" INTEGER, \n\t\"Location\" TEXT, \n\t\"Speed_knots\" INTEGER, \n\t\"Fate\" TEXT, \n\tPRIMARY KEY (\"Mission_ID\"), \n\tFOREIGN KEY(\"Ship_ID\") REFERENCES ship (\"Ship_ID\")\n)\n/*\nColumns in mission and all categories for low cardinality columns :\nMission_ID : 1, 2, 5, 7, 4, 6, 3\nShip_ID : 1, 2, 5, 7, 8, 6, 3\nCode : VMV-3, VMV-5, VMV-6, VMV-4 Former: Sterling, VMV-2, VMV-7, VMV-1\nLaunched_Year : 1932, 1916, 1930, 1931\nLocation : Turku , Finland, Helsinki , Finland, Norway, Germany, Uusikaupunki , Finland\nSpeed_knots : 16, 25, 23\nFate : Retired 1939, Decommissioned 1950, Lost (burned and sunk) 1933, Lost (burned) 1931, Decommissioned 1959, Decommissioned 1960\n*/\n \nCREATE TABLE \"Ref_Colors\" (\n\tcolor_code VARCHAR(15), \n\tcolor_description VARCHAR(80), \n\tPRIMARY KEY (color_code)\n)\n/*\nColumns in Ref_Colors and all categories for low cardinality columns :\ncolor_code : 1, 2, 5, 7, 8, 4, 3, 9\ncolor_description : blue, green, gray, red, black, yellow, purple, white\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 program (\n\t\"Program_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Origin\" TEXT, \n\t\"Launch\" REAL, \n\t\"Owner\" TEXT, \n\tPRIMARY KEY (\"Program_ID\")\n)\n/*\nColumns in program and all categories for low cardinality columns :\nProgram_ID : 1, 2, 5, 4, 3\nName : Toonmax, Aniworld, Youman, Jiajia, Kaku\nOrigin : Beijing, Shanghai, Guangdong, Hunan, Jiangsu\nLaunch : 2007.0, 2005.0, 2010.0, 2004.0\nOwner : Jiangsu Broadcasting Corporation (JSBC), Shanghai Media Group (SMG), Beijing Television (BTV), Hunan Broadcasting System (HBS), Southern Media Corporation (SMC)\n*/\n \nCREATE TABLE culture_company (\n\t\"Company_name\" TEXT, \n\t\"Type\" TEXT, \n\t\"Incorporated_in\" TEXT, \n\t\"Group_Equity_Shareholding\" REAL, \n\tbook_club_id TEXT, \n\tmovie_id TEXT, \n\tPRIMARY KEY (\"Company_name\"), \n\tFOREIGN KEY(book_club_id) REFERENCES book_club (book_club_id), \n\tFOREIGN KEY(movie_id) REFERENCES movie (movie_id)\n)\n/*\nColumns in culture_company and all categories for low cardinality columns :\nCompany_name : Cathay Pacific Culture, Culture China Cargo, Culture Hong Kong, Cathay Pacific Culture Services (HK) Limited, Culture China, Dragonair\nType : Joint Venture, Subsidiary, Corporate\nIncorporated_in : Hong Kong, China\nGroup_Equity_Shareholding : 49.0, 60.0, 18.77, 100.0\nbook_club_id : 1, 2, 5, 6, 3\nmovie_id : 2, 5, 7, 4, 6, 3\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 city (\n\t\"City_ID\" INTEGER, \n\t\"City\" TEXT, \n\t\"Hanzi\" TEXT, \n\t\"Hanyu_Pinyin\" TEXT, \n\t\"Regional_Population\" INTEGER, \n\t\"GDP\" REAL, \n\tPRIMARY KEY (\"City_ID\")\n)\n/*\nColumns in city and 3 examples in each column for high cardinality columns :\nCity_ID : 1, 13, 11\nCity : Shanghai, Changzhou ( Jiangsu ), Jinhua ( Zhejiang )\nHanzi : 台州, 金华/ 金華, 上海\nHanyu_Pinyin : Shàoxīng, Tāizhōu, Hángzhōu\nRegional_Population : 8700400, 7605689, 4912200\nGDP : 1919.57, 408.02, 266.81\n*/\n\n \nCREATE TABLE \"Authorship\" (\n\t\"authID\" INTEGER, \n\t\"instID\" INTEGER, \n\t\"paperID\" INTEGER, \n\t\"authOrder\" INTEGER, \n\tPRIMARY KEY (\"authID\", \"instID\", \"paperID\"), \n\tFOREIGN KEY(\"authID\") REFERENCES \"Authors\" (\"authID\"), \n\tFOREIGN KEY(\"instID\") REFERENCES \"Inst\" (\"instID\"), \n\tFOREIGN KEY(\"paperID\") REFERENCES \"Papers\" (\"paperID\")\n)\n/*\nColumns in Authorship and 3 examples in each column for high cardinality columns :\nauthID : 53, 56, 57\n*/\n/*\nColumns in Authorship and all categories for low cardinality columns :\ninstID : 1060, 1010, 1000, 1040, 1050, 1030, 1020, 1070\npaperID : 201, 204, 205, 200, 206, 203, 202\nauthOrder : 1, 2, 3\n*/\n \nCREATE TABLE storm (\n\t\"Storm_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Dates_active\" TEXT, \n\t\"Max_speed\" INTEGER, \n\t\"Damage_millions_USD\" REAL, \n\t\"Number_Deaths\" INTEGER, \n\tPRIMARY KEY (\"Storm_ID\")\n)\n/*\nColumns in storm and all categories for low cardinality columns :\nStorm_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Three, One, Five, Nine, Four, Seven, Six, Eight, 9 cyclones, Two\nDates_active : August5–August14, May19 –October26, August3–August10, September22–September28, September7–September17, May19–May25, October24–October26, August26–September2, September18–September25, October20–October24\nMax_speed : 1007, 988, 977, 961, 972, 1002, 983, 995\nDamage_millions_USD : 1.49, 10.75, 13.0, 29.3, 4.05, 0.039\nNumber_Deaths : 2, 7, 52, 3, 71, 0\n*/\n \nCREATE TABLE player (\n\t\"Player_ID\" INTEGER, \n\t\"Player\" TEXT, \n\t\"Team\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Position\" TEXT, \n\t\"School_ID\" INTEGER, \n\tPRIMARY KEY (\"Player_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in player and 3 examples in each column for high cardinality columns :\nPlayer_ID : 17, 21, 9\nPlayer : Buster Posey, Brett Wallace, Timothy Beckham\nTeam : Los Angeles Dodgers, San Diego Padres, Toronto Blue Jays\n*/\n/*\nColumns in player and all categories for low cardinality columns :\nAge : 16, 18, 17, 14, 15\nPosition : Second baseman, Outfielder, Left-handed pitcher, Shortstop, Third baseman, First baseman, First Baseman, Catcher, Right-handed pitcher\nSchool_ID : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE \"Ref_Hotel_Star_Ratings\" (\n\tstar_rating_code CHAR(15) NOT NULL, \n\tstar_rating_description VARCHAR(80), \n\tPRIMARY KEY (star_rating_code), \n\tUNIQUE (star_rating_code)\n)\n/*\nColumns in Ref_Hotel_Star_Ratings and all categories for low cardinality columns :\nstar_rating_code : 1, 2, 5, 4, 3\nstar_rating_description : star\n*/\n \nCREATE TABLE medicine_enzyme_interaction (\n\tenzyme_id INTEGER, \n\tmedicine_id INTEGER, \n\tinteraction_type TEXT, \n\tPRIMARY KEY (enzyme_id, medicine_id), \n\tFOREIGN KEY(medicine_id) REFERENCES medicine (id), \n\tFOREIGN KEY(enzyme_id) REFERENCES enzyme (id)\n)\n/*\nColumns in medicine_enzyme_interaction and 3 examples in each column for high cardinality columns :\nmedicine_id : 1, 13, 20\n*/\n/*\nColumns in medicine_enzyme_interaction and all categories for low cardinality columns :\nenzyme_id : 1, 2, 5, 4, 6, 3\ninteraction_type : inhibitor, activitor\n*/\n \nCREATE TABLE \"Premises\" (\n\tpremise_id INTEGER, \n\tpremises_type VARCHAR(15) NOT NULL, \n\tpremise_details VARCHAR(255), \n\tPRIMARY KEY (premise_id)\n)\n/*\nColumns in Premises and 3 examples in each column for high cardinality columns :\npremise_id : 1, 13, 11\npremise_details : 5109 Jules Squares Apt. 082, 676 Kelly Spur, 00100 Green Mountains Apt. 653\n*/\n/*\nColumns in Premises and all categories for low cardinality columns :\npremises_type : Residence, Office, Warehouse\n*/\n \nCREATE TABLE \"Customer_Master_Index\" (\n\tmaster_customer_id INTEGER NOT NULL, \n\tcmi_details VARCHAR(255), \n\tPRIMARY KEY (master_customer_id)\n)\n/*\nColumns in Customer_Master_Index and all categories for low cardinality columns :\nmaster_customer_id : 1, 2, 5, 7, 8, 4, 6, 3, 9\ncmi_details : Reynolds-McClure, Quigley-Paucek, Volkman, Mills and Ferry, Mayer-Hagenes, Schmidt, Kertzmann and Lubowitz, Gottlieb, Becker and Wyman, Streich-Morissette, Schmitt-Lang, Gusikowski PLC\n*/\n \nCREATE TABLE \"PROFESSOR\" (\n\t\"EMP_NUM\" INTEGER, \n\t\"DEPT_CODE\" VARCHAR(10), \n\t\"PROF_OFFICE\" VARCHAR(50), \n\t\"PROF_EXTENSION\" VARCHAR(4), \n\t\"PROF_HIGH_DEGREE\" VARCHAR(5), \n\tFOREIGN KEY(\"EMP_NUM\") REFERENCES \"EMPLOYEE\" (\"EMP_NUM\"), \n\tFOREIGN KEY(\"DEPT_CODE\") REFERENCES \"DEPARTMENT\" (\"DEPT_CODE\")\n)\n/*\nColumns in PROFESSOR and 3 examples in each column for high cardinality columns :\nEMP_NUM : 387, 301, 155\nDEPT_CODE : ECON/FIN, ART, HIST\nPROF_OFFICE : KLR 203E, BBG 208, AAK 230\nPROF_EXTENSION : 2248, 2851, 4436\n*/\n/*\nColumns in PROFESSOR and all categories for low cardinality columns :\nPROF_HIGH_DEGREE : Ph.D., MBA, MA, DBA\n*/\n \nCREATE TABLE movie (\n\tmovie_id INTEGER, \n\t\"Title\" TEXT, \n\t\"Year\" INTEGER, \n\t\"Director\" TEXT, \n\t\"Budget_million\" REAL, \n\t\"Gross_worldwide\" INTEGER, \n\tPRIMARY KEY (movie_id)\n)\n/*\nColumns in movie and all categories for low cardinality columns :\nmovie_id : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nTitle : Agent Red, The Whole Nine Yards, Storm Catcher, 3000 Miles to Graceland, The Art of War, The Boondock Saints, Jill Rips, The Big Kahuna, Get Carter, Battlefield Earth\nYear : 2001, 1999, 2000\nDirector : Roger Christian, John Swanbeck, Stephen Kay, Christian Duguay, Jonathan Lynn, Troy Duffy, Anthony Hickox, Demian Lichtenstein, Damian Lee\nBudget_million : 63.6, 47.0, 60.0, 41.3, 44.0, 7.0, 62.0, 6.0, 4.0, 5.0\nGross_worldwide : 106371651, 456774, 40400425, 30471, 40500, 543356, 19412993, 29725663, 3728888, 18720175\n*/\n" }, { "role": "user", "content": "For the airline ids with the top 10 most routes operated, what are their names?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines, routes.\nFrom these tables, I'll be using the following columns: airlines.name, routes.alid, airlines.alid.\nThe SQL query I'll be generating is:\nSELECT T1.name , T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10" } ]
[ { "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 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 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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_first_name VARCHAR(50), \n\tcustomer_middle_initial VARCHAR(1), \n\tcustomer_last_name VARCHAR(50), \n\tgender VARCHAR(1), \n\temail_address VARCHAR(255), \n\tlogin_name VARCHAR(80), \n\tlogin_password VARCHAR(20), \n\tphone_number VARCHAR(255), \n\ttown_city VARCHAR(50), \n\tstate_county_province VARCHAR(50), \n\tcountry VARCHAR(50), \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 : Devin, Ruby, Joesph\ncustomer_last_name : Muller, Weimann, Glover\nemail_address : roosevelt.collier@example.org, pyundt@example.org, anastacio45@example.org\nlogin_name : zdeckow, rubye.padberg, feeney.lauriane\nlogin_password : 180a37476c537e78d3de, 035f2ba1e2a675c4f426, d4ade599672bccdabeee\nphone_number : 241.796.1219x37862, (791)562-7792x45732, (193)465-6674x4952\ntown_city : North Nellie, Kenshire, West Khaliltown\nstate_county_province : Louisiana, SouthDakota, Kansas\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\ncustomer_middle_initial : E, K, H, A, G, L, V, M, B\ngender : 1, 0\ncountry : USA\n*/\n \nCREATE TABLE \"Ref_Transaction_Types\" (\n\ttransaction_type_code VARCHAR(10), \n\ttransaction_type_description VARCHAR(80) NOT NULL, \n\tPRIMARY KEY (transaction_type_code)\n)\n/*\nColumns in Ref_Transaction_Types and all categories for low cardinality columns :\ntransaction_type_code : PUR, SALE\ntransaction_type_description : Sale, Purchase\n*/\n \nCREATE TABLE \"Student_Tests_Taken\" (\n\tregistration_id INTEGER NOT NULL, \n\tdate_test_taken DATETIME NOT NULL, \n\ttest_result VARCHAR(255), \n\tFOREIGN KEY(registration_id) REFERENCES \"Student_Course_Enrolment\" (registration_id)\n)\n/*\nColumns in Student_Tests_Taken and 3 examples in each column for high cardinality columns :\ndate_test_taken : 2018-03-19 02:04:26, 2018-03-25 03:27:16, 2018-03-25 21:41:51\n*/\n/*\nColumns in Student_Tests_Taken and all categories for low cardinality columns :\nregistration_id : 16, 2, 5, 7, 17, 4, 12, 19, 10, 9\ntest_result : Fail, Pass\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 nomination (\n\t\"Artwork_ID\" INTEGER, \n\t\"Festival_ID\" INTEGER, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"Artwork_ID\", \"Festival_ID\"), \n\tFOREIGN KEY(\"Festival_ID\") REFERENCES festival_detail (\"Festival_ID\"), \n\tFOREIGN KEY(\"Artwork_ID\") REFERENCES artwork (\"Artwork_ID\")\n)\n/*\nColumns in nomination and all categories for low cardinality columns :\nArtwork_ID : 1, 2, 8, 4, 3, 9\nFestival_ID : 1, 2, 5\nResult : Nominated, Won\n*/\n \nCREATE TABLE temperature (\n\t\"City_ID\" INTEGER, \n\t\"Jan\" REAL, \n\t\"Feb\" REAL, \n\t\"Mar\" REAL, \n\t\"Apr\" REAL, \n\t\"Jun\" REAL, \n\t\"Jul\" REAL, \n\t\"Aug\" REAL, \n\t\"Sep\" REAL, \n\t\"Oct\" REAL, \n\t\"Nov\" REAL, \n\t\"Dec\" REAL, \n\tPRIMARY KEY (\"City_ID\"), \n\tFOREIGN KEY(\"City_ID\") REFERENCES city (\"City_ID\")\n)\n/*\nColumns in temperature and all categories for low cardinality columns :\nCity_ID : 1, 11, 2, 7, 4, 6, 3, 10\nJan : 18.9, 25.6, 18.3, 26.1, 17.8, 26.7, 17.2\nFeb : 18.9, 18.3, 26.1, 27.2, 17.8, 26.6, 17.2\nMar : 19.4, 18.3, 26.1, 26.6, 27.8\nApr : 18.9, 26.1, 20.6, 28.3, 27.8, 20.0\nJun : 22.8, 30.0, 30.6, 22.2, 20.6, 28.3, 27.8, 20.0\nJul : 31.1, 23.3, 28.9, 30.6, 20.6, 21.7, 27.8\nAug : 31.1, 31.7, 23.9, 23.3, 29.4, 20.6, 21.7, 28.3\nSep : 31.1, 21.1, 31.7, 23.3, 29.4, 20.6, 28.3\nOct : 22.8, 30.6, 28.9, 20.6, 28.3, 20.0\nNov : 19.4, 27.2, 28.9, 21.7, 20.0\nDec : 18.3, 26.1, 26.7, 27.8, 20.0\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 \"Customer_Payments\" (\n\tcustomer_id INTEGER NOT NULL, \n\tdatetime_payment DATETIME NOT NULL, \n\tpayment_method_code VARCHAR(10) NOT NULL, \n\tamount_payment DOUBLE, \n\tPRIMARY KEY (customer_id, datetime_payment), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Customer_Payments and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\ndatetime_payment : 2018-03-20 21:38:41, 2018-02-15 16:38:49, 2018-02-19 01:49:59\namount_payment : 9570.93, 6782.84, 787.12\n*/\n/*\nColumns in Customer_Payments and all categories for low cardinality columns :\npayment_method_code : Direct Debit, Credit Card\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 \"Agreements\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Event_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES \"Events\" (\"Event_ID\")\n)\n/*\nColumns in Agreements and 3 examples in each column for high cardinality columns :\nDocument_ID : 1, 13, 11\n*/\n/*\nColumns in Agreements and all categories for low cardinality columns :\nEvent_ID : 13, 11, 10, 5, 8, 6, 12, 15, 9\n*/\n \nCREATE TABLE \"Accounts\" (\n\taccount_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\taccount_name VARCHAR(50), \n\tother_account_details VARCHAR(255), \n\tPRIMARY KEY (account_id)\n)\n/*\nColumns in Accounts and 3 examples in each column for high cardinality columns :\naccount_id : 1, 13, 11\naccount_name : 866, 725, 858\n*/\n/*\nColumns in Accounts and all categories for low cardinality columns :\ncustomer_id : 13, 2, 8, 4, 6, 12, 14, 10, 9\nother_account_details : VIP, Regular\n*/\n \nCREATE TABLE \"Activity\" (\n\tactid INTEGER, \n\tactivity_name VARCHAR(25), \n\tPRIMARY KEY (actid)\n)\n/*\nColumns in Activity and 3 examples in each column for high cardinality columns :\nactid : 771, 782, 770\nactivity_name : Proselytizing, Spelunking, Extreme Canasta\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 \"Characteristics\" (\n\tcharacteristic_id INTEGER, \n\tcharacteristic_type_code VARCHAR(15) NOT NULL, \n\tcharacteristic_data_type VARCHAR(10), \n\tcharacteristic_name VARCHAR(80), \n\tother_characteristic_details VARCHAR(255), \n\tPRIMARY KEY (characteristic_id), \n\tFOREIGN KEY(characteristic_type_code) REFERENCES \"Ref_Characteristic_Types\" (characteristic_type_code)\n)\n/*\nColumns in Characteristics and 3 examples in each column for high cardinality columns :\ncharacteristic_id : 1, 13, 11\ncharacteristic_data_type : placeat, dolores, mollitia\n*/\n/*\nColumns in Characteristics and all categories for low cardinality columns :\ncharacteristic_type_code : Grade, Purity\ncharacteristic_name : hot, error, cool, fast, warm, slow\nother_characteristic_details : None\n*/\n" }, { "role": "user", "content": "Find the name and city of the airport which is the source for the most number of flight routes." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.city, routes.src_apid, airports.apid.\nThe SQL query I'll be generating is:\nSELECT T1.name , T1.city , T2.src_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T2.src_apid 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 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 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 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 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 \"Students_in_Detention\" (\n\tstudent_id INTEGER NOT NULL, \n\tdetention_id INTEGER NOT NULL, \n\tincident_id INTEGER NOT NULL, \n\tFOREIGN KEY(student_id) REFERENCES \"Students\" (student_id), \n\tFOREIGN KEY(detention_id) REFERENCES \"Detention\" (detention_id), \n\tFOREIGN KEY(incident_id) REFERENCES \"Behavior_Incident\" (incident_id)\n)\n/*\nColumns in Students_in_Detention and all categories for low cardinality columns :\nstudent_id : 3, 13, 11, 7, 8, 14, 12, 10, 9\ndetention_id : 3, 13, 2, 7, 6, 12, 14, 15, 9\nincident_id : 1, 13, 11, 8, 12, 3, 14, 15\n*/\n \nCREATE TABLE \"Track\" (\n\t\"TrackId\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(200) NOT NULL, \n\t\"AlbumId\" INTEGER DEFAULT NULL, \n\t\"MediaTypeId\" INTEGER NOT NULL, \n\t\"GenreId\" INTEGER DEFAULT NULL, \n\t\"Composer\" VARCHAR(220) DEFAULT NULL, \n\t\"Milliseconds\" INTEGER NOT NULL, \n\t\"Bytes\" INTEGER DEFAULT NULL, \n\t\"UnitPrice\" DECIMAL(10, 2) NOT NULL, \n\tPRIMARY KEY (\"TrackId\"), \n\tFOREIGN KEY(\"MediaTypeId\") REFERENCES \"MediaType\" (\"MediaTypeId\"), \n\tFOREIGN KEY(\"GenreId\") REFERENCES \"Genre\" (\"GenreId\"), \n\tFOREIGN KEY(\"AlbumId\") REFERENCES \"Album\" (\"AlbumId\")\n)\n/*\nColumns in Track and 3 examples in each column for high cardinality columns :\nTrackId : 87, 56, 65\nName : Snoopy's search-Red baron, The Winner Loses, Leave My Girl Alone\nAlbumId : 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 Track and all categories for low cardinality columns :\nMediaTypeId : 1, 2\nGenreId : 1, 2, 5, 4, 6, 3\nUnitPrice : 0.99\n*/\n \nCREATE TABLE \"Sales\" (\n\tsales_transaction_id INTEGER, \n\tsales_details VARCHAR(255), \n\tPRIMARY KEY (sales_transaction_id), \n\tFOREIGN KEY(sales_transaction_id) REFERENCES \"Transactions\" (transaction_id)\n)\n/*\nColumns in Sales and 3 examples in each column for high cardinality columns :\nsales_transaction_id : 1, 13, 11\n*/\n/*\nColumns in Sales and all categories for low cardinality columns :\nsales_details : t, f, s, e, y, n, x, p, o, a\n*/\n \nCREATE TABLE \"Claims\" (\n\t\"Claim_ID\" INTEGER NOT NULL, \n\t\"FNOL_ID\" INTEGER NOT NULL, \n\t\"Effective_Date\" DATE, \n\tPRIMARY KEY (\"Claim_ID\"), \n\tFOREIGN KEY(\"FNOL_ID\") REFERENCES \"First_Notification_of_Loss\" (\"FNOL_ID\"), \n\tUNIQUE (\"Claim_ID\")\n)\n/*\nColumns in Claims and all categories for low cardinality columns :\nClaim_ID : 428, 309, 717, 145, 228, 311, 360, 134, 641, 604\nFNOL_ID : 1611, 4226, 2543, 4525, 1722, 4323, 532\nEffective_Date : 1985-03-24, 1975-05-07, 1992-02-09, 2006-06-10, 1982-05-03, 1996-11-29, 1992-01-05, 1973-08-18, 2014-10-19, 2009-02-11\n*/\n \nCREATE TABLE workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\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 race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\n*/\n \nCREATE TABLE \"Asset_Parts\" (\n\tasset_id INTEGER NOT NULL, \n\tpart_id INTEGER NOT NULL, \n\tFOREIGN KEY(asset_id) REFERENCES \"Assets\" (asset_id), \n\tFOREIGN KEY(part_id) REFERENCES \"Parts\" (part_id)\n)\n/*\nColumns in Asset_Parts and all categories for low cardinality columns :\nasset_id : 1, 2, 5, 15, 4, 6, 14, 3, 10\npart_id : 1, 2, 3\n*/\n \nCREATE TABLE body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Date_of_Birth\" TEXT, \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\nName : Fabrizio Buonocore, Goran Fiorentini, Francesco Postiglione, Alberto Angelini, Leonardo Binchi, Marco Gerini, Roberto Calcaterra, Maurizio Felugo\nHeight : 1.9, 1.86, 1.72, 1.75, 1.95, 1.78, 1.82, 1.83\nWeight : 45.0, 89.0, 67.0, 58.0, 57.0, 75.0, 76.0, 80.0\nDate_of_Birth : 1975-08-27, 1971-08-05, 1972-04-29, 1977-04-28, 1981-03-04, 1972-02-06, 1981-11-21, 1974-09-28\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 is the name and city of the airport from most of the routes start?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.city, routes.src_apid, airports.apid.\nThe SQL query I'll be generating is:\nSELECT T1.name , T1.city , T2.src_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T2.src_apid 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 \"Scientists\" (\n\t\"SSN\" INTEGER, \n\t\"Name\" CHAR(30) NOT NULL, \n\tPRIMARY KEY (\"SSN\")\n)\n/*\nColumns in Scientists and 3 examples in each column for high cardinality columns :\nSSN : 546523478, 332569843, 845657246\nName : Kumar Swamy, John Doe, David Smith\n*/\n\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE tweets (\n\tid BIGINT NOT NULL, \n\tuid INTEGER NOT NULL, \n\ttext CHAR(140) NOT NULL, \n\tcreatedate DATETIME DEFAULT CURRENT_TIMESTAMP, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(uid) REFERENCES user_profiles (uid)\n)\n/*\nColumns in tweets and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 9\nuid : 1, 5, 4, 6, 3\ntext : Today I have went shopping at Laffayette., Let’s celebrate women, fight for equality and support each other, not just today, but everyday!, Oh, I only have a few fans., I love my new boyfriend., I feel tired and don't want to write SQLs., My company is hiring interns., Hello I'm Tony Stark., I had a pretty rough time during the last couple of weeks\ncreatedate : 2018-03-09 20:00:14, 2018-03-12 02:30:30, 2018-03-09 20:01:02\n*/\n \nCREATE TABLE farm (\n\t\"Farm_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Total_Horses\" REAL, \n\t\"Working_Horses\" REAL, \n\t\"Total_Cattle\" REAL, \n\t\"Oxen\" REAL, \n\t\"Bulls\" REAL, \n\t\"Cows\" REAL, \n\t\"Pigs\" REAL, \n\t\"Sheep_and_Goats\" REAL, \n\tPRIMARY KEY (\"Farm_ID\")\n)\n/*\nColumns in farm and all categories for low cardinality columns :\nFarm_ID : 1, 2, 5, 7, 8, 4, 6, 3\nYear : 1932, 1928, 1930, 1931, 1927, 1934, 1929, 1933\nTotal_Horses : 3658.9, 5056.5, 2546.9, 5607.5, 4781.3, 5308.2, 5486.9, 2604.8\nWorking_Horses : 3721.6, 3711.2, 3900.1, 3711.6, 4090.5, 4198.8, 2197.3, 3593.7\nTotal_Cattle : 6274.1, 4446.3, 6189.5, 8374.5, 5277.5, 7611.0, 5006.7, 8604.8\nOxen : 805.5, 895.3, 156.5, 593.7, 116.9, 113.8, 254.8, 105.2\nBulls : 49.6, 71.6, 40.0, 26.9, 32.8, 31.6, 37.6, 46.7\nCows : 3852.1, 2739.5, 2518.0, 2407.2, 3377.0, 3987.0, 3873.0, 3471.6\nPigs : 3171.8, 4236.7, 4161.2, 2089.2, 4412.4, 3373.3, 6962.9, 2623.7\nSheep_and_Goats : 7956.3, 7030.8, 2197.1, 2004.7, 3364.8, 4533.4, 2109.5, 8112.2\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Product_Characteristics\" (\n\tproduct_id INTEGER NOT NULL, \n\tcharacteristic_id INTEGER NOT NULL, \n\tproduct_characteristic_value VARCHAR(50), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(characteristic_id) REFERENCES \"Characteristics\" (characteristic_id)\n)\n/*\nColumns in Product_Characteristics and all categories for low cardinality columns :\nproduct_id : 1, 13, 11, 5, 7, 8, 6, 12, 14\ncharacteristic_id : 13, 10, 11, 2, 4, 6, 12, 3, 15\nproduct_characteristic_value : high, low, medium\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 \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 player (\n\t\"Player_ID\" INTEGER, \n\tname TEXT, \n\t\"Position\" TEXT, \n\t\"Club_ID\" INTEGER, \n\t\"Apps\" REAL, \n\t\"Tries\" REAL, \n\t\"Goals\" TEXT, \n\t\"Points\" REAL, \n\tPRIMARY KEY (\"Player_ID\"), \n\tFOREIGN KEY(\"Club_ID\") REFERENCES club (\"Club_ID\")\n)\n/*\nColumns in player and 3 examples in each column for high cardinality columns :\nPlayer_ID : 1, 13, 11\nname : Michael Platt, Tame Tupou, Terry Newton\nApps : 30.0, 29.0, 24.0\n*/\n/*\nColumns in player and all categories for low cardinality columns :\nPosition : Scrum Half, Right Centre, Prop, Loose Forward, Hooker, Right Wing, Stand Off, Second Row, Left Wing, Full Back\nClub_ID : 1, 2, 5, 4, 3\nTries : 3.0, 8.0, 1.0, 6.0, 9.0, 2.0, 4.0, 5.0\nGoals : 50/60, 90/106, 0/1, 0\nPoints : 36.0, 8.0, 16.0, 12.0, 24.0, 188.0, 32.0, 110.0, 4.0, 20.0\n*/\n \nCREATE TABLE \"Events\" (\n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Address_ID\" INTEGER, \n\t\"Channel_ID\" INTEGER NOT NULL, \n\t\"Event_Type_Code\" CHAR(15), \n\t\"Finance_ID\" INTEGER NOT NULL, \n\t\"Location_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Event_ID\"), \n\tFOREIGN KEY(\"Location_ID\") REFERENCES \"Locations\" (\"Location_ID\"), \n\tFOREIGN KEY(\"Address_ID\") REFERENCES \"Addresses\" (\"Address_ID\"), \n\tFOREIGN KEY(\"Finance_ID\") REFERENCES \"Finances\" (\"Finance_ID\"), \n\tUNIQUE (\"Event_ID\")\n)\n/*\nColumns in Events and 3 examples in each column for high cardinality columns :\nEvent_ID : 1, 13, 11\nChannel_ID : 1, 13, 11\nFinance_ID : 1, 13, 10\n*/\n/*\nColumns in Events and all categories for low cardinality columns :\nAddress_ID : 13, 10, 2, 12, 3, 14, 15, 9\nEvent_Type_Code : Press Conferenc, Seminar, Ceremonies, Conference, Trade Show\nLocation_ID : 13, 11, 10, 5, 7, 8, 6, 12, 15, 9\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 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 \"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 \"Companies\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value_billion\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Companies and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : PetroChina, Berkshire Hathaway, Petrobras\nSales_billion : 69.2, 189.6, 421.8\nProfits_billion : 16.4, 19.9, 17.4\nAssets_billion : 2467.9, 192.8, 1913.9\nMarket_Value_billion : 239.5, 186.5, 224.8\n*/\n/*\nColumns in Companies and all categories for low cardinality columns :\nHeadquarters : Spain, UK, China, Brazil, France, Russia, USA, Netherlands\nIndustry : Retailing, Conglomerate, Oil and gas, Telecommunications, Banking\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" }, { "role": "user", "content": "Find the number of different airports which are the destinations of the American Airlines." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines, routes.\nFrom these tables, I'll be using the following columns: dst_apid, airlines.alid, routes.alid, airlines.name.\nThe SQL query I'll be generating is:\nSELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'" } ]
[ { "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 \"Customer_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\" DATE, \n\t\"End_Date\" DATE, \n\tPRIMARY KEY (\"Policy_ID\"), \n\tFOREIGN KEY(\"Customer_ID\") REFERENCES \"Customers\" (\"Customer_ID\")\n)\n/*\nColumns in Customer_Policies and 3 examples in each column for high cardinality columns :\nPolicy_ID : 218, 143, 552\nCustomer_ID : 1, 13, 2\nStart_Date : 2016-12-25, 2016-07-17, 2017-04-24\nEnd_Date : 2017-11-23, 2018-01-25, 2017-12-09\n*/\n/*\nColumns in Customer_Policies and all categories for low cardinality columns :\nPolicy_Type_Code : Travel, Car, Life, Property\n*/\n \nCREATE TABLE \"Institution\" (\n\t\"Institution_id\" TEXT, \n\t\"Institution\" TEXT, \n\t\"Location\" TEXT, \n\t\"Founded\" REAL, \n\t\"Type\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"Team\" TEXT, \n\t\"Primary_Conference\" TEXT, \n\tbuilding_id TEXT, \n\tPRIMARY KEY (\"Institution_id\"), \n\tFOREIGN KEY(building_id) REFERENCES building (building_id)\n)\n/*\nColumns in Institution and 3 examples in each column for high cardinality columns :\nInstitution_id : 1, 2, 5\nInstitution : Ave Maria University, Lindenwood University–Belleville, Point University\nLocation : Mayville, North Dakota, Jacksonville, Florida, Babson Park, Florida\nEnrollment : 967, 616, 3102\nTeam : Gyrenes, Comets, Warriors\n*/\n/*\nColumns in Institution and all categories for low cardinality columns :\nFounded : 1937.0, 1881.0, 1927.0, 2003.0, 1883.0, 1866.0, 1998.0, 1884.0, 1889.0, 1890.0\nType : Public, Tribal, Private\nPrimary_Conference : MCAC, CalPac, Gulf Coast (GCAC), AAC, none, The Sun\nbuilding_id : 1, 2, 5, 7, 4, 3, 0\n*/\n \nCREATE TABLE \"Participates_in\" (\n\tstuid INTEGER, \n\tactid INTEGER, \n\tFOREIGN KEY(stuid) REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(actid) REFERENCES \"Activity\" (actid)\n)\n/*\nColumns in Participates_in and 3 examples in each column for high cardinality columns :\nstuid : 1003, 1017, 1002\nactid : 771, 782, 770\n*/\n\n \nCREATE TABLE \"Ref_Locations\" (\n\t\"Location_Code\" CHAR(15) NOT NULL, \n\t\"Location_Name\" VARCHAR(255) NOT NULL, \n\t\"Location_Description\" VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (\"Location_Code\")\n)\n/*\nColumns in Ref_Locations and all categories for low cardinality columns :\nLocation_Code : b, e, n, x, c\nLocation_Name : Canada, Xiamen, Nanjing, Brazil, Edinburgh\nLocation_Description : \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 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 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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\nproduct_id : 13, 11, 2\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\norder_id : 1, 13, 5, 7, 8, 6, 14, 12, 15, 9\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 manufacturer (\n\t\"Manufacturer_ID\" INTEGER, \n\t\"Open_Year\" REAL, \n\t\"Name\" TEXT, \n\t\"Num_of_Factories\" INTEGER, \n\t\"Num_of_Shops\" INTEGER, \n\tPRIMARY KEY (\"Manufacturer_ID\")\n)\n/*\nColumns in manufacturer and all categories for low cardinality columns :\nManufacturer_ID : 1, 2, 5, 7, 4, 6, 3\nOpen_Year : 2001.0, 2008.0, 2000.0, 1980.0, 1992.0, 1991.0, 1990.0\nName : Tomorrow, Chevrolet, Chevrolet House, Jiaju, Ford Make, IKEA, Dodge\nNum_of_Factories : 1, 38, 36, 21, 12, 3\nNum_of_Shops : 2, 7, 8, 24, 4, 19, 35\n*/\n \nCREATE TABLE staff (\n\tstaff_id INTEGER NOT NULL, \n\tfirst_name VARCHAR(45) NOT NULL, \n\tlast_name VARCHAR(45) NOT NULL, \n\taddress_id INTEGER NOT NULL, \n\tpicture BLOB DEFAULT NULL, \n\temail VARCHAR(50) DEFAULT NULL, \n\tstore_id INTEGER NOT NULL, \n\tactive BOOLEAN DEFAULT TRUE NOT NULL, \n\tusername VARCHAR(16) NOT NULL, \n\tpassword VARCHAR(40) DEFAULT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (staff_id), \n\tFOREIGN KEY(address_id) REFERENCES address (address_id)\n)\n/*\nColumns in staff and all categories for low cardinality columns :\nstaff_id : \nfirst_name : \nlast_name : \naddress_id : \npicture : \nemail : \nstore_id : \nactive : \nusername : \npassword : \nlast_update : \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 film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\n*/\n \nCREATE TABLE \"Customers\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Customer_Details\" VARCHAR(255) NOT NULL, \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_Details : Miss Felicita Reichel, Selena Gerhold, Mrs. Liza Heller V\n*/\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 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 language (\n\tlanguage_id INTEGER NOT NULL, \n\tname CHAR(20) NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (language_id)\n)\n/*\nColumns in language and all categories for low cardinality columns :\nlanguage_id : \nname : \nlast_update : \n*/\n \nCREATE TABLE \"Band\" (\n\t\"Id\" INTEGER, \n\t\"Firstname\" TEXT, \n\t\"Lastname\" TEXT, \n\tPRIMARY KEY (\"Id\")\n)\n/*\nColumns in Band and all categories for low cardinality columns :\nId : \nFirstname : \nLastname : \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" }, { "role": "user", "content": "What is the number of different different airports that are destinations for American Airlines?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines, routes.\nFrom these tables, I'll be using the following columns: dst_apid, airlines.alid, routes.alid, airlines.name.\nThe SQL query I'll be generating is:\nSELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'" } ]
[ { "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 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 \"Project_Staff\" (\n\tstaff_id DOUBLE, \n\tproject_id INTEGER NOT NULL, \n\trole_code VARCHAR(10) NOT NULL, \n\tdate_from DATETIME, \n\tdate_to DATETIME, \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (staff_id), \n\tFOREIGN KEY(role_code) REFERENCES \"Staff_Roles\" (role_code), \n\tFOREIGN KEY(project_id) REFERENCES \"Projects\" (project_id)\n)\n/*\nColumns in Project_Staff and 3 examples in each column for high cardinality columns :\nstaff_id : 3.0, 5137097.0, 45.0\ndate_from : 1981-10-04 22:44:50, 2000-08-28 11:49:17, 2005-01-13 11:49:48\ndate_to : 1988-03-04 19:30:05, 2004-07-28 03:11:47, 1971-07-19 22:49:05\n*/\n/*\nColumns in Project_Staff and all categories for low cardinality columns :\nproject_id : 1, 11, 2, 5, 7, 8, 4, 3, 15, 9\nrole_code : researcher, leader\nother_details : None\n*/\n \nCREATE TABLE stadium (\n\t\"ID\" INTEGER, \n\tname TEXT, \n\t\"Capacity\" INTEGER, \n\t\"City\" TEXT, \n\t\"Country\" TEXT, \n\t\"Opening_year\" INTEGER, \n\tPRIMARY KEY (\"ID\")\n)\n/*\nColumns in stadium and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Northumberland Development Project, Fisht Olympic Stadium, Ferenc Puskás Stadion, Nou Mestalla, Yubileyniy Stadium, Estadio La Peineta, Baku Olympic Stadium, Arena Baltika, Stade des Lumières, Gazprom Arena\nCapacity : 61556, 69501, 56250, 68000, 47659, 45015, 67500, 75000, 65000\nCity : London, Sochi, Budapest, Saint Petersburg, Baku, Kaliningrad, Madrid, Valencia, Lyon, Saransk\nCountry : Spain, France, England, Russia, Azerbaijan, Hungary\nOpening_year : 2004, 2005, 2007, 2006\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE farm (\n\t\"Farm_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Total_Horses\" REAL, \n\t\"Working_Horses\" REAL, \n\t\"Total_Cattle\" REAL, \n\t\"Oxen\" REAL, \n\t\"Bulls\" REAL, \n\t\"Cows\" REAL, \n\t\"Pigs\" REAL, \n\t\"Sheep_and_Goats\" REAL, \n\tPRIMARY KEY (\"Farm_ID\")\n)\n/*\nColumns in farm and all categories for low cardinality columns :\nFarm_ID : 1, 2, 5, 7, 8, 4, 6, 3\nYear : 1932, 1928, 1930, 1931, 1927, 1934, 1929, 1933\nTotal_Horses : 3658.9, 5056.5, 2546.9, 5607.5, 4781.3, 5308.2, 5486.9, 2604.8\nWorking_Horses : 3721.6, 3711.2, 3900.1, 3711.6, 4090.5, 4198.8, 2197.3, 3593.7\nTotal_Cattle : 6274.1, 4446.3, 6189.5, 8374.5, 5277.5, 7611.0, 5006.7, 8604.8\nOxen : 805.5, 895.3, 156.5, 593.7, 116.9, 113.8, 254.8, 105.2\nBulls : 49.6, 71.6, 40.0, 26.9, 32.8, 31.6, 37.6, 46.7\nCows : 3852.1, 2739.5, 2518.0, 2407.2, 3377.0, 3987.0, 3873.0, 3471.6\nPigs : 3171.8, 4236.7, 4161.2, 2089.2, 4412.4, 3373.3, 6962.9, 2623.7\nSheep_and_Goats : 7956.3, 7030.8, 2197.1, 2004.7, 3364.8, 4533.4, 2109.5, 8112.2\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE round (\n\t\"Round_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Decoration_Theme\" TEXT, \n\t\"Rank_in_Round\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\", \"Round_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in round and all categories for low cardinality columns :\nRound_ID : 1, 2\nMember_ID : 1, 2, 4, 6, 10, 9\nDecoration_Theme : Dark Nights, Summer, Walk on the Moon, Sweetie, Soft Dream, Happiness\nRank_in_Round : 1, 2, 4, 3\n*/\n \nCREATE TABLE \"Web_client_accelerator\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Operating_system\" TEXT, \n\t\"Client\" TEXT, \n\t\"Connection\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Web_client_accelerator and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : Freewire, Toonel, Fasterfox\nOperating_system : Unix (Linux, *BSD, Mac OS X, others), Windows, Windows, Mac and Mobile devices, Windows, Mac, Mobile devices\n*/\n/*\nColumns in Web_client_accelerator and all categories for low cardinality columns :\nClient : End User, ISP, End user, ISP, user/Google server, user/Opera server, user/ISP, ISP, All, user\nConnection : up to 756kbit/s, Broadband, Any, Broadband, Satellite, Wireless, Fiber, DSL, Dial, DSL, ISDN, Satellite, wireless, Dial-up, Broadband, DSL, ISDN, Satellite, Wireless, Dialup, Wireless, Broadband, DSL, Dial-up\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 jobs (\n\t\"JOB_ID\" VARCHAR(10) DEFAULT '' NOT NULL, \n\t\"JOB_TITLE\" VARCHAR(35) NOT NULL, \n\t\"MIN_SALARY\" DECIMAL(6, 0) DEFAULT NULL, \n\t\"MAX_SALARY\" DECIMAL(6, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"JOB_ID\")\n)\n/*\nColumns in jobs and 3 examples in each column for high cardinality columns :\nJOB_ID : HR_REP, ST_MAN, AD_PRES\nJOB_TITLE : Purchasing Clerk, Stock Clerk, Marketing Manager\nMIN_SALARY : 20000, 8000, 3000\nMAX_SALARY : 20000, 8500, 40000\n*/\n\n \nCREATE TABLE weather (\n\tdate TEXT, \n\tmax_temperature_f INTEGER, \n\tmean_temperature_f INTEGER, \n\tmin_temperature_f INTEGER, \n\tmax_dew_point_f INTEGER, \n\tmean_dew_point_f INTEGER, \n\tmin_dew_point_f INTEGER, \n\tmax_humidity INTEGER, \n\tmean_humidity INTEGER, \n\tmin_humidity INTEGER, \n\tmax_sea_level_pressure_inches NUMERIC, \n\tmean_sea_level_pressure_inches NUMERIC, \n\tmin_sea_level_pressure_inches NUMERIC, \n\tmax_visibility_miles INTEGER, \n\tmean_visibility_miles INTEGER, \n\tmin_visibility_miles INTEGER, \n\t\"max_wind_Speed_mph\" INTEGER, \n\tmean_wind_speed_mph INTEGER, \n\tmax_gust_speed_mph INTEGER, \n\tprecipitation_inches INTEGER, \n\tcloud_cover INTEGER, \n\tevents TEXT, \n\twind_dir_degrees INTEGER, \n\tzip_code INTEGER\n)\n/*\nColumns in weather and 3 examples in each column for high cardinality columns :\ndate : 10/28/2013, 9/8/2013, 9/27/2013\nmax_temperature_f : 87, 53, 56\nmean_temperature_f : 53, 56, 65\nmin_temperature_f : 53, 56, 49\nmax_dew_point_f : 53, 56, 49\nmean_dew_point_f : 53, 56, 49\nmin_dew_point_f : 53, 56, 49\nmax_humidity : 87, 53, 56\nmean_humidity : 79, 53, 87\nmin_humidity : 53, 56, 65\nmax_sea_level_pressure_inches : 30.1500000000, 30.1800000000, 30.0700000000\nmean_sea_level_pressure_inches : 29.4300000000, 30.1500000000, 30.1800000000\nmin_sea_level_pressure_inches : 30.1800000000, 30.0700000000, 30.0600000000\nmin_visibility_miles : 1, 2, 5\nmax_wind_Speed_mph : 36, 17, 21\nmean_wind_speed_mph : 19, 21, 9\nmax_gust_speed_mph : , 36, 17\nprecipitation_inches : 0.42, 0.09, 0.64\nwind_dir_degrees : 75, 291, 304\n*/\n/*\nColumns in weather and all categories for low cardinality columns :\nmax_visibility_miles : 10, 9\nmean_visibility_miles : 5, 7, 8, 6, 10, 9\ncloud_cover : 1, 2, 5, 7, 8, 4, 6, 3, 0\nevents : , rain, Rain, Fog-Rain, Fog\nzip_code : 94107, 94063\n*/\n \nCREATE TABLE \"Plays_Games\" (\n\t\"StuID\" INTEGER, \n\t\"GameID\" INTEGER, \n\t\"Hours_Played\" INTEGER, \n\tFOREIGN KEY(\"GameID\") REFERENCES \"Video_Games\" (\"GameID\"), \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\")\n)\n/*\nColumns in Plays_Games and all categories for low cardinality columns :\nStuID : 1007, 1008, 1032, 1010, 1001\nGameID : 1, 2, 5, 4, 6, 3\nHours_Played : 1, 100, 10, 1000, 50, 47, 15, 1337, 35\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 \"Authors\" (\n\t\"authID\" INTEGER, \n\tlname TEXT, \n\tfname TEXT, \n\tPRIMARY KEY (\"authID\")\n)\n/*\nColumns in Authors and 3 examples in each column for high cardinality columns :\nauthID : 53, 56, 57\nlname : Gibbons, Turon, Ueno\nfname : Daniel W. H., Tim, Ralf\n*/\n\n \nCREATE TABLE \"Tourist_Attraction_Features\" (\n\t\"Tourist_Attraction_ID\" INTEGER NOT NULL, \n\t\"Feature_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Tourist_Attraction_ID\", \"Feature_ID\"), \n\tFOREIGN KEY(\"Tourist_Attraction_ID\") REFERENCES \"Tourist_Attractions\" (\"Tourist_Attraction_ID\"), \n\tFOREIGN KEY(\"Feature_ID\") REFERENCES \"Features\" (\"Feature_ID\")\n)\n/*\nColumns in Tourist_Attraction_Features and 3 examples in each column for high cardinality columns :\nTourist_Attraction_ID : 5076, 8429, 6852\n*/\n/*\nColumns in Tourist_Attraction_Features and all categories for low cardinality columns :\nFeature_ID : 955, 543, 681, 528, 523\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(20), \n\tproduct_price DECIMAL(19, 4), \n\tproduct_description VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 1, 2, 5, 4, 6, 3\nproduct_name : electronics, food, dvds, cloth, gift, books\nproduct_price : 5022.3900, 3644.4500, 1322.7800, 2511.2900, 7111.6800, 6402.0900\nproduct_description : great condition, bad condition, good condition\n*/\n \nCREATE TABLE \"PersonFriend\" (\n\tname VARCHAR(20), \n\tfriend VARCHAR(20), \n\tyear INTEGER, \n\tFOREIGN KEY(name) REFERENCES \"Person\" (name), \n\tFOREIGN KEY(friend) REFERENCES \"Person\" (name)\n)\n/*\nColumns in PersonFriend and all categories for low cardinality columns :\nname : Alice, Zach, Bob\nfriend : Alice, Dan, Zach, Bob\nyear : 10, 5, 6, 12\n*/\n" }, { "role": "user", "content": "Which countries has the most number of airlines?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines.\nFrom these tables, I'll be using the following columns: country.\nThe SQL query I'll be generating is:\nSELECT country FROM airlines GROUP BY country 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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Problem_Category_Codes\" (\n\tproblem_category_code VARCHAR(20), \n\tproblem_category_description VARCHAR(80), \n\tPRIMARY KEY (problem_category_code)\n)\n/*\nColumns in Problem_Category_Codes and all categories for low cardinality columns :\nproblem_category_code : Datatabase, Middleware, GUI\nproblem_category_description : User Interface., Infrastructrure and Architecture, Database design or contents.\n*/\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 \"Student_Tests_Taken\" (\n\tregistration_id INTEGER NOT NULL, \n\tdate_test_taken DATETIME NOT NULL, \n\ttest_result VARCHAR(255), \n\tFOREIGN KEY(registration_id) REFERENCES \"Student_Course_Enrolment\" (registration_id)\n)\n/*\nColumns in Student_Tests_Taken and 3 examples in each column for high cardinality columns :\ndate_test_taken : 2018-03-19 02:04:26, 2018-03-25 03:27:16, 2018-03-25 21:41:51\n*/\n/*\nColumns in Student_Tests_Taken and all categories for low cardinality columns :\nregistration_id : 16, 2, 5, 7, 17, 4, 12, 19, 10, 9\ntest_result : Fail, Pass\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 \"match\" (\n\t\"Round\" REAL, \n\t\"Location\" TEXT, \n\t\"Country\" TEXT, \n\t\"Date\" TEXT, \n\t\"Fastest_Qualifying\" TEXT, \n\t\"Winning_Pilot\" TEXT, \n\t\"Winning_Aircraft\" TEXT, \n\tPRIMARY KEY (\"Round\"), \n\tFOREIGN KEY(\"Winning_Pilot\") REFERENCES pilot (\"Pilot_Id\"), \n\tFOREIGN KEY(\"Winning_Aircraft\") REFERENCES aircraft (\"Aircraft_ID\")\n)\n/*\nColumns in match and all categories for low cardinality columns :\nRound : 3.0, 1.0, 7.0, 2.0, 6.0, 4.0, 5.0\nLocation : EuroSpeedway Lausitz, Flamengo Beach , Rio de Janeiro, River Danube , Budapest, Swan River , Perth, Mina' Zayid , Abu Dhabi, New York City, Windsor , Ontario\nCountry : Canada, United States, Australia, Brazil, Germany, United Arab Emirates, Hungary\nDate : June 5–6, June 19–20, August 7–8, May 8–9, March 26–27, April 17–18, Cancelled\nFastest_Qualifying : Hannes Arch, Paul Bonhomme, Cancelled, Nigel Lamb\nWinning_Pilot : 1, 2, 4, 6, 9\nWinning_Aircraft : 1, 2, 5, 4, 3\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 stock (\n\t\"Shop_ID\" INTEGER, \n\t\"Device_ID\" INTEGER, \n\t\"Quantity\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\", \"Device_ID\"), \n\tFOREIGN KEY(\"Device_ID\") REFERENCES device (\"Device_ID\"), \n\tFOREIGN KEY(\"Shop_ID\") REFERENCES shop (\"Shop_ID\")\n)\n/*\nColumns in stock and all categories for low cardinality columns :\nShop_ID : 1, 11, 2, 4, 3, 9\nDevice_ID : 4, 6\nQuantity : 110, 56, 124, 100, 200, 112, 134, 51\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 enrollments (\n\t\"Campus\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"TotalEnrollment_AY\" INTEGER, \n\t\"FTE_AY\" INTEGER, \n\tPRIMARY KEY (\"Campus\", \"Year\"), \n\tFOREIGN KEY(\"Campus\") REFERENCES \"Campuses\" (\"Id\")\n)\n/*\nColumns in enrollments and 3 examples in each column for high cardinality columns :\nYear : 1979, 2004, 1937\nTotalEnrollment_AY : 495, 5734, 9547\nFTE_AY : 3877, 14324, 12876\n*/\n/*\nColumns in enrollments and all categories for low cardinality columns :\nCampus : 1, 2, 5, 4, 3\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 member (\n\t\"Member_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Country\" TEXT, \n\t\"College_ID\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\"), \n\tFOREIGN KEY(\"College_ID\") REFERENCES college (\"College_ID\")\n)\n/*\nColumns in member and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Tom Weiskopf, Tom Watson, Pat Fitzsimons, Homero Blancas, Jack Nicklaus, Billy Casper, J. C. Snead, Arnold Palmer, Lee Trevino, Bobby Nichols\nCountry : United States, Canada\nCollege_ID : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\n*/\n \nCREATE TABLE \"Customer_Addresses\" (\n\tcustomer_id INTEGER NOT NULL, \n\taddress_id INTEGER NOT NULL, \n\tdate_from DATETIME NOT NULL, \n\taddress_type VARCHAR(10) NOT NULL, \n\tdate_to DATETIME, \n\tFOREIGN KEY(address_id) REFERENCES \"Addresses\" (address_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Customer_Addresses and 3 examples in each column for high cardinality columns :\ndate_from : 2010-12-29 11:01:39, 2013-05-06 00:49:45, 2012-08-31 15:41:03\ndate_to : 2018-03-22 02:54:10, 2018-02-25 15:34:58, 2018-03-02 23:42:49\n*/\n/*\nColumns in Customer_Addresses and all categories for low cardinality columns :\ncustomer_id : 1, 2, 5, 7, 8, 4, 14, 3, 12, 10\naddress_id : 1, 11, 2, 5, 7, 6, 3, 10, 9\naddress_type : Flat, Apartment, House\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 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 team (\n\t\"Team_id\" INTEGER, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Team_id\")\n)\n/*\nColumns in team and all categories for low cardinality columns :\nTeam_id : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Enrique Osinski, Berneice Hand, Columbus Crew, Evalyn Feil, D.C. United, Anais VonRueden, Ryley Goldner, Miami Fusion, Los Angeles Galaxy, Brown Erdman\n*/\n" }, { "role": "user", "content": "What is the name of the country with the most number of home airlines?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines.\nFrom these tables, I'll be using the following columns: country.\nThe SQL query I'll be generating is:\nSELECT country FROM airlines GROUP BY country 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 race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\n*/\n \nCREATE TABLE endowment (\n\tendowment_id INTEGER, \n\t\"School_id\" INTEGER, \n\tdonator_name TEXT, \n\tamount REAL, \n\tPRIMARY KEY (endowment_id), \n\tFOREIGN KEY(\"School_id\") REFERENCES \"School\" (\"School_id\")\n)\n/*\nColumns in endowment and 3 examples in each column for high cardinality columns :\nendowment_id : 1, 11, 2\ndonator_name : Santo Domingo Este, Duarte, San Cristóbal\namount : 9.05, 8.82, 8.85\n*/\n/*\nColumns in endowment and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 7, 8, 4, 6, 3\n*/\n \nCREATE TABLE \"Affiliated_With\" (\n\t\"Physician\" INTEGER NOT NULL, \n\t\"Department\" INTEGER NOT NULL, \n\t\"PrimaryAffiliation\" BOOLEAN NOT NULL, \n\tPRIMARY KEY (\"Physician\", \"Department\"), \n\tCONSTRAINT \"fk_Affiliated_With_Physician_EmployeeID\" FOREIGN KEY(\"Physician\") REFERENCES \"Physician\" (\"EmployeeID\"), \n\tCONSTRAINT \"fk_Affiliated_With_Department_DepartmentID\" FOREIGN KEY(\"Department\") REFERENCES \"Department\" (\"DepartmentID\")\n)\n/*\nColumns in Affiliated_With and all categories for low cardinality columns :\nPhysician : 1, 2, 5, 7, 8, 4, 6, 3, 9\nDepartment : 1, 2, 3\nPrimaryAffiliation : False, True\n*/\n \nCREATE TABLE \"Companies\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value_billion\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Companies and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : PetroChina, Berkshire Hathaway, Petrobras\nSales_billion : 69.2, 189.6, 421.8\nProfits_billion : 16.4, 19.9, 17.4\nAssets_billion : 2467.9, 192.8, 1913.9\nMarket_Value_billion : 239.5, 186.5, 224.8\n*/\n/*\nColumns in Companies and all categories for low cardinality columns :\nHeadquarters : Spain, UK, China, Brazil, France, Russia, USA, Netherlands\nIndustry : Retailing, Conglomerate, Oil and gas, Telecommunications, Banking\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 \"Department_Store_Chain\" (\n\tdept_store_chain_id INTEGER, \n\tdept_store_chain_name VARCHAR(80), \n\tPRIMARY KEY (dept_store_chain_id)\n)\n/*\nColumns in Department_Store_Chain and all categories for low cardinality columns :\ndept_store_chain_id : 1, 2, 4, 3\ndept_store_chain_name : West, East, North, South\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 photos (\n\tid INTEGER, \n\tcamera_lens_id INTEGER, \n\tmountain_id INTEGER, \n\tcolor TEXT, \n\tname TEXT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(mountain_id) REFERENCES mountain (id), \n\tFOREIGN KEY(camera_lens_id) REFERENCES camera_lens (id)\n)\n/*\nColumns in photos and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\ncamera_lens_id : 1, 5, 7, 6, 10\nmountain_id : 1, 20, 2, 14, 12, 10\ncolor : Black/White, RBG\nname : life, wolfs, deers, grass, rabbits, sunset, cloud, river, monkey, the mountain\n*/\n \nCREATE TABLE mountain (\n\tid INTEGER, \n\tname TEXT, \n\t\"Height\" REAL, \n\t\"Prominence\" REAL, \n\t\"Range\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in mountain and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Kaka / Kecha / Chiqe, Aksouâl, Ioll / Yoll\nHeight : 4167.0, 4120.0, 4071.0\nProminence : 1540.0, 3931.0, 610.0\nRange : Toubkal Atlas, Aberdare Range, Semien Mountains\n*/\n/*\nColumns in mountain and all categories for low cardinality columns :\nCountry : Cameroon, Morocco, Kenya, Rwanda Uganda, Ethiopia\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 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 rental (\n\trental_id INTEGER NOT NULL, \n\trental_date DATETIME NOT NULL, \n\tinventory_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\treturn_date DATETIME DEFAULT NULL, \n\tstaff_id INTEGER NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (rental_id), \n\tFOREIGN KEY(staff_id) REFERENCES staff (staff_id), \n\tFOREIGN KEY(inventory_id) REFERENCES inventory (inventory_id), \n\tFOREIGN KEY(customer_id) REFERENCES customer (customer_id)\n)\n/*\nColumns in rental and 3 examples in each column for high cardinality columns :\nrental_id : 87, 56, 65\nrental_date : 2005-05-25 01:48:41, 2005-05-26 04:26:06, 2005-05-25 08:53:14\ninventory_id : 3938, 815, 1689\ncustomer_id : 586, 56, 75\nreturn_date : 2005-06-02 22:11:28, 2005-05-26 04:52:23, 2005-05-28 12:13:24\n*/\n/*\nColumns in rental and all categories for low cardinality columns :\nstaff_id : 1, 2\nlast_update : 2006-02-15 21:30:53\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 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 company (\n\t\"Company_ID\" INTEGER, \n\t\"Rank\" INTEGER, \n\t\"Company\" TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Main_Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value\" REAL, \n\tPRIMARY KEY (\"Company_ID\")\n)\n/*\nColumns in company and all categories for low cardinality columns :\nCompany_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nRank : 1, 11, 5, 7, 8, 4, 6, 3, 10, 9\nCompany : ExxonMobil, HSBC, General Electric, PetroChina, Industrial and Commercial Bank of China, Wells Fargo, Berkshire Hathaway, Petrobras, Royal Dutch Shell, BP\nHeadquarters : UK, China, Brazil, USA, Netherlands\nMain_Industry : Conglomerate, Banking, Oil and gas\nSales_billion : 143.7, 310.1, 433.5, 147.3, 470.2, 145.9, 87.6, 82.6, 375.5, 102.0\nProfits_billion : 20.1, 41.1, 30.9, 25.1, 14.2, 25.7, 20.6, 16.2, 15.9, 10.3\nAssets_billion : 1313.9, 319.4, 717.2, 340.5, 331.1, 2039.1, 292.5, 304.7, 392.6, 2550.0\nMarket_Value : 237.4, 213.7, 227.6, 147.4, 164.3, 202.2, 294.7, 180.0, 407.4, 178.7\n*/\n \nCREATE TABLE railway (\n\t\"Railway_ID\" INTEGER, \n\t\"Railway\" TEXT, \n\t\"Builder\" TEXT, \n\t\"Built\" TEXT, \n\t\"Wheels\" TEXT, \n\t\"Location\" TEXT, \n\t\"ObjectNumber\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\")\n)\n/*\nColumns in railway and all categories for low cardinality columns :\nRailway_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nRailway : Longmoor, LTSR, GWRWk, GERSt, GWRSn, GERHt, MR, SECR, GWRS, GNRD\nBuilder : GNR Doncaster, Stephenson, Swindon Works, GWR Swindon, GER Stratford, MR Derby, GER Hartford, SECR Ashford, Avonside\nBuilt : 1902 Midland Railway 1000 was rebuilt in 1914., 1902, 1901, 1905, 1907, 1903, 1904, 1909, 1910\nWheels : 4-4-0, 4-6-0, 0-6-0T, 4-4-2, 4-4-2T, 2-8-0, 0-6-0, 0-6-0ST\nLocation : Shildon, Swindon, Basingstoke, York, Toddington, Barrow Hill, Bressingham, Bo'ness\nObjectNumber : 1975-7005, 1978-7028, 1978-7025, 1975-7003, 1978-7026, 2008-7159, 1975-7006, 1978-7027, 1975-7018, 1976-7001\n*/\n" }, { "role": "user", "content": "Which countries has the most number of airlines whose active status is 'Y'?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines.\nFrom these tables, I'll be using the following columns: country, active.\nThe SQL query I'll be generating is:\nSELECT country FROM airlines WHERE active = 'Y' GROUP BY country 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 inventory (\n\tinventory_id INTEGER NOT NULL, \n\tfilm_id INTEGER NOT NULL, \n\tstore_id INTEGER NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (inventory_id), \n\tFOREIGN KEY(store_id) REFERENCES store (store_id), \n\tFOREIGN KEY(film_id) REFERENCES film (film_id)\n)\n/*\nColumns in inventory and 3 examples in each column for high cardinality columns :\ninventory_id : 87, 56, 65\nfilm_id : 44, 17, 21\n*/\n/*\nColumns in inventory and all categories for low cardinality columns :\nstore_id : 1, 2\nlast_update : 2006-02-15 05:09:17\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduct_category_code VARCHAR(20) NOT NULL, \n\tdate_product_first_available DATETIME, \n\tdate_product_discontinued DATETIME, \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tproduct_price DECIMAL(19, 4), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\nparent_product_id : 8, 4, 9, 3\nproduct_category_code : Food, Book, Hardware\ndate_product_first_available : 1988-09-29 17:54:50, 1998-06-20 15:04:11, 1994-12-18 15:13:19, 1974-06-25 12:26:47\ndate_product_discontinued : 1987-12-20 13:46:16, 1997-07-02 18:26:16, 1980-06-26 10:40:19, 1991-08-20 05:22:31\nproduct_name : Chocolate, The Great Gatsby, Mouse, Keyboard\nproduct_description : Designed for games, Handmade chocolate, American novel, Blue tooth mouse\nproduct_price : 23.3500, 2.8800, 109.9900, 35.0000\n*/\n \nCREATE TABLE appellations (\n\t\"No\" INTEGER, \n\t\"Appelation\" TEXT, \n\t\"County\" TEXT, \n\t\"State\" TEXT, \n\t\"Area\" TEXT, \n\t\"isAVA\" TEXT, \n\tPRIMARY KEY (\"No\"), \n\tUNIQUE (\"Appelation\")\n)\n/*\nColumns in appellations and 3 examples in each column for high cardinality columns :\nNo : 53, 56, 49\nAppelation : Anderson Valley, Fiddletown, Mendocino County\nCounty : Monterey, Solano, Santa Barbara\n*/\n/*\nColumns in appellations and all categories for low cardinality columns :\nState : California\nArea : Sierra Foothills, Central Valley, North Coast, Central Coast, N/A, California, Santa Cruz Mountains\nisAVA : Yes, No\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 round (\n\t\"Round_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Decoration_Theme\" TEXT, \n\t\"Rank_in_Round\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\", \"Round_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in round and all categories for low cardinality columns :\nRound_ID : 1, 2\nMember_ID : 1, 2, 4, 6, 10, 9\nDecoration_Theme : Dark Nights, Summer, Walk on the Moon, Sweetie, Soft Dream, Happiness\nRank_in_Round : 1, 2, 4, 3\n*/\n \nCREATE TABLE \"Document_Types\" (\n\tdocument_type_code VARCHAR(10), \n\tdocument_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (document_type_code)\n)\n/*\nColumns in Document_Types and all categories for low cardinality columns :\ndocument_type_code : APP, REG\ndocument_description : Regular, Initial Application\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE station (\n\t\"Station_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Annual_entry_exit\" REAL, \n\t\"Annual_interchanges\" REAL, \n\t\"Total_Passengers\" REAL, \n\t\"Location\" TEXT, \n\t\"Main_Services\" TEXT, \n\t\"Number_of_Platforms\" INTEGER, \n\tPRIMARY KEY (\"Station_ID\")\n)\n/*\nColumns in station and 3 examples in each column for high cardinality columns :\nStation_ID : 1, 11, 2\nName : London King's Cross, London Waterloo, Birmingham New Street\nAnnual_entry_exit : 20.551, 21.797, 36.609\nAnnual_interchanges : 9.157, 2.064, 9.489\nTotal_Passengers : 26.892, 29.658, 30.896\nMain_Services : South Eastern Main Line, Great Eastern Main Line Lea Valley Lines, Midland Main Line Thameslink High-Speed 1 Eurostar\n*/\n/*\nColumns in station and all categories for low cardinality columns :\nLocation : Glasgow, London, Birmingham\nNumber_of_Platforms : 13, 15, 17, 6, 12, 19, 18\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 school_performance (\n\t\"School_Id\" INTEGER, \n\t\"School_Year\" TEXT, \n\t\"Class_A\" TEXT, \n\t\"Class_AA\" TEXT, \n\tPRIMARY KEY (\"School_Id\", \"School_Year\"), \n\tFOREIGN KEY(\"School_Id\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in school_performance and 3 examples in each column for high cardinality columns :\nSchool_Year : 1998-99, 2002-03, 1994-95\nClass_A : Skidmore-Tynan, Lindsay, Anton\nClass_AA : Buffalo, Henrietta, S&S Consolidated\n*/\n/*\nColumns in school_performance and all categories for low cardinality columns :\nSchool_Id : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE election (\n\t\"Election_ID\" INTEGER, \n\t\"Representative_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Votes\" REAL, \n\t\"Vote_Percent\" REAL, \n\t\"Seats\" REAL, \n\t\"Place\" REAL, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"Representative_ID\") REFERENCES representative (\"Representative_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 4, 3\nRepresentative_ID : 1, 2, 5, 7, 4\nDate : 1946, 1949, July 1942, October 1942, 1953\nVotes : 11059.0, 9423.0, 13049.0, 12422.0, 14077.0\nVote_Percent : 16.0, 19.5, 16.2, 18.5\nSeats : 10.0, 6.0, 7.0, 9.0\nPlace : 3.0, 1.0, 2.0\n*/\n \nCREATE TABLE party (\n\t\"Party_ID\" INTEGER, \n\t\"Party_Theme\" TEXT, \n\t\"Location\" TEXT, \n\t\"First_year\" TEXT, \n\t\"Last_year\" TEXT, \n\t\"Number_of_hosts\" INTEGER, \n\tPRIMARY KEY (\"Party_ID\")\n)\n/*\nColumns in party and all categories for low cardinality columns :\nParty_ID : 1, 2, 5, 7, 8, 4, 6, 3\nParty_Theme : Qlubtempo, In Qontrol, Club Q-BASE, QrimeTime, Teqnology, Houseqlassics, Hardcore Resurrection, Spring\nLocation : Various locations, RAI Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam\nFirst_year : 2004, 2001, 1999, 2000, 2002\nLast_year : 2004, 2001, 2002, 2003, 2010, 2007\nNumber_of_hosts : 5, 7, 23, 4, 6, 18, 31\n*/\n \nCREATE TABLE \"Club\" (\n\t\"ClubID\" INTEGER, \n\t\"ClubName\" VARCHAR(40), \n\t\"ClubDesc\" VARCHAR(1024), \n\t\"ClubLocation\" VARCHAR(40), \n\tPRIMARY KEY (\"ClubID\")\n)\n/*\nColumns in Club and all categories for low cardinality columns :\nClubID : 1, 2, 4, 3\nClubName : Bootup Baltimore, Pen and Paper Gaming, Tennis Club, Hopkins Student Enterprises\nClubDesc : Venture capital fund for student business., A competitive tennis club., Refurbish computers; teach kids and adults about computer basics., Play pen and paper games on campus.\nClubLocation : HHH, AKW\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 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 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 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" }, { "role": "user", "content": "What are the countries with the most airlines whose active status is Y?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines.\nFrom these tables, I'll be using the following columns: country, active.\nThe SQL query I'll be generating is:\nSELECT country FROM airlines WHERE active = 'Y' GROUP BY country 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 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 \"Web_client_accelerator\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Operating_system\" TEXT, \n\t\"Client\" TEXT, \n\t\"Connection\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Web_client_accelerator and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : Freewire, Toonel, Fasterfox\nOperating_system : Unix (Linux, *BSD, Mac OS X, others), Windows, Windows, Mac and Mobile devices, Windows, Mac, Mobile devices\n*/\n/*\nColumns in Web_client_accelerator and all categories for low cardinality columns :\nClient : End User, ISP, End user, ISP, user/Google server, user/Opera server, user/ISP, ISP, All, user\nConnection : up to 756kbit/s, Broadband, Any, Broadband, Satellite, Wireless, Fiber, DSL, Dial, DSL, ISDN, Satellite, wireless, Dial-up, Broadband, DSL, ISDN, Satellite, Wireless, Dialup, Wireless, Broadband, DSL, Dial-up\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 countries (\n\t\"COUNTRY_ID\" VARCHAR(2) NOT NULL, \n\t\"COUNTRY_NAME\" VARCHAR(40) DEFAULT NULL, \n\t\"REGION_ID\" DECIMAL(10, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"COUNTRY_ID\"), \n\tFOREIGN KEY(\"REGION_ID\") REFERENCES regions (\"REGION_ID\")\n)\n/*\nColumns in countries and 3 examples in each column for high cardinality columns :\nCOUNTRY_ID : AR, JP, DE\nCOUNTRY_NAME : Israel, Australia, India\n*/\n/*\nColumns in countries and all categories for low cardinality columns :\nREGION_ID : 1, 2, 4, 3\n*/\n \nCREATE TABLE station (\n\tid INTEGER, \n\tnetwork_name TEXT, \n\tservices TEXT, \n\tlocal_authority TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in station and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\nnetwork_name : Chalfont & Latimer, Chorleywood, Brentwood\n*/\n/*\nColumns in station and all categories for low cardinality columns :\nservices : Greater Anglia, Metropolitan line and Chiltern Railways, Metropolitan line, c2c, London Overground and London Midland, London Overground\nlocal_authority : Three Rivers, Brentwood, Broxbourne, Thurrock, Watford, Chiltern\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 stock (\n\t\"Shop_ID\" INTEGER, \n\t\"Device_ID\" INTEGER, \n\t\"Quantity\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\", \"Device_ID\"), \n\tFOREIGN KEY(\"Device_ID\") REFERENCES device (\"Device_ID\"), \n\tFOREIGN KEY(\"Shop_ID\") REFERENCES shop (\"Shop_ID\")\n)\n/*\nColumns in stock and all categories for low cardinality columns :\nShop_ID : 1, 11, 2, 4, 3, 9\nDevice_ID : 4, 6\nQuantity : 110, 56, 124, 100, 200, 112, 134, 51\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 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 \nCREATE TABLE \"Products\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Price\" DECIMAL NOT NULL, \n\t\"Manufacturer\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Manufacturer\") REFERENCES \"Manufacturers\" (\"Code\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nCode : 1, 11, 2\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nName : Printer, Floppy disk, Memory, Monitor, Toner cartridge, CD drive, DVD burner, Hard drive, ZIP drive, DVD drive\nPrice : 150.0000000000, 120.0000000000, 90.0000000000, 5.0000000000, 270.0000000000, 180.0000000000, 66.0000000000, 240.0000000000\nManufacturer : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE \"Apartment_Facilities\" (\n\tapt_id INTEGER NOT NULL, \n\tfacility_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (apt_id, facility_code), \n\tFOREIGN KEY(apt_id) REFERENCES \"Apartments\" (apt_id)\n)\n/*\nColumns in Apartment_Facilities and all categories for low cardinality columns :\napt_id : 1, 2, 5, 6, 3, 15, 9\nfacility_code : Gym, Swimming Pool, Boardband, Cable TV\n*/\n \nCREATE TABLE \"Projects\" (\n\tproject_id INTEGER, \n\torganisation_id INTEGER NOT NULL, \n\tproject_details VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (project_id), \n\tFOREIGN KEY(organisation_id) REFERENCES \"Organisations\" (organisation_id)\n)\n/*\nColumns in Projects and 3 examples in each column for high cardinality columns :\nproject_id : 1, 13, 11\nproject_details : doloremque, impedit, et\n*/\n/*\nColumns in Projects and all categories for low cardinality columns :\norganisation_id : 1, 13, 11, 10, 5, 7, 4, 12, 3, 15\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 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 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 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 \"Locations\" (\n\t\"Location_ID\" INTEGER NOT NULL, \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 : 1, 13, 11\nOther_Details : Rowe PLC, Rowe-Stoltenberg, Fritsch LLC\n*/\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 artist (\n\t\"Artist_ID\" INTEGER, \n\t\"Artist\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Famous_Title\" TEXT, \n\t\"Famous_Release_date\" TEXT, \n\tPRIMARY KEY (\"Artist_ID\")\n)\n/*\nColumns in artist and all categories for low cardinality columns :\nArtist_ID : 1, 2, 5, 7, 4, 6, 3\nArtist : Gorgoroth, Tangorodrim, Triumfall, Black Flame, Ophiolatry\nAge : 49, 34, 18, 27, 22, 35\nFamous_Title : Unholy Metal Way (re-release), Antievangelistical Process (re-release), Imperivm, Those Who Unleashed (re-release), Antithesis of All Flesh, Bergen 1996, Transmutation\nFamous_Release_date : November 2007, 2009, June 15, 2009, January 21, 2008, June 23, 2008\n*/\n \nCREATE TABLE school (\n\t\"School_ID\" INTEGER, \n\t\"Grade\" TEXT, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 7, 4, 6, 3\nGrade : Freshman–Sophomore year, 1st-3rd grade, Kindergarten, Junior–Senior year, College, 5th-12th grade, 4th grade\nSchool : Occidental College, Noelani Elementary School, Harvard Law School, Columbia University, Punahou School, St. Francis Assisi, State Elementary School Menteng 01\nLocation : Cambridge, Massachusetts, Honolulu, Hawaii, Jakarta, Indonesia, Los Angeles, California, New York City\nType : Public, Private Catholic, Private\n*/\n" }, { "role": "user", "content": "List all countries and their number of airlines in the descending order of number of airlines." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines.\nFrom these tables, I'll be using the following columns: country.\nThe SQL query I'll be generating is:\nSELECT country , count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC" } ]
[ { "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 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 happy_hour_member (\n\t\"HH_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Total_amount\" REAL, \n\tPRIMARY KEY (\"HH_ID\", \"Member_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in happy_hour_member and all categories for low cardinality columns :\nHH_ID : 1, 2, 5, 7, 8, 4\nMember_ID : 5, 9, 3\nTotal_amount : 4.9, 4.2, 20.9, 16.9, 16.92, 20.92\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 \"SAVINGS\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in SAVINGS and all categories for low cardinality columns :\ncustid : 1, 2, 5, 4, 6, 3\nbalance : 80000.0, 230000.0, 999999999.0, 60.0, 240.0, 200000.0\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 \"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 repair_assignment (\n\ttechnician_id INTEGER, \n\t\"repair_ID\" INTEGER, \n\t\"Machine_ID\" INTEGER, \n\tPRIMARY KEY (technician_id, \"repair_ID\", \"Machine_ID\"), \n\tFOREIGN KEY(\"Machine_ID\") REFERENCES machine (\"Machine_ID\"), \n\tFOREIGN KEY(\"repair_ID\") REFERENCES repair (\"repair_ID\"), \n\tFOREIGN KEY(technician_id) REFERENCES technician (technician_id)\n)\n/*\nColumns in repair_assignment and all categories for low cardinality columns :\ntechnician_id : 1, 2, 5, 7, 3\nrepair_ID : 1, 2, 5, 8, 4, 3\nMachine_ID : 1, 2, 7, 4, 6, 3\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE exhibition_record (\n\t\"Exhibition_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Exhibition_ID\", \"Date\"), \n\tFOREIGN KEY(\"Exhibition_ID\") REFERENCES exhibition (\"Exhibition_ID\")\n)\n/*\nColumns in exhibition_record and 3 examples in each column for high cardinality columns :\nDate : February 25, February 19, December 2\nAttendance : 1313, 24808, 1233\n*/\n/*\nColumns in exhibition_record and all categories for low cardinality columns :\nExhibition_ID : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduct_category_code VARCHAR(20) NOT NULL, \n\tdate_product_first_available DATETIME, \n\tdate_product_discontinued DATETIME, \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tproduct_price DECIMAL(19, 4), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\nparent_product_id : 8, 4, 9, 3\nproduct_category_code : Food, Book, Hardware\ndate_product_first_available : 1988-09-29 17:54:50, 1998-06-20 15:04:11, 1994-12-18 15:13:19, 1974-06-25 12:26:47\ndate_product_discontinued : 1987-12-20 13:46:16, 1997-07-02 18:26:16, 1980-06-26 10:40:19, 1991-08-20 05:22:31\nproduct_name : Chocolate, The Great Gatsby, Mouse, Keyboard\nproduct_description : Designed for games, Handmade chocolate, American novel, Blue tooth mouse\nproduct_price : 23.3500, 2.8800, 109.9900, 35.0000\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 film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\n*/\n \nCREATE TABLE \"Products\" (\n\t\"Product_ID\" INTEGER NOT NULL, \n\t\"Product_Type_Code\" CHAR(15), \n\t\"Product_Name\" VARCHAR(255), \n\t\"Product_Price\" DECIMAL(20, 4), \n\tPRIMARY KEY (\"Product_ID\"), \n\tUNIQUE (\"Product_ID\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nProduct_ID : 1, 26, 20\nProduct_Price : 932.2500, 970.7700, 3228.4900\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nProduct_Type_Code : Food, Books, Electronics, Clothes\nProduct_Name : Conference Equipments, Men suits, Dinning, TV Equipments, Trading Policy B, Special Dinning, Business Policy B, Trading Policy, Business Policy\n*/\n \nCREATE TABLE airport_aircraft (\n\t\"ID\" INTEGER, \n\t\"Airport_ID\" INTEGER, \n\t\"Aircraft_ID\" INTEGER, \n\tPRIMARY KEY (\"Airport_ID\", \"Aircraft_ID\"), \n\tFOREIGN KEY(\"Aircraft_ID\") REFERENCES aircraft (\"Aircraft_ID\"), \n\tFOREIGN KEY(\"Airport_ID\") REFERENCES airport (\"Airport_ID\")\n)\n/*\nColumns in airport_aircraft and all categories for low cardinality columns :\nID : 1, 2, 4, 3\nAirport_ID : 1, 9, 2, 6\nAircraft_ID : 1, 2, 5, 3\n*/\n \nCREATE TABLE movie (\n\tmovie_id INTEGER, \n\t\"Title\" TEXT, \n\t\"Year\" INTEGER, \n\t\"Director\" TEXT, \n\t\"Budget_million\" REAL, \n\t\"Gross_worldwide\" INTEGER, \n\tPRIMARY KEY (movie_id)\n)\n/*\nColumns in movie and all categories for low cardinality columns :\nmovie_id : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nTitle : Agent Red, The Whole Nine Yards, Storm Catcher, 3000 Miles to Graceland, The Art of War, The Boondock Saints, Jill Rips, The Big Kahuna, Get Carter, Battlefield Earth\nYear : 2001, 1999, 2000\nDirector : Roger Christian, John Swanbeck, Stephen Kay, Christian Duguay, Jonathan Lynn, Troy Duffy, Anthony Hickox, Demian Lichtenstein, Damian Lee\nBudget_million : 63.6, 47.0, 60.0, 41.3, 44.0, 7.0, 62.0, 6.0, 4.0, 5.0\nGross_worldwide : 106371651, 456774, 40400425, 30471, 40500, 543356, 19412993, 29725663, 3728888, 18720175\n*/\n \nCREATE TABLE \"Payments\" (\n\t\"Payment_ID\" INTEGER NOT NULL, \n\t\"Settlement_ID\" INTEGER NOT NULL, \n\t\"Payment_Method_Code\" VARCHAR(255), \n\t\"Date_Payment_Made\" DATE, \n\t\"Amount_Payment\" INTEGER, \n\tPRIMARY KEY (\"Payment_ID\"), \n\tFOREIGN KEY(\"Settlement_ID\") REFERENCES \"Settlements\" (\"Settlement_ID\")\n)\n/*\nColumns in Payments and 3 examples in each column for high cardinality columns :\nPayment_ID : 754, 739, 542\nDate_Payment_Made : 2017-06-24, 2017-08-06, 2017-12-16\nAmount_Payment : 423154, 155654, 71246\n*/\n/*\nColumns in Payments and all categories for low cardinality columns :\nSettlement_ID : 527, 476, 564, 983, 682, 648, 597, 512, 516\nPayment_Method_Code : Visa, Discover Card, American Express, MasterCard\n*/\n \nCREATE TABLE \"Teachers\" (\n\tteacher_id INTEGER, \n\taddress_id INTEGER NOT NULL, \n\tfirst_name VARCHAR(80), \n\tmiddle_name VARCHAR(80), \n\tlast_name VARCHAR(80), \n\tgender VARCHAR(1), \n\tcell_mobile_number VARCHAR(40), \n\temail_address VARCHAR(40), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (teacher_id), \n\tFOREIGN KEY(address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in Teachers and 3 examples in each column for high cardinality columns :\nteacher_id : 1, 13, 11\naddress_id : 16, 13, 10\nfirst_name : Camren, Trystan, Alvis\nmiddle_name : Keanu, Michel, Kailyn\nlast_name : Goldner, Becker, Heller\ncell_mobile_number : 952.821.3392, 07928511102, 017.636.7409\nemail_address : hilll.kitty@example.com, paula.abbott@example.org, kozey.adeline@example.org\n*/\n/*\nColumns in Teachers and all categories for low cardinality columns :\ngender : 1, 0\nother_details : None, Dean\n*/\n \nCREATE TABLE \"Document_Functional_Areas\" (\n\tdocument_code VARCHAR(15) NOT NULL, \n\tfunctional_area_code VARCHAR(15) NOT NULL, \n\tFOREIGN KEY(functional_area_code) REFERENCES \"Functional_Areas\" (functional_area_code), \n\tFOREIGN KEY(document_code) REFERENCES \"Documents\" (document_code)\n)\n/*\nColumns in Document_Functional_Areas and 3 examples in each column for high cardinality columns :\ndocument_code : 217, 930, 958\n*/\n/*\nColumns in Document_Functional_Areas and all categories for low cardinality columns :\nfunctional_area_code : 1, 8, 9\n*/\n" }, { "role": "user", "content": "How many airlines operate out of each country in descending order?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines.\nFrom these tables, I'll be using the following columns: country.\nThe SQL query I'll be generating is:\nSELECT country , count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC" } ]
[ { "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 locations (\n\t\"LOCATION_ID\" DECIMAL(4, 0) DEFAULT '0' NOT NULL, \n\t\"STREET_ADDRESS\" VARCHAR(40) DEFAULT NULL, \n\t\"POSTAL_CODE\" VARCHAR(12) DEFAULT NULL, \n\t\"CITY\" VARCHAR(30) NOT NULL, \n\t\"STATE_PROVINCE\" VARCHAR(25) DEFAULT NULL, \n\t\"COUNTRY_ID\" VARCHAR(2) DEFAULT NULL, \n\tPRIMARY KEY (\"LOCATION_ID\"), \n\tFOREIGN KEY(\"COUNTRY_ID\") REFERENCES countries (\"COUNTRY_ID\")\n)\n/*\nColumns in locations and 3 examples in each column for high cardinality columns :\nLOCATION_ID : 1900, 1700, 1200\nSTREET_ADDRESS : 2004 Charade Rd, Mariano Escobedo 9991, 9450 Kamiya-cho\nPOSTAL_CODE : , 1689, 98199\nCITY : Tokyo, Southlake, South San Francisco\nSTATE_PROVINCE : , New South Wales, Sao Paulo\nCOUNTRY_ID : AU, NL, JP\n*/\n\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\torder_quantity VARCHAR(80), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\norder_id : 13, 11, 5\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 13, 11, 2, 5, 4, 6, 12, 3, 15, 9\norder_quantity : 2, 5, 7, 8, 4, 3, 9, male\n*/\n \nCREATE TABLE election (\n\t\"Election_ID\" INTEGER, \n\t\"Representative_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Votes\" REAL, \n\t\"Vote_Percent\" REAL, \n\t\"Seats\" REAL, \n\t\"Place\" REAL, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"Representative_ID\") REFERENCES representative (\"Representative_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 4, 3\nRepresentative_ID : 1, 2, 5, 7, 4\nDate : 1946, 1949, July 1942, October 1942, 1953\nVotes : 11059.0, 9423.0, 13049.0, 12422.0, 14077.0\nVote_Percent : 16.0, 19.5, 16.2, 18.5\nSeats : 10.0, 6.0, 7.0, 9.0\nPlace : 3.0, 1.0, 2.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 storm (\n\t\"Storm_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Dates_active\" TEXT, \n\t\"Max_speed\" INTEGER, \n\t\"Damage_millions_USD\" REAL, \n\t\"Number_Deaths\" INTEGER, \n\tPRIMARY KEY (\"Storm_ID\")\n)\n/*\nColumns in storm and all categories for low cardinality columns :\nStorm_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Three, One, Five, Nine, Four, Seven, Six, Eight, 9 cyclones, Two\nDates_active : August5–August14, May19 –October26, August3–August10, September22–September28, September7–September17, May19–May25, October24–October26, August26–September2, September18–September25, October20–October24\nMax_speed : 1007, 988, 977, 961, 972, 1002, 983, 995\nDamage_millions_USD : 1.49, 10.75, 13.0, 29.3, 4.05, 0.039\nNumber_Deaths : 2, 7, 52, 3, 71, 0\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Authors\" (\n\t\"authID\" INTEGER, \n\tlname TEXT, \n\tfname TEXT, \n\tPRIMARY KEY (\"authID\")\n)\n/*\nColumns in Authors and 3 examples in each column for high cardinality columns :\nauthID : 53, 56, 57\nlname : Gibbons, Turon, Ueno\nfname : Daniel W. H., Tim, Ralf\n*/\n\n \nCREATE TABLE \"Trucks\" (\n\ttruck_id INTEGER, \n\ttruck_licence_number VARCHAR(20), \n\ttruck_details VARCHAR(255), \n\tPRIMARY KEY (truck_id)\n)\n/*\nColumns in Trucks and 3 examples in each column for high cardinality columns :\ntruck_id : 1, 13, 11\ntruck_licence_number : 25232, 63359, 24474\ntruck_details : Kaya, Ricky, Deon\n*/\n\n \nCREATE TABLE course (\n\tcourse_id VARCHAR(8), \n\ttitle VARCHAR(50), \n\tdept_name VARCHAR(20), \n\tcredits NUMERIC(2, 0), \n\tPRIMARY KEY (course_id), \n\tFOREIGN KEY(dept_name) REFERENCES department (dept_name), \n\tCHECK (credits > 0)\n)\n/*\nColumns in course and 3 examples in each column for high cardinality columns :\ncourse_id : 241, 586, 377\ntitle : Numerical Methods, Thermal Physics, Stream Processing\ndept_name : Math, Athletics, English\n*/\n/*\nColumns in course and all categories for low cardinality columns :\ncredits : 4, 3\n*/\n \nCREATE TABLE \"Ref_Calendar\" (\n\t\"Calendar_Date\" DATETIME NOT NULL, \n\t\"Day_Number\" INTEGER, \n\tPRIMARY KEY (\"Calendar_Date\")\n)\n/*\nColumns in Ref_Calendar and 3 examples in each column for high cardinality columns :\nCalendar_Date : 2009-08-18 03:29:08, 2012-07-03 09:48:46, 1972-03-31 09:47:22\n*/\n/*\nColumns in Ref_Calendar and all categories for low cardinality columns :\nDay_Number : 1, 2, 5, 7, 8, 3, 9\n*/\n \nCREATE TABLE \"Research_Outcomes\" (\n\toutcome_code VARCHAR(10), \n\toutcome_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (outcome_code)\n)\n/*\nColumns in Research_Outcomes and all categories for low cardinality columns :\noutcome_code : Patent, Paper\noutcome_description : Published Research Paper, Research Patent\n*/\n \nCREATE TABLE branch (\n\t\"Branch_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Open_year\" TEXT, \n\t\"Address_road\" TEXT, \n\t\"City\" TEXT, \n\tmembership_amount TEXT, \n\tPRIMARY KEY (\"Branch_ID\")\n)\n/*\nColumns in branch and all categories for low cardinality columns :\nBranch_ID : 1, 2, 5, 7, 8, 4, 6, 3\nName : Popert, Zytogorski, Alexandre, Brooke Greville, Taverner, Stanley, Saint Amant, Cochrane\nOpen_year : 2009, 2013, 2015, 2001, 2012, 2014\nAddress_road : Abbott Street, Concord Road, Brampton Road, Cecilia Avenue, Oaks Crescent, Valleys Place, Glebe Street, Abbey Rise\nCity : Oxford, London\nmembership_amount : 91, 56, 11, 1418, 7, 6, 112, 31\n*/\n \nCREATE TABLE medicine (\n\tid INTEGER, \n\tname TEXT, \n\t\"Trade_Name\" TEXT, \n\t\"FDA_approved\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in medicine and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Quetiapine, Carpipramine, Asenapine\nTrade_Name : Buronil, Fanapt, Nipolept\n*/\n/*\nColumns in medicine and all categories for low cardinality columns :\nFDA_approved : Yes, No\n*/\n \nCREATE TABLE performance (\n\t\"Performance_ID\" REAL, \n\t\"Date\" TEXT, \n\t\"Host\" TEXT, \n\t\"Location\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Performance_ID\")\n)\n/*\nColumns in performance and all categories for low cardinality columns :\nPerformance_ID : 3.0, 1.0, 2.0, 6.0, 4.0, 5.0\nDate : February 7, February 4, February 2, February 5, February 10, February 11\nHost : Ottawa Senators, New York Rangers, Pittsburgh Penguins, Atlanta Thrashers, Montreal Canadiens, Boston Bruins\nLocation : Madison Square Garden, Scotiabank Place, Verizon Center, TD Garden, Bell Centre\nAttendance : 2173, 1878, 1877, 1820, 1982, 165\n*/\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 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 race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\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 \"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 nomination (\n\t\"Artwork_ID\" INTEGER, \n\t\"Festival_ID\" INTEGER, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"Artwork_ID\", \"Festival_ID\"), \n\tFOREIGN KEY(\"Festival_ID\") REFERENCES festival_detail (\"Festival_ID\"), \n\tFOREIGN KEY(\"Artwork_ID\") REFERENCES artwork (\"Artwork_ID\")\n)\n/*\nColumns in nomination and all categories for low cardinality columns :\nArtwork_ID : 1, 2, 8, 4, 3, 9\nFestival_ID : 1, 2, 5\nResult : Nominated, Won\n*/\n" }, { "role": "user", "content": "How many airports are there per country? Order the countries by decreasing number of airports." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: country.\nThe SQL query I'll be generating is:\nSELECT count(*) , country FROM airports GROUP BY country ORDER BY count(*) DESC" } ]
[ { "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 \"Investors\" (\n\tinvestor_id INTEGER, \n\t\"Investor_details\" VARCHAR(255), \n\tPRIMARY KEY (investor_id)\n)\n/*\nColumns in Investors and 3 examples in each column for high cardinality columns :\ninvestor_id : 17, 9, 16\nInvestor_details : d, t, b\n*/\n\n \nCREATE TABLE \"Complaints\" (\n\tcomplaint_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\tcomplaint_outcome_code VARCHAR(20) NOT NULL, \n\tcomplaint_status_code VARCHAR(20) NOT NULL, \n\tcomplaint_type_code VARCHAR(20) NOT NULL, \n\tdate_complaint_raised DATETIME, \n\tdate_complaint_closed DATETIME, \n\tstaff_id INTEGER NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Complaints and 3 examples in each column for high cardinality columns :\ncomplaint_id : 1, 11, 2\n*/\n/*\nColumns in Complaints and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\ncustomer_id : 120, 114, 113, 116, 117, 115, 118\ncomplaint_outcome_code : OK\ncomplaint_status_code : Open, Closed, New\ncomplaint_type_code : Product Failure, Product Unusable\ndate_complaint_raised : 2006-10-29 07:08:46, 2002-07-18 10:59:35, 1977-08-06 00:31:19, 1987-07-11 14:40:30, 1973-02-10 22:55:56, 2007-10-14 21:50:43\ndate_complaint_closed : 2013-09-14 02:59:10, 1975-10-11 05:54:30, 1970-10-14 00:57:25, 1976-04-19 11:03:06, 1995-09-11 14:48:46, 2000-08-17 17:02:48\nstaff_id : 120, 114, 116, 117, 115, 118\n*/\n \nCREATE TABLE school_bus (\n\t\"School_ID\" INTEGER, \n\t\"Driver_ID\" INTEGER, \n\t\"Years_Working\" INTEGER, \n\t\"If_full_time\" BOOLEAN, \n\tPRIMARY KEY (\"School_ID\", \"Driver_ID\"), \n\tFOREIGN KEY(\"Driver_ID\") REFERENCES driver (\"Driver_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in school_bus and all categories for low cardinality columns :\nSchool_ID : 1, 5, 7, 4, 3\nDriver_ID : 7, 4, 3, 10, 9\nYears_Working : 2, 8, 6, 3, 10\nIf_full_time : True\n*/\n \nCREATE TABLE host (\n\t\"Host_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Age\" TEXT, \n\tPRIMARY KEY (\"Host_ID\")\n)\n/*\nColumns in host and all categories for low cardinality columns :\nHost_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Lloyd Daniels, Kornel David, Antonio Davis, Carlos Delfino, DeMar DeRozan, Ed Davis, Austin Daye, Derrick Dial, Justin Dentmon, Hubert Davis\nNationality : United States, Argentina, Hungary\nAge : 26, 45, 37, 40, 30, 60, 47, 43, 31\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\torder_quantity VARCHAR(15), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Order_Items and all categories for low cardinality columns :\norder_id : 13, 11, 2, 5, 7, 8, 14, 10\nproduct_id : 1, 2, 3\norder_quantity : 1, 2, 5, 7, 8, 6, 9\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 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 \"Students\" (\n\tstudent_id INTEGER, \n\tdate_of_registration DATETIME, \n\tdate_of_latest_logon DATETIME, \n\tlogin_name VARCHAR(40), \n\tpassword VARCHAR(10), \n\tpersonal_name VARCHAR(40), \n\tmiddle_name VARCHAR(40), \n\tfamily_name VARCHAR(40), \n\tPRIMARY KEY (student_id)\n)\n/*\nColumns in Students and 3 examples in each column for high cardinality columns :\nstudent_id : 1, 13, 11\ndate_of_registration : 2015-10-11 03:23:27, 2016-03-25 18:58:58, 2015-04-27 10:25:31\ndate_of_latest_logon : 2017-11-25 03:14:32, 2017-12-11 14:29:41, 2017-09-15 08:10:04\nlogin_name : eichmann.lera, myron.bergnaum, kiarra28\npassword : 5bc0d35e75, aedd08a3b9, 2e05a1e6a3\npersonal_name : Mariela, Eliza, Alicia\nmiddle_name : Casimir, Camilla, Marianne\nfamily_name : Ziemann, Zieme, Hartmann\n*/\n\n \nCREATE TABLE \"Council_Tax\" (\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 Council_Tax and all categories for low cardinality columns :\ncouncil_tax_id : 1, 2, 7, 8, 3, 9\ncmi_cross_ref_id : 106, 103, 102, 101, 104, 105\n*/\n \nCREATE TABLE \"Companies\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value_billion\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Companies and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : PetroChina, Berkshire Hathaway, Petrobras\nSales_billion : 69.2, 189.6, 421.8\nProfits_billion : 16.4, 19.9, 17.4\nAssets_billion : 2467.9, 192.8, 1913.9\nMarket_Value_billion : 239.5, 186.5, 224.8\n*/\n/*\nColumns in Companies and all categories for low cardinality columns :\nHeadquarters : Spain, UK, China, Brazil, France, Russia, USA, Netherlands\nIndustry : Retailing, Conglomerate, Oil and gas, Telecommunications, Banking\n*/\n \nCREATE TABLE school (\n\t\"School_ID\" INTEGER, \n\t\"Grade\" TEXT, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 7, 4, 6, 3\nGrade : Freshman–Sophomore year, 1st-3rd grade, Kindergarten, Junior–Senior year, College, 5th-12th grade, 4th grade\nSchool : Occidental College, Noelani Elementary School, Harvard Law School, Columbia University, Punahou School, St. Francis Assisi, State Elementary School Menteng 01\nLocation : Cambridge, Massachusetts, Honolulu, Hawaii, Jakarta, Indonesia, Los Angeles, California, New York City\nType : Public, Private Catholic, Private\n*/\n \nCREATE TABLE \"Financial_Transactions\" (\n\ttransaction_id INTEGER NOT NULL, \n\tprevious_transaction_id INTEGER, \n\taccount_id INTEGER NOT NULL, \n\tcard_id INTEGER NOT NULL, \n\ttransaction_type VARCHAR(15) NOT NULL, \n\ttransaction_date DATETIME, \n\ttransaction_amount DOUBLE, \n\ttransaction_comment VARCHAR(255), \n\tother_transaction_details VARCHAR(255), \n\tFOREIGN KEY(account_id) REFERENCES \"Accounts\" (account_id), \n\tFOREIGN KEY(card_id) REFERENCES \"Customers_Cards\" (card_id)\n)\n/*\nColumns in Financial_Transactions and 3 examples in each column for high cardinality columns :\ntransaction_id : 1, 13, 11\nprevious_transaction_id : 925, 947, 986\naccount_id : 1, 13, 11\ntransaction_date : 2018-03-24 10:39:09, 2018-03-23 21:59:28, 2018-03-24 05:45:57\ntransaction_amount : 486.56, 1336.21, 945.43\n*/\n/*\nColumns in Financial_Transactions and all categories for low cardinality columns :\ncard_id : 1, 11, 2, 5, 7, 4, 6, 12, 3, 9\ntransaction_type : Refund, Payment\ntransaction_comment : None\nother_transaction_details : None\n*/\n \nCREATE TABLE gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\n*/\n \nCREATE TABLE \"Ref_Document_Status\" (\n\tdocument_status_code CHAR(15) NOT NULL, \n\tdocument_status_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (document_status_code)\n)\n/*\nColumns in Ref_Document_Status and all categories for low cardinality columns :\ndocument_status_code : done, overdue, working\ndocument_status_description : mailed late, mailed, currently working on\n*/\n \nCREATE TABLE jobs (\n\t\"JOB_ID\" VARCHAR(10) DEFAULT '' NOT NULL, \n\t\"JOB_TITLE\" VARCHAR(35) NOT NULL, \n\t\"MIN_SALARY\" DECIMAL(6, 0) DEFAULT NULL, \n\t\"MAX_SALARY\" DECIMAL(6, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"JOB_ID\")\n)\n/*\nColumns in jobs and 3 examples in each column for high cardinality columns :\nJOB_ID : HR_REP, ST_MAN, AD_PRES\nJOB_TITLE : Purchasing Clerk, Stock Clerk, Marketing Manager\nMIN_SALARY : 20000, 8000, 3000\nMAX_SALARY : 20000, 8500, 40000\n*/\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" }, { "role": "user", "content": "What is the number of airports per country, ordered from most to least?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: country.\nThe SQL query I'll be generating is:\nSELECT count(*) , country FROM airports GROUP BY country ORDER BY count(*) DESC" } ]
[ { "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 \"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 shop (\n\t\"Shop_ID\" INTEGER, \n\t\"Shop_Name\" TEXT, \n\t\"Location\" TEXT, \n\t\"Open_Date\" TEXT, \n\t\"Open_Year\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\")\n)\n/*\nColumns in shop and 3 examples in each column for high cardinality columns :\nShop_ID : 1, 11, 2\nShop_Name : Pentre store, Best Buy, Apple\nOpen_Date : 24 February, 18 February, 1 January\n*/\n/*\nColumns in shop and all categories for low cardinality columns :\nLocation : Maerdy, Porth, Blaenllechau, Pentre, Penygraig, Gelli, Dinas, Wattstown, Cymmer\nOpen_Year : 2009, 2013, 2015, 2017, 2006, 2011, 2014, 2010, 2007\n*/\n \nCREATE TABLE program (\n\t\"Program_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Origin\" TEXT, \n\t\"Launch\" REAL, \n\t\"Owner\" TEXT, \n\tPRIMARY KEY (\"Program_ID\")\n)\n/*\nColumns in program and all categories for low cardinality columns :\nProgram_ID : 1, 2, 5, 4, 3\nName : Toonmax, Aniworld, Youman, Jiajia, Kaku\nOrigin : Beijing, Shanghai, Guangdong, Hunan, Jiangsu\nLaunch : 2007.0, 2005.0, 2010.0, 2004.0\nOwner : Jiangsu Broadcasting Corporation (JSBC), Shanghai Media Group (SMG), Beijing Television (BTV), Hunan Broadcasting System (HBS), Southern Media Corporation (SMC)\n*/\n \nCREATE TABLE stock (\n\t\"Shop_ID\" INTEGER, \n\t\"Device_ID\" INTEGER, \n\t\"Quantity\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\", \"Device_ID\"), \n\tFOREIGN KEY(\"Device_ID\") REFERENCES device (\"Device_ID\"), \n\tFOREIGN KEY(\"Shop_ID\") REFERENCES shop (\"Shop_ID\")\n)\n/*\nColumns in stock and all categories for low cardinality columns :\nShop_ID : 1, 11, 2, 4, 3, 9\nDevice_ID : 4, 6\nQuantity : 110, 56, 124, 100, 200, 112, 134, 51\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 \"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 \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 county_public_safety (\n\t\"County_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Population\" INTEGER, \n\t\"Police_officers\" INTEGER, \n\t\"Residents_per_officer\" INTEGER, \n\t\"Case_burden\" INTEGER, \n\t\"Crime_rate\" REAL, \n\t\"Police_force\" TEXT, \n\t\"Location\" TEXT, \n\tPRIMARY KEY (\"County_ID\")\n)\n/*\nColumns in county_public_safety and all categories for low cardinality columns :\nCounty_ID : 1, 2, 5, 4, 6, 3\nName : Central Saanich, Campbell River, Chilliwack, Castlegar, Burnaby, Abbotsford\nPopulation : 16821, 204320, 128165, 73066, 7821, 30810\nPolice_officers : 91, 11, 187, 253, 40, 21\nResidents_per_officer : 711, 770, 801, 808, 803, 685\nCase_burden : 100, 137, 140, 39, 107, 81\nCrime_rate : 178.0, 150.0, 49.0, 118.0, 174.0, 123.0\nPolice_force : Abbotsford Police Department, Central Saanich Police, RCMP\nLocation : West, East, North\n*/\n \nCREATE TABLE \"Maintenance_Engineers\" (\n\tengineer_id INTEGER, \n\tcompany_id INTEGER NOT NULL, \n\tfirst_name VARCHAR(50), \n\tlast_name VARCHAR(50), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (engineer_id), \n\tFOREIGN KEY(company_id) REFERENCES \"Third_Party_Companies\" (company_id)\n)\n/*\nColumns in Maintenance_Engineers and 3 examples in each column for high cardinality columns :\nengineer_id : 1, 13, 11\ncompany_id : 1, 11, 10\nfirst_name : Lorine, Weston, Josie\nlast_name : Harvey, Hirthe, Goldner\n*/\n/*\nColumns in Maintenance_Engineers and all categories for low cardinality columns :\nother_details : None, Skilled\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 \"Channels\" (\n\t\"Channel_ID\" INTEGER NOT NULL, \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Channel_ID\")\n)\n/*\nColumns in Channels and 3 examples in each column for high cardinality columns :\nChannel_ID : 1, 13, 11\nOther_Details : 668, 249, 943\n*/\n\n \nCREATE TABLE member (\n\t\"Member_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Country\" TEXT, \n\t\"College_ID\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\"), \n\tFOREIGN KEY(\"College_ID\") REFERENCES college (\"College_ID\")\n)\n/*\nColumns in member and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Tom Weiskopf, Tom Watson, Pat Fitzsimons, Homero Blancas, Jack Nicklaus, Billy Casper, J. C. Snead, Arnold Palmer, Lee Trevino, Bobby Nichols\nCountry : United States, Canada\nCollege_ID : 1, 2, 5, 4, 3\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 \"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 culture_company (\n\t\"Company_name\" TEXT, \n\t\"Type\" TEXT, \n\t\"Incorporated_in\" TEXT, \n\t\"Group_Equity_Shareholding\" REAL, \n\tbook_club_id TEXT, \n\tmovie_id TEXT, \n\tPRIMARY KEY (\"Company_name\"), \n\tFOREIGN KEY(book_club_id) REFERENCES book_club (book_club_id), \n\tFOREIGN KEY(movie_id) REFERENCES movie (movie_id)\n)\n/*\nColumns in culture_company and all categories for low cardinality columns :\nCompany_name : Cathay Pacific Culture, Culture China Cargo, Culture Hong Kong, Cathay Pacific Culture Services (HK) Limited, Culture China, Dragonair\nType : Joint Venture, Subsidiary, Corporate\nIncorporated_in : Hong Kong, China\nGroup_Equity_Shareholding : 49.0, 60.0, 18.77, 100.0\nbook_club_id : 1, 2, 5, 6, 3\nmovie_id : 2, 5, 7, 4, 6, 3\n*/\n \nCREATE TABLE \"Document_Sections\" (\n\tsection_id INTEGER, \n\tdocument_code VARCHAR(15) NOT NULL, \n\tsection_sequence INTEGER, \n\tsection_code VARCHAR(20), \n\tsection_title VARCHAR(80), \n\tPRIMARY KEY (section_id), \n\tFOREIGN KEY(document_code) REFERENCES \"Documents\" (document_code)\n)\n/*\nColumns in Document_Sections and 3 examples in each column for high cardinality columns :\nsection_id : 89, 62, 38\ndocument_code : 714, 217, 566\nsection_sequence : 5552, 4433, 8805\nsection_code : 91, 16, 38\n*/\n/*\nColumns in Document_Sections and all categories for low cardinality columns :\nsection_title : after, before\n*/\n \nCREATE TABLE technician (\n\ttechnician_id REAL, \n\t\"Name\" TEXT, \n\t\"Team\" TEXT, \n\t\"Starting_Year\" REAL, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (technician_id)\n)\n/*\nColumns in technician and all categories for low cardinality columns :\ntechnician_id : 3.0, 8.0, 10.0, 1.0, 7.0, 2.0, 6.0, 9.0, 4.0, 5.0\nName : Mark Sewell, John Brown, Mickey Cochrane, Joe Sewell, Tony Sewell, Joe Cochrane, Eddie Collins, Charlie Hollocher, Lou Boudreau\nTeam : CHC, NYY, CLE, PHA, CWS\nStarting_Year : 2013.0, 2016.0, 2003.0, 2006.0, 2005.0, 2002.0, 2009.0, 2012.0\nAge : 38, 37, 45, 46, 28, 36, 32, 47, 43, 35\n*/\n \nCREATE TABLE wine (\n\t\"No\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Winery\" TEXT, \n\t\"Appelation\" TEXT, \n\t\"State\" TEXT, \n\t\"Name\" TEXT, \n\t\"Year\" INTEGER, \n\t\"Price\" INTEGER, \n\t\"Score\" INTEGER, \n\t\"Cases\" INTEGER, \n\t\"Drink\" TEXT, \n\tFOREIGN KEY(\"Grape\") REFERENCES grapes (\"Grape\"), \n\tFOREIGN KEY(\"Appelation\") REFERENCES appellations (\"Appelation\")\n)\n/*\nColumns in wine and 3 examples in each column for high cardinality columns :\nNo : 87, 56, 65\nWinery : Novy, Turnbull, Loring\nAppelation : Mendocino County, Happy Canyon of Santa Barbara, Russian River Valley\nName : Wheelhouse, Limited Release, Mother Clone\nPrice : 56, 65, 75\nScore : 87, 91, 89\nCases : NULL, 377, 575\n*/\n/*\nColumns in wine and all categories for low cardinality columns :\nGrape : Sauvignon Blanc, Pinot Noir, Malbec, Merlot, Petite Sirah, Syrah, Cabernet Sauvingnon, Grenache, Zinfandel\nState : California\nYear : 2006, 2008, 2009, 2007\nDrink : 2013, 2001, 2012, 2011, now, 2010\n*/\n" }, { "role": "user", "content": "How many airports are there per city in the United States? Order the cities by decreasing number of airports." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city, country.\nThe SQL query I'll be generating is:\nSELECT count(*) , city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY count(*) DESC" } ]
[ { "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 status (\n\t\"statusId\" INTEGER, \n\tstatus TEXT, \n\tPRIMARY KEY (\"statusId\")\n)\n/*\nColumns in status and 3 examples in each column for high cardinality columns :\nstatusId : 87, 56, 65\nstatus : Safety concerns, Suspension, Spark plugs\n*/\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 stadium (\n\t\"ID\" INTEGER, \n\tname TEXT, \n\t\"Capacity\" INTEGER, \n\t\"City\" TEXT, \n\t\"Country\" TEXT, \n\t\"Opening_year\" INTEGER, \n\tPRIMARY KEY (\"ID\")\n)\n/*\nColumns in stadium and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Northumberland Development Project, Fisht Olympic Stadium, Ferenc Puskás Stadion, Nou Mestalla, Yubileyniy Stadium, Estadio La Peineta, Baku Olympic Stadium, Arena Baltika, Stade des Lumières, Gazprom Arena\nCapacity : 61556, 69501, 56250, 68000, 47659, 45015, 67500, 75000, 65000\nCity : London, Sochi, Budapest, Saint Petersburg, Baku, Kaliningrad, Madrid, Valencia, Lyon, Saransk\nCountry : Spain, France, England, Russia, Azerbaijan, Hungary\nOpening_year : 2004, 2005, 2007, 2006\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Video_Games\" (\n\t\"GameID\" INTEGER, \n\t\"GName\" VARCHAR(40), \n\t\"GType\" VARCHAR(40), \n\tPRIMARY KEY (\"GameID\")\n)\n/*\nColumns in Video_Games and all categories for low cardinality columns :\nGameID : 1, 2, 5, 4, 6, 3\nGName : Call of Destiny, Grand Term Assignment, The Vanishing of Eric Calder, Europe is the Universe, Works of Widenius, RNG Stone\nGType : Role-playing game, Collectible card game, Frist-person shooter, Walking Simulator, Grand strategy, Massively multiplayer online game\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 \"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 \"Player\" (\n\tid INTEGER, \n\tplayer_api_id INTEGER, \n\tplayer_name TEXT, \n\tplayer_fifa_api_id INTEGER, \n\tbirthday TEXT, \n\theight INTEGER, \n\tweight INTEGER, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Player and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\nplayer_api_id : 148827, 38423, 176301\nplayer_name : Adam Ounas, Abdelmalek Cherrad, Adrian\nplayer_fifa_api_id : 197081, 211185, 184410\nbirthday : 1988-08-25 00:00:00, 1986-12-02 00:00:00, 1978-12-22 00:00:00\nheight : 172.72, 175.26, 187.96\nweight : 185, 187, 163\n*/\n\n \nCREATE TABLE csu_fees (\n\t\"Campus\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"CampusFee\" INTEGER, \n\tPRIMARY KEY (\"Campus\"), \n\tFOREIGN KEY(\"Campus\") REFERENCES \"Campuses\" (\"Id\")\n)\n/*\nColumns in csu_fees and 3 examples in each column for high cardinality columns :\nCampus : 17, 21, 9\nCampusFee : 1916, 2009, 2204\n*/\n/*\nColumns in csu_fees and all categories for low cardinality columns :\nYear : 2003, 1996\n*/\n \nCREATE TABLE instructor (\n\t\"ID\" VARCHAR(5), \n\tname VARCHAR(20) NOT NULL, \n\tdept_name VARCHAR(20), \n\tsalary NUMERIC(8, 2), \n\tPRIMARY KEY (\"ID\"), \n\tFOREIGN KEY(dept_name) REFERENCES department (dept_name), \n\tCHECK (salary > 29000)\n)\n/*\nColumns in instructor and 3 examples in each column for high cardinality columns :\nID : 99052, 6569, 79081\nname : McKinnon, Sarkar, Vicentino\ndept_name : Marketing, Comp. Sci., Statistics\nsalary : 43770.36, 35023.18, 117836.50\n*/\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 \"Invoice\" (\n\t\"InvoiceId\" INTEGER NOT NULL, \n\t\"CustomerId\" INTEGER NOT NULL, \n\t\"InvoiceDate\" DATETIME NOT NULL, \n\t\"BillingAddress\" VARCHAR(70) DEFAULT NULL, \n\t\"BillingCity\" VARCHAR(40) DEFAULT NULL, \n\t\"BillingState\" VARCHAR(40) DEFAULT NULL, \n\t\"BillingCountry\" VARCHAR(40) DEFAULT NULL, \n\t\"BillingPostalCode\" VARCHAR(10) DEFAULT NULL, \n\t\"Total\" DECIMAL(10, 2) NOT NULL, \n\tPRIMARY KEY (\"InvoiceId\"), \n\tFOREIGN KEY(\"CustomerId\") REFERENCES \"Customer\" (\"CustomerId\")\n)\n/*\nColumns in Invoice and 3 examples in each column for high cardinality columns :\nInvoiceId : 87, 56, 65\nCustomerId : 53, 56, 49\nInvoiceDate : 2009-06-10 00:00:00, 2010-05-30 00:00:00, 2011-02-16 00:00:00\nBillingAddress : 696 Osborne Street, 796 Dundas Street West, Grétrystraat 63\nBillingCity : Oslo, Lisbon, Mountain View\nBillingState : AZ, NSW, Dublin\nBillingCountry : Sweden, Australia, India\nBillingPostalCode : B3S 1C5, 85719, 1106\nTotal : 3.96, 17.91, 15.86\n*/\n\n \nCREATE TABLE appellations (\n\t\"No\" INTEGER, \n\t\"Appelation\" TEXT, \n\t\"County\" TEXT, \n\t\"State\" TEXT, \n\t\"Area\" TEXT, \n\t\"isAVA\" TEXT, \n\tPRIMARY KEY (\"No\"), \n\tUNIQUE (\"Appelation\")\n)\n/*\nColumns in appellations and 3 examples in each column for high cardinality columns :\nNo : 53, 56, 49\nAppelation : Anderson Valley, Fiddletown, Mendocino County\nCounty : Monterey, Solano, Santa Barbara\n*/\n/*\nColumns in appellations and all categories for low cardinality columns :\nState : California\nArea : Sierra Foothills, Central Valley, North Coast, Central Coast, N/A, California, Santa Cruz Mountains\nisAVA : Yes, No\n*/\n \nCREATE TABLE \"Transactions\" (\n\ttransaction_id INTEGER, \n\tinvestor_id INTEGER NOT NULL, \n\ttransaction_type_code VARCHAR(10) NOT NULL, \n\tdate_of_transaction DATETIME, \n\tamount_of_transaction DECIMAL(19, 4), \n\tshare_count VARCHAR(40), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (transaction_id), \n\tFOREIGN KEY(transaction_type_code) REFERENCES \"Ref_Transaction_Types\" (transaction_type_code), \n\tFOREIGN KEY(investor_id) REFERENCES \"Investors\" (investor_id)\n)\n/*\nColumns in Transactions and 3 examples in each column for high cardinality columns :\ntransaction_id : 1, 13, 11\ndate_of_transaction : 1990-12-02 09:03:38, 2001-11-28 15:06:25, 2002-09-13 03:04:56\namount_of_transaction : 207484122.2796, 27.2570, 822.8030\nshare_count : , 8718572, 930\n*/\n/*\nColumns in Transactions and all categories for low cardinality columns :\ninvestor_id : 3, 20, 2, 7, 8, 17, 6, 14, 19, 18\ntransaction_type_code : PUR, SALE\nother_details : None\n*/\n \nCREATE TABLE \"Candidate_Assessments\" (\n\tcandidate_id INTEGER NOT NULL, \n\tqualification CHAR(15) NOT NULL, \n\tassessment_date DATETIME NOT NULL, \n\tasessment_outcome_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (candidate_id, qualification), \n\tFOREIGN KEY(candidate_id) REFERENCES \"Candidates\" (candidate_id)\n)\n/*\nColumns in Candidate_Assessments and all categories for low cardinality columns :\ncandidate_id : 151, 141, 131, 111, 121\nqualification : A, C, D, B\nassessment_date : 2010-04-06 11:44:34, 2010-04-17 11:44:34, 2010-04-09 11:44:34, 2010-04-07 11:44:34, 2010-04-05 11:44:34\nasessment_outcome_code : Fail, Pass\n*/\n \nCREATE TABLE \"People\" (\n\tperson_id INTEGER NOT NULL, \n\tfirst_name VARCHAR(255), \n\tmiddle_name VARCHAR(255), \n\tlast_name VARCHAR(255), \n\tcell_mobile_number VARCHAR(40), \n\temail_address VARCHAR(40), \n\tlogin_name VARCHAR(40), \n\tpassword VARCHAR(40), \n\tPRIMARY KEY (person_id)\n)\n/*\nColumns in People and all categories for low cardinality columns :\nperson_id : 151, 141, 131, 171, 111, 161, 181, 121\nfirst_name : Shannon, Mayra, Hoyt, Virginie, Nova, Dariana, Verna, Lizeth\nmiddle_name : Arielle, Jasmin, Haley, Amiya, Mercedes, Bell, Elissa, Hayley\nlast_name : Hartmann, Senger, Bednar, Wintheiser, Feest, Grant, Bartoletti\ncell_mobile_number : 1-603-110-0647, (508)319-2970x043, 724-681-4161x51632, 1-372-548-7538x314, (262)347-9364x516, 812.228.0645x91481, 01955267735, 766-272-9964\nemail_address : stanley.monahan@example.org, adele.gibson@example.net, terry.kuhlman@example.org, boyer.lonie@example.com, celestine11@example.net, oreynolds@example.com, javier.trantow@example.net, leila14@example.net\nlogin_name : uuol, mkou, qrwl, bkkv, pgub, bnto, zops, rzxu\npassword : ecae473cb54601e01457078ac0cdf4a1ced837bb, b063331ea8116befaa7b84c59c6a22200f5f8caa, 5e4ff49a61b3544da3ad7dc7e2cf28847564c64c, 7be9c03d5467d563555c51ebb3eb78e7f90832ec, 7dce9b688636ee212294c257dd2f6b85c7f65f2e, 76a93d1d3b7becc932d203beac61d064bd54e947, c55795df86182959094b83e27900f7cf44ced570, b20b6a9f24aadeda70d54e410c3219f61fb063fb\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ncustomer_id : 1, 11, 10\ndate_order_placed : 2017-03-08 05:42:10, 2015-05-17 03:05:32, 2013-10-25 17:40:25\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\norder_details : None\n*/\n" }, { "role": "user", "content": "How many airports are there per city in the US ordered from most to least?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city, country.\nThe SQL query I'll be generating is:\nSELECT count(*) , city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY count(*) DESC" } ]
[ { "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 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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE aircraft (\n\taid NUMERIC(9, 0), \n\tname TEXT(30), \n\tdistance NUMERIC(6, 0), \n\tPRIMARY KEY (aid)\n)\n/*\nColumns in aircraft and 3 examples in each column for high cardinality columns :\naid : 1, 16, 13\nname : Boeing 757-300, Lockheed L1011, Airbus A319\ndistance : 2128, 6475, 8430\n*/\n\n \nCREATE TABLE \"Parking_Fines\" (\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 Parking_Fines and all categories for low cardinality columns :\ncouncil_tax_id : 10, 9\ncmi_cross_ref_id : 4, 81\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 \"Ref_Document_Types\" (\n\tdocument_type_code CHAR(15) NOT NULL, \n\tdocument_type_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (document_type_code)\n)\n/*\nColumns in Ref_Document_Types and all categories for low cardinality columns :\ndocument_type_code : Hard Drive, CD, Paper\ndocument_type_description : f, u, b\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 body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\n*/\n \nCREATE TABLE \"Document_Locations\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Location_Code\" CHAR(15) NOT NULL, \n\t\"Date_in_Location_From\" DATETIME NOT NULL, \n\t\"Date_in_Locaton_To\" DATETIME, \n\tPRIMARY KEY (\"Document_ID\", \"Location_Code\", \"Date_in_Location_From\"), \n\tFOREIGN KEY(\"Location_Code\") REFERENCES \"Ref_Locations\" (\"Location_Code\"), \n\tFOREIGN KEY(\"Date_in_Location_From\") REFERENCES \"Ref_Calendar\" (\"Calendar_Date\"), \n\tFOREIGN KEY(\"Date_in_Locaton_To\") REFERENCES \"Ref_Calendar\" (\"Calendar_Date\"), \n\tFOREIGN KEY(\"Document_ID\") REFERENCES \"All_Documents\" (\"Document_ID\")\n)\n/*\nColumns in Document_Locations and all categories for low cardinality columns :\nDocument_ID : 230, 11, 252, 170, 7, 119, 260, 111, 166, 81\nLocation_Code : b, e, c, n, x\nDate_in_Location_From : 2009-08-18 03:29:08, 1972-03-31 09:47:22, 1986-10-14 17:53:39, 2017-01-06 23:17:22, 1997-03-10 15:24:00, 2010-11-26 19:22:50, 1985-05-13 12:19:43, 2008-06-08 12:45:38\nDate_in_Locaton_To : 2009-08-18 03:29:08, 2012-07-03 09:48:46, 1987-11-05 06:11:22, 1986-10-14 17:53:39, 2017-01-06 23:17:22, 1976-06-15 03:40:06, 1997-03-10 15:24:00, 2010-11-26 19:22:50, 1995-01-01 03:52:11, 2008-06-08 12:45:38\n*/\n \nCREATE TABLE \"match\" (\n\t\"Match_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Score\" TEXT, \n\t\"Result\" TEXT, \n\t\"Competition\" TEXT, \n\tPRIMARY KEY (\"Match_ID\")\n)\n/*\nColumns in match and all categories for low cardinality columns :\nMatch_ID : 1, 2, 5, 4, 6, 3\nDate : 23 July 1992, 18 February 1992, 19 July 1992, 23 July 2000, 4 April 1993\nVenue : Estadio Rigoberto López , Managua , Nicaragua, Estadio Cuscatlán , San Salvador , El Salvador\nScore : 3-0, 2–1, 1-0, 1–0\nResult : 5-1, 7–1, 5-0, 2–1, 2-0\nCompetition : 1994 FIFA World Cup qualification, Friendly match, 2002 FIFA World Cup qualification\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 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 technician (\n\ttechnician_id REAL, \n\t\"Name\" TEXT, \n\t\"Team\" TEXT, \n\t\"Starting_Year\" REAL, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (technician_id)\n)\n/*\nColumns in technician and all categories for low cardinality columns :\ntechnician_id : 3.0, 8.0, 10.0, 1.0, 7.0, 2.0, 6.0, 9.0, 4.0, 5.0\nName : Mark Sewell, John Brown, Mickey Cochrane, Joe Sewell, Tony Sewell, Joe Cochrane, Eddie Collins, Charlie Hollocher, Lou Boudreau\nTeam : CHC, NYY, CLE, PHA, CWS\nStarting_Year : 2013.0, 2016.0, 2003.0, 2006.0, 2005.0, 2002.0, 2009.0, 2012.0\nAge : 38, 37, 45, 46, 28, 36, 32, 47, 43, 35\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 furniture (\n\t\"Furniture_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Num_of_Component\" INTEGER, \n\t\"Market_Rate\" REAL, \n\tPRIMARY KEY (\"Furniture_ID\")\n)\n/*\nColumns in furniture and all categories for low cardinality columns :\nFurniture_ID : 1, 2, 5, 7, 4, 6, 3\nName : Dining set, Chabudai, Billiard table, Hatstand, Bookcase, Four-poster bed, Bench\nNum_of_Component : 5, 4, 6, 14, 3, 12\nMarket_Rate : 1.0, 3.5, 52.5, 0.5, 40.0, 2.0\n*/\n" }, { "role": "user", "content": "Return the cities with more than 3 airports in the United States." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city, country.\nThe SQL query I'll be generating is:\nSELECT city FROM airports WHERE country = 'United States' GROUP BY city 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 \"Parking_Fines\" (\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 Parking_Fines and all categories for low cardinality columns :\ncouncil_tax_id : 10, 9\ncmi_cross_ref_id : 4, 81\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 stock (\n\t\"Shop_ID\" INTEGER, \n\t\"Device_ID\" INTEGER, \n\t\"Quantity\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\", \"Device_ID\"), \n\tFOREIGN KEY(\"Device_ID\") REFERENCES device (\"Device_ID\"), \n\tFOREIGN KEY(\"Shop_ID\") REFERENCES shop (\"Shop_ID\")\n)\n/*\nColumns in stock and all categories for low cardinality columns :\nShop_ID : 1, 11, 2, 4, 3, 9\nDevice_ID : 4, 6\nQuantity : 110, 56, 124, 100, 200, 112, 134, 51\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 \"Apartment_Facilities\" (\n\tapt_id INTEGER NOT NULL, \n\tfacility_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (apt_id, facility_code), \n\tFOREIGN KEY(apt_id) REFERENCES \"Apartments\" (apt_id)\n)\n/*\nColumns in Apartment_Facilities and all categories for low cardinality columns :\napt_id : 1, 2, 5, 6, 3, 15, 9\nfacility_code : Gym, Swimming Pool, Boardband, Cable TV\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 \"Problem_Status_Codes\" (\n\tproblem_status_code VARCHAR(20), \n\tproblem_status_description VARCHAR(80), \n\tPRIMARY KEY (problem_status_code)\n)\n/*\nColumns in Problem_Status_Codes and all categories for low cardinality columns :\nproblem_status_code : Solved, Reported\nproblem_status_description : Solved, Reported\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 editor (\n\t\"Editor_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Age\" REAL, \n\tPRIMARY KEY (\"Editor_ID\")\n)\n/*\nColumns in editor and all categories for low cardinality columns :\nEditor_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Maria Góralczyk, Władysław Grzywna, Grażyna Wolszczak, Szymon Wydra, Piotr Pręgowski, Kamila Porczyk, Marek Siudym, Anna Powierza, Mariusz Zalejski\nAge : 43.0, 24.0, 25.0, 34.0, 38.0, 54.0, 35.0, 21.0, 20.0\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 \"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 \"Premises\" (\n\tpremise_id INTEGER, \n\tpremises_type VARCHAR(15) NOT NULL, \n\tpremise_details VARCHAR(255), \n\tPRIMARY KEY (premise_id)\n)\n/*\nColumns in Premises and 3 examples in each column for high cardinality columns :\npremise_id : 1, 13, 11\npremise_details : 5109 Jules Squares Apt. 082, 676 Kelly Spur, 00100 Green Mountains Apt. 653\n*/\n/*\nColumns in Premises and all categories for low cardinality columns :\npremises_type : Residence, Office, Warehouse\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 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 \"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 employee (\n\teid NUMERIC(9, 0), \n\tname TEXT(30), \n\tsalary NUMERIC(10, 2), \n\tPRIMARY KEY (eid)\n)\n/*\nColumns in employee and 3 examples in each column for high cardinality columns :\neid : 573284895, 90873519, 552455318\nname : Dorthy Lewis, Jennifer Thomas, Eric Cooper\nsalary : 43001.00, 33546.00, 43723.00\n*/\n\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_type_code VARCHAR(20) NOT NULL, \n\taddress_line_1 VARCHAR(80), \n\taddress_line_2 VARCHAR(80), \n\ttown_city VARCHAR(80), \n\tstate VARCHAR(80), \n\temail_address VARCHAR(255), \n\tphone_number VARCHAR(80), \n\tPRIMARY KEY (customer_id)\n)\n/*\nColumns in Customers and all categories for low cardinality columns :\ncustomer_id : 120, 114, 113, 116, 117, 115, 119, 118\ncustomer_type_code : Defaults on payments, Good Credit Rating\naddress_line_1 : 92189 Gulgowski Ranch Apt. 683, 05355 Marcelle Radial, 039 Jedidiah Estate Suite 537, 72144 Katlynn Flat Suite 512, 518 Mann Park, 425 Roman Tunnel, 1566 Ramona Overpass Apt. 464, 144 Legros Landing\naddress_line_2 : Suite 151, Apt. 551, Suite 035, Suite 959, Apt. 245, Apt. 495, Apt. 828, Suite 054\ntown_city : Funkstad, Tyreekhaven, North Alisaville, Maryamport, Hansenbury, Port Joshuah, West Annamariestad, Sauerberg\nstate : Pennsylvania, Hawaii, Tennessee, Kansas, Colorado, Iowa, Florida\nemail_address : hsteuber@example.org, vbogisich@example.org, rzulauf@example.org, cayla.satterfield@example.net, paige.hyatt@example.com, lavonne.frami@example.com, ubeier@example.org, vida86@example.com\nphone_number : 548.373.3603x59134, 044-468-4549, 06963347450, 997.698.4779x882, +38(3)9011433816, 578.019.7943x328, 1-369-302-7623x576, 470-803-0244\n*/\n" }, { "role": "user", "content": "What is the number of cities in the United States with more than 3 airports?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city, country.\nThe SQL query I'll be generating is:\nSELECT city FROM airports WHERE country = 'United States' GROUP BY city 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 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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Customer_Payments\" (\n\tcustomer_id INTEGER NOT NULL, \n\tdatetime_payment DATETIME NOT NULL, \n\tpayment_method_code VARCHAR(10) NOT NULL, \n\tamount_payment DOUBLE, \n\tPRIMARY KEY (customer_id, datetime_payment), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Customer_Payments and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\ndatetime_payment : 2018-03-20 21:38:41, 2018-02-15 16:38:49, 2018-02-19 01:49:59\namount_payment : 9570.93, 6782.84, 787.12\n*/\n/*\nColumns in Customer_Payments and all categories for low cardinality columns :\npayment_method_code : Direct Debit, Credit Card\n*/\n \nCREATE TABLE \"Web_client_accelerator\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Operating_system\" TEXT, \n\t\"Client\" TEXT, \n\t\"Connection\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Web_client_accelerator and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : Freewire, Toonel, Fasterfox\nOperating_system : Unix (Linux, *BSD, Mac OS X, others), Windows, Windows, Mac and Mobile devices, Windows, Mac, Mobile devices\n*/\n/*\nColumns in Web_client_accelerator and all categories for low cardinality columns :\nClient : End User, ISP, End user, ISP, user/Google server, user/Opera server, user/ISP, ISP, All, user\nConnection : up to 756kbit/s, Broadband, Any, Broadband, Satellite, Wireless, Fiber, DSL, Dial, DSL, ISDN, Satellite, wireless, Dial-up, Broadband, DSL, ISDN, Satellite, Wireless, Dialup, Wireless, Broadband, DSL, Dial-up\n*/\n \nCREATE TABLE \"Office_locations\" (\n\tbuilding_id INTEGER, \n\tcompany_id INTEGER, \n\tmove_in_year INTEGER, \n\tPRIMARY KEY (building_id, company_id), \n\tFOREIGN KEY(building_id) REFERENCES buildings (id), \n\tFOREIGN KEY(company_id) REFERENCES \"Companies\" (id)\n)\n/*\nColumns in Office_locations and 3 examples in each column for high cardinality columns :\nbuilding_id : 1, 11, 2\nmove_in_year : 2023, 2020, 2022\n*/\n/*\nColumns in Office_locations and all categories for low cardinality columns :\ncompany_id : 1, 11, 2, 5, 19, 7, 4, 3, 10, 9\n*/\n \nCREATE TABLE pilot (\n\t\"Pilot_Id\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(50) NOT NULL, \n\t\"Age\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Pilot_Id\")\n)\n/*\nColumns in pilot and 3 examples in each column for high cardinality columns :\nPilot_Id : 1, 11, 2\nName : Winnifred Boyle, Mr. Cristian Halvorson II, Katheryn Gorczany IV\n*/\n/*\nColumns in pilot and all categories for low cardinality columns :\nAge : 26, 37, 20, 25, 33, 30, 23, 29, 31\n*/\n \nCREATE TABLE member (\n\t\"Member_ID\" INTEGER, \n\t\"Card_Number\" TEXT, \n\t\"Name\" TEXT, \n\t\"Hometown\" TEXT, \n\t\"Level\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\")\n)\n/*\nColumns in member and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nCard_Number : LT98, RE95, LCB7, FS10, MLB4, SLB51, RCB32, OLB56, LE99, RT91\nName : Trevard Lindley, Jeremy Jarmon, Corey Peters, David Jones, Myron Pryor, Matt Lentz, Johnny Williams, Ventrell Jenkins, Braxton Kelley, Micah Johnson\nHometown : Jacksonville, Florida, Collierville, Tennessee, Columbia, South Carolina, Red Jacket, West Virginia, Fort Campbell, Kentucky, LaGrange, Georgia, Louisville, Kentucky, Simpsonville, South Carolina, Hiram, Georgia\nLevel : 2, 4, 6\n*/\n \nCREATE TABLE \"View_Product_Availability\" (\n\tproduct_id INTEGER NOT NULL, \n\tbooking_id INTEGER NOT NULL, \n\tstatus_date DATETIME, \n\tavailable_yn VARCHAR(1), \n\tPRIMARY KEY (status_date), \n\tFOREIGN KEY(product_id) REFERENCES \"Products_for_Hire\" (product_id), \n\tFOREIGN KEY(booking_id) REFERENCES \"Bookings\" (booking_id)\n)\n/*\nColumns in View_Product_Availability and all categories for low cardinality columns :\nproduct_id : 1, 2, 5, 3\nbooking_id : 11, 5\nstatus_date : 2018-03-18 05:25:55, 2018-03-25 10:20:15, 2018-03-21 15:20:32, 2018-03-22 00:16:58\navailable_yn : 1, 0\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Age\" REAL, \n\t\"Height\" REAL, \n\t\"Hometown\" TEXT, \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, 10, 9\nName : Rosa Clarissa Ortíz Melo, Elizabeth Quiñónez Aroyo, Paul Hamm, Nadia Caba Rodríguez, Eve Tatiana Cruz Oviedo, Clary Sermina Delgado Cid, Lorraine Súarez Carmona, Ashley Pérez Cabrera, Marina Castro Medina, Endis de los Santos Álvarez\nAge : 24.0, 19.0, 21.0, 23.0, 22.0, 20.0\nHeight : 1.7, 1.76, 1.72, 1.79, 1.75, 1.71, 1.81\nHometown : Santo Domingo, La Romana, Santiago de los Caballeros, Bonao, Los Alcarrizos, Miami\n*/\n \nCREATE TABLE station (\n\tid INTEGER, \n\tname TEXT, \n\tlat NUMERIC, \n\tlong NUMERIC, \n\tdock_count INTEGER, \n\tcity TEXT, \n\tinstallation_date TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in station and 3 examples in each column for high cardinality columns :\nid : 56, 65, 75\nname : Howard at 2nd, 2nd at Folsom, Market at 10th\nlat : 37.7954250000, 37.7863050000, 37.3297320000\nlong : -122.2362340000, -122.2274240000, -122.4182350000\ninstallation_date : 8/20/2013, 1/22/2014, 8/15/2013\n*/\n/*\nColumns in station and all categories for low cardinality columns :\ndock_count : 11, 25, 23, 19, 15, 27\ncity : San Jose, Mountain View, Palo Alto, Redwood City, San Francisco\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 takes (\n\t\"ID\" VARCHAR(5), \n\tcourse_id VARCHAR(8), \n\tsec_id VARCHAR(8), \n\tsemester VARCHAR(6), \n\tyear NUMERIC(4, 0), \n\tgrade VARCHAR(2), \n\tPRIMARY KEY (\"ID\", course_id, sec_id, semester, year), \n\tFOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year), \n\tFOREIGN KEY(\"ID\") REFERENCES student (\"ID\")\n)\n/*\nColumns in takes and 3 examples in each column for high cardinality columns :\nID : 99189, 44706, 56058\ncourse_id : 843, 400, 349\n*/\n/*\nColumns in takes and all categories for low cardinality columns :\nsec_id : 1, 2, 3\nsemester : Fall, Spring\nyear : 2004, 2009, 2001, 2005, 2008, 2006, 2003, 2002, 2010, 2007\ngrade : B-, B , C , B+, A , A-, C-, C+, A+\n*/\n \nCREATE TABLE company (\n\t\"Company_ID\" REAL, \n\t\"Name\" TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_in_Billion\" REAL, \n\t\"Profits_in_Billion\" REAL, \n\t\"Assets_in_Billion\" REAL, \n\t\"Market_Value_in_Billion\" REAL, \n\tPRIMARY KEY (\"Company_ID\")\n)\n/*\nColumns in company and 3 examples in each column for high cardinality columns :\nCompany_ID : 3.0, 8.0, 11.0\nName : PetroChina, Berkshire Hathaway, Petrobras\nSales_in_Billion : 82.6, 110.8, 143.7\nProfits_in_Billion : 15.7, 20.1, 25.1\nAssets_in_Billion : 213.0, 331.1, 1313.9\nMarket_Value_in_Billion : 237.4, 213.7, 164.3\n*/\n/*\nColumns in company and all categories for low cardinality columns :\nHeadquarters : UK, China, Brazil, France, Russia, USA, Germany, Netherlands\nIndustry : Retailing, Automotive, Conglomerate, Oil and gas, Banking\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 time_slot (\n\ttime_slot_id VARCHAR(4), \n\tday VARCHAR(1), \n\tstart_hr NUMERIC(2), \n\tstart_min NUMERIC(2), \n\tend_hr NUMERIC(2), \n\tend_min NUMERIC(2), \n\tPRIMARY KEY (time_slot_id, day, start_hr, start_min), \n\tCHECK (start_hr >= 0 and start_hr < 24), \n\tCHECK (start_min >= 0 and start_min < 60), \n\tCHECK (end_hr >= 0 and end_hr < 24), \n\tCHECK (end_min >= 0 and end_min < 60)\n)\n/*\nColumns in time_slot and all categories for low cardinality columns :\ntime_slot_id : E, F, C, H, A, D, G, B\nday : F, T, R, W, M\nstart_hr : 16.0000000000, 10.0000000000, 14.0000000000, 13.0000000000, 9.0000000000, 8.0000000000, 11.0000000000\nstart_min : 30.0000000000, 0E-10\nend_hr : 16.0000000000, 15.0000000000, 12.0000000000, 13.0000000000, 9.0000000000, 8.0000000000, 11.0000000000\nend_min : 30.0000000000, 45.0000000000, 50.0000000000\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 \"Products_for_Hire\" (\n\tproduct_id INTEGER, \n\tproduct_type_code VARCHAR(15) NOT NULL, \n\tdaily_hire_cost DECIMAL(19, 4), \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products_for_Hire and all categories for low cardinality columns :\nproduct_id : 1, 2, 5, 4, 3\nproduct_type_code : Din_Plates, Cutlery\ndaily_hire_cost : 18.5000, 39.5800, 15.6200, 39.7300, 26.1500\nproduct_name : DVD collection B, DVD collection A, Book collection C, Book collection A, Book collection B\nproduct_description : The Great Gatsby, Anna Karenina, One Hundred Years of Solitude, War and Peace, Twilight\n*/\n" }, { "role": "user", "content": "List the cities which have more than one airport and number of airports." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city.\nThe SQL query I'll be generating is:\nSELECT city , count(*) FROM airports GROUP BY city HAVING count(*) > 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 drivers (\n\t\"driverId\" INTEGER, \n\t\"driverRef\" TEXT, \n\tnumber TEXT, \n\tcode TEXT, \n\tforename TEXT, \n\tsurname TEXT, \n\tdob TEXT, \n\tnationality TEXT, \n\turl TEXT, \n\tPRIMARY KEY (\"driverId\")\n)\n/*\nColumns in drivers and 3 examples in each column for high cardinality columns :\ndriverId : 87, 56, 65\ndriverRef : prost, katayama, satoru_nakajima\nnumber : , 5, 44\ncode : WEB, FMO, \nforename : Adrian, Gary, Eliseo\nsurname : Blundell, Boullion, Verstappen\ndob : 06/10/1951, 27/11/1957, 23/09/1981\nnationality : Argentine, Colombian, Czech\nurl : http://en.wikipedia.org/wiki/Ricardo_Rosset, http://en.wikipedia.org/wiki/Alex_Zanardi, http://en.wikipedia.org/wiki/Marc_Surer\n*/\n\n \nCREATE TABLE coach (\n\t\"Coach_ID\" INTEGER, \n\t\"Coach_name\" TEXT, \n\t\"Gender\" TEXT, \n\t\"Club_ID\" INTEGER, \n\t\"Rank\" INTEGER, \n\tPRIMARY KEY (\"Coach_ID\"), \n\tFOREIGN KEY(\"Club_ID\") REFERENCES club (\"Club_ID\")\n)\n/*\nColumns in coach and all categories for low cardinality columns :\nCoach_ID : 1, 2, 5, 4, 3\nCoach_name : Robert Chen, James Wong, Smith Brown, Jameson Tomas, Joe Fabbri\nGender : F, M\nClub_ID : 1, 3\nRank : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"College\" (\n\t\"cName\" VARCHAR(20) NOT NULL, \n\tstate VARCHAR(2), \n\tenr NUMERIC(5, 0), \n\tPRIMARY KEY (\"cName\")\n)\n/*\nColumns in College and all categories for low cardinality columns :\ncName : FSU, OU, ASU, LSU\nstate : AZ, FL, LA, OK\nenr : 22000, 19000, 12000, 18000\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 \"CHECKING\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in CHECKING and all categories for low cardinality columns :\ncustid : 1, 2, 5, 7, 4, 6, 3\nbalance : 3000.0, 10000.0, 2000.0, 7.0, 7000.0, 77.0\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 technician (\n\ttechnician_id REAL, \n\t\"Name\" TEXT, \n\t\"Team\" TEXT, \n\t\"Starting_Year\" REAL, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (technician_id)\n)\n/*\nColumns in technician and all categories for low cardinality columns :\ntechnician_id : 3.0, 8.0, 10.0, 1.0, 7.0, 2.0, 6.0, 9.0, 4.0, 5.0\nName : Mark Sewell, John Brown, Mickey Cochrane, Joe Sewell, Tony Sewell, Joe Cochrane, Eddie Collins, Charlie Hollocher, Lou Boudreau\nTeam : CHC, NYY, CLE, PHA, CWS\nStarting_Year : 2013.0, 2016.0, 2003.0, 2006.0, 2005.0, 2002.0, 2009.0, 2012.0\nAge : 38, 37, 45, 46, 28, 36, 32, 47, 43, 35\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduct_category_code VARCHAR(20) NOT NULL, \n\tdate_product_first_available DATETIME, \n\tdate_product_discontinued DATETIME, \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tproduct_price DECIMAL(19, 4), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\nparent_product_id : 8, 4, 9, 3\nproduct_category_code : Food, Book, Hardware\ndate_product_first_available : 1988-09-29 17:54:50, 1998-06-20 15:04:11, 1994-12-18 15:13:19, 1974-06-25 12:26:47\ndate_product_discontinued : 1987-12-20 13:46:16, 1997-07-02 18:26:16, 1980-06-26 10:40:19, 1991-08-20 05:22:31\nproduct_name : Chocolate, The Great Gatsby, Mouse, Keyboard\nproduct_description : Designed for games, Handmade chocolate, American novel, Blue tooth mouse\nproduct_price : 23.3500, 2.8800, 109.9900, 35.0000\n*/\n \nCREATE TABLE \"Rooms\" (\n\t\"RoomId\" TEXT, \n\t\"roomName\" TEXT, \n\tbeds INTEGER, \n\t\"bedType\" TEXT, \n\t\"maxOccupancy\" INTEGER, \n\t\"basePrice\" INTEGER, \n\tdecor TEXT, \n\tPRIMARY KEY (\"RoomId\")\n)\n/*\nColumns in Rooms and all categories for low cardinality columns :\nRoomId : IBD, IBS, RTE, CAS, FNA, HBB, AOB, MWC, TAA, RND\nroomName : Convoke and sanguine, Immutable before decorum, Abscond or bolster, Recluse and defiance, Thrift and accolade, Riddle to exculpate, Harbinger but bequest, Frugal not apropos, Interim but salutary, Mendicant with cryptic\nbeds : 1, 2\nbedType : King, Double, Queen\nmaxOccupancy : 2, 4\nbasePrice : 250, 75, 100, 150, 125, 175\ndecor : modern, rustic, traditional\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 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 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 \"Trained_In\" (\n\t\"Physician\" INTEGER NOT NULL, \n\t\"Treatment\" INTEGER NOT NULL, \n\t\"CertificationDate\" DATETIME NOT NULL, \n\t\"CertificationExpires\" DATETIME NOT NULL, \n\tPRIMARY KEY (\"Physician\", \"Treatment\"), \n\tCONSTRAINT \"fk_Trained_In_Physician_EmployeeID\" FOREIGN KEY(\"Physician\") REFERENCES \"Physician\" (\"EmployeeID\"), \n\tCONSTRAINT \"fk_Trained_In_Procedures_Code\" FOREIGN KEY(\"Treatment\") REFERENCES \"Procedures\" (\"Code\")\n)\n/*\nColumns in Trained_In and all categories for low cardinality columns :\nPhysician : 7, 6, 3\nTreatment : 1, 2, 5, 7, 4, 6, 3\nCertificationDate : 2008-01-01 00:00:00, 2007-01-01 00:00:00\nCertificationExpires : 2007-12-31 00:00:00, 2008-12-31 00:00:00\n*/\n \nCREATE TABLE \"Third_Party_Companies\" (\n\tcompany_id INTEGER, \n\tcompany_type VARCHAR(5) NOT NULL, \n\tcompany_name VARCHAR(255), \n\tcompany_address VARCHAR(255), \n\tother_company_details VARCHAR(255), \n\tPRIMARY KEY (company_id)\n)\n/*\nColumns in Third_Party_Companies and 3 examples in each column for high cardinality columns :\ncompany_id : 1, 13, 11\ncompany_name : Weimann-Swift, Glover-Vandervort, Dicki, Erdman and Kris\ncompany_address : 615 Jacobs Mews, 9576 Jacynthe Point Suite 747, 51515 Conn Corner Suite 696\nother_company_details : Palestinian Territory, Slovenia, Somalia\n*/\n/*\nColumns in Third_Party_Companies and all categories for low cardinality columns :\ncompany_type : Maintenance Contractor, Supplier\n*/\n \nCREATE TABLE film (\n\t\"Film_ID\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Studio\" TEXT, \n\t\"Director\" TEXT, \n\t\"Gross_in_dollar\" INTEGER, \n\tPRIMARY KEY (\"Film_ID\")\n)\n/*\nColumns in film and 3 examples in each column for high cardinality columns :\nFilm_ID : 1, 13, 11\nTitle : Annie, Rocky III, Tootsie\nDirector : Richard Attenborough, Nicholas Meyer, Ted Kotcheff\nGross_in_dollar : 53977250, 76606280, 125049125\n*/\n/*\nColumns in film and all categories for low cardinality columns :\nStudio : MGM, United Artists, Universal, 20th Century Fox, Columbia, Paramount, Columbia / Rastar, Paramount / Lorimar, Orion / Carolco, Universal / RKO\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 people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Date_of_Birth\" TEXT, \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\nName : Fabrizio Buonocore, Goran Fiorentini, Francesco Postiglione, Alberto Angelini, Leonardo Binchi, Marco Gerini, Roberto Calcaterra, Maurizio Felugo\nHeight : 1.9, 1.86, 1.72, 1.75, 1.95, 1.78, 1.82, 1.83\nWeight : 45.0, 89.0, 67.0, 58.0, 57.0, 75.0, 76.0, 80.0\nDate_of_Birth : 1975-08-27, 1971-08-05, 1972-04-29, 1977-04-28, 1981-03-04, 1972-02-06, 1981-11-21, 1974-09-28\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_type_code VARCHAR(15), \n\tproduct_name VARCHAR(80), \n\tproduct_price DOUBLE, \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nproduct_price : 5927021.8748021, 622.79275984494, 22956668.699482\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_type_code : Hardware, Clothes\nproduct_name : Apple, jcrew, Sony, gucci\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n" }, { "role": "user", "content": "What are the names of all cities with more than one airport and how many airports do they have?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city.\nThe SQL query I'll be generating is:\nSELECT city , count(*) FROM airports GROUP BY city HAVING count(*) > 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 \"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 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 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 \"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 device (\n\t\"Device_ID\" INTEGER, \n\t\"Device\" TEXT, \n\t\"Carrier\" TEXT, \n\t\"Package_Version\" TEXT, \n\t\"Applications\" TEXT, \n\t\"Software_Platform\" TEXT, \n\tPRIMARY KEY (\"Device_ID\")\n)\n/*\nColumns in device and all categories for low cardinality columns :\nDevice_ID : 1, 2, 5, 4, 6, 3\nDevice : Huawei, Galaxy, Apple, Xiaomi, BlackBerry Storm 9530, Samsung\nCarrier : MTS Mobility, Bell Mobility, Telus Mobility, Vodafone AU, Verizon Wireless, Iusacell\nPackage_Version : 4.7.0.208, 5.0.0.742, 5.0.0.808, 5.0.0.328, 5.0.0.419\nApplications : 4.7.0.151, 5.0.0.451, 5.0.0.328, 5.0.0.419\nSoftware_Platform : iOS, Android\n*/\n \nCREATE TABLE \"View_Unit_Status\" (\n\tapt_id INTEGER, \n\tapt_booking_id INTEGER, \n\tstatus_date DATETIME NOT NULL, \n\tavailable_yn NUMERIC, \n\tPRIMARY KEY (status_date), \n\tFOREIGN KEY(apt_id) REFERENCES \"Apartments\" (apt_id), \n\tFOREIGN KEY(apt_booking_id) REFERENCES \"Apartment_Bookings\" (apt_booking_id)\n)\n/*\nColumns in View_Unit_Status and 3 examples in each column for high cardinality columns :\napt_id : 1, 13, 11\napt_booking_id : 924, 497, 575\nstatus_date : 2011-02-12 09:04:07, 2003-07-25 10:13:48, 2000-02-04 07:50:09\n*/\n/*\nColumns in View_Unit_Status and all categories for low cardinality columns :\navailable_yn : 0E-10, 1.0000000000\n*/\n \nCREATE TABLE \"Payments\" (\n\t\"Payment_ID\" INTEGER NOT NULL, \n\t\"Settlement_ID\" INTEGER NOT NULL, \n\t\"Payment_Method_Code\" VARCHAR(255), \n\t\"Date_Payment_Made\" DATE, \n\t\"Amount_Payment\" INTEGER, \n\tPRIMARY KEY (\"Payment_ID\"), \n\tFOREIGN KEY(\"Settlement_ID\") REFERENCES \"Settlements\" (\"Settlement_ID\")\n)\n/*\nColumns in Payments and 3 examples in each column for high cardinality columns :\nPayment_ID : 754, 739, 542\nDate_Payment_Made : 2017-06-24, 2017-08-06, 2017-12-16\nAmount_Payment : 423154, 155654, 71246\n*/\n/*\nColumns in Payments and all categories for low cardinality columns :\nSettlement_ID : 527, 476, 564, 983, 682, 648, 597, 512, 516\nPayment_Method_Code : Visa, Discover Card, American Express, MasterCard\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 \"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 \"Addresses\" (\n\taddress_id INTEGER NOT NULL, \n\taddress_details VARCHAR(255), \n\tPRIMARY KEY (address_id)\n)\n/*\nColumns in Addresses and all categories for low cardinality columns :\naddress_id : 1, 2, 5, 7, 8, 4, 6, 3, 9, 0\naddress_details : PT, IT, MX, US, DE, IE, ES\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 shop (\n\t\"Shop_ID\" INTEGER, \n\t\"Shop_Name\" TEXT, \n\t\"Location\" TEXT, \n\t\"Open_Date\" TEXT, \n\t\"Open_Year\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\")\n)\n/*\nColumns in shop and 3 examples in each column for high cardinality columns :\nShop_ID : 1, 11, 2\nShop_Name : Pentre store, Best Buy, Apple\nOpen_Date : 24 February, 18 February, 1 January\n*/\n/*\nColumns in shop and all categories for low cardinality columns :\nLocation : Maerdy, Porth, Blaenllechau, Pentre, Penygraig, Gelli, Dinas, Wattstown, Cymmer\nOpen_Year : 2009, 2013, 2015, 2017, 2006, 2011, 2014, 2010, 2007\n*/\n \nCREATE TABLE invoice_lines (\n\tid INTEGER, \n\tinvoice_id INTEGER NOT NULL, \n\ttrack_id INTEGER NOT NULL, \n\tunit_price NUMERIC(10, 2) NOT NULL, \n\tquantity INTEGER NOT NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(invoice_id) REFERENCES invoices (id), \n\tFOREIGN KEY(track_id) REFERENCES tracks (id)\n)\n/*\nColumns in invoice_lines and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\ninvoice_id : 36, 17, 21\ntrack_id : 1188, 756, 988\n*/\n/*\nColumns in invoice_lines and all categories for low cardinality columns :\nunit_price : 0.99\nquantity : 1\n*/\n \nCREATE TABLE \"Visits_Restaurant\" (\n\t\"StuID\" INTEGER, \n\t\"ResID\" INTEGER, \n\t\"Time\" TIMESTAMP, \n\t\"Spent\" FLOAT, \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"ResID\") REFERENCES \"Restaurant\" (\"ResID\")\n)\n/*\nColumns in Visits_Restaurant and all categories for low cardinality columns :\nStuID : 1001, 1032\nResID : 1, 2\nTime : 2017-10-09 18:15:00, 2017-10-08 13:00:30\nSpent : 13.2, 6.53\n*/\n \nCREATE TABLE \"Playlist\" (\n\t\"PlaylistId\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(120) DEFAULT NULL, \n\tPRIMARY KEY (\"PlaylistId\")\n)\n/*\nColumns in Playlist and 3 examples in each column for high cardinality columns :\nPlaylistId : 1, 16, 13\nName : Heavy Metal Classic, 90’s Music, Classical 101 - Deep Cuts\n*/\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 \"First_Notification_of_Loss\" (\n\t\"FNOL_ID\" INTEGER NOT NULL, \n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Service_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"FNOL_ID\"), \n\tFOREIGN KEY(\"Service_ID\") REFERENCES \"Services\" (\"Service_ID\"), \n\tFOREIGN KEY(\"Customer_ID\", \"Policy_ID\") REFERENCES \"Customers_Policies\" (\"Customer_ID\", \"Policy_ID\"), \n\tUNIQUE (\"FNOL_ID\")\n)\n/*\nColumns in First_Notification_of_Loss and all categories for low cardinality columns :\nFNOL_ID : 1611, 4226, 2543, 4525, 1722, 4323, 532\nCustomer_ID : 582, 892, 826, 214, 996\nPolicy_ID : 586, 630, 257, 927, 366, 879, 993\nService_ID : 1, 9, 4, 6\n*/\n" }, { "role": "user", "content": "List the cities which have more than 2 airports sorted by the number of airports." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city.\nThe SQL query I'll be generating is:\nSELECT city FROM airports GROUP BY city HAVING count(*) > 2 ORDER BY count(*)" } ]
[ { "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 \"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 mountain (\n\tid INTEGER, \n\tname TEXT, \n\t\"Height\" REAL, \n\t\"Prominence\" REAL, \n\t\"Range\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in mountain and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Kaka / Kecha / Chiqe, Aksouâl, Ioll / Yoll\nHeight : 4167.0, 4120.0, 4071.0\nProminence : 1540.0, 3931.0, 610.0\nRange : Toubkal Atlas, Aberdare Range, Semien Mountains\n*/\n/*\nColumns in mountain and all categories for low cardinality columns :\nCountry : Cameroon, Morocco, Kenya, Rwanda Uganda, Ethiopia\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 1, 2, 3\nproduct_details : Dove Chocolate, Americano, Latte\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 operate_company (\n\tid INTEGER, \n\tname TEXT, \n\t\"Type\" TEXT, \n\t\"Principal_activities\" TEXT, \n\t\"Incorporated_in\" TEXT, \n\t\"Group_Equity_Shareholding\" REAL, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in operate_company and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nname : China Pacific Laundry Services, Cathay Pacific Holidays, CLS Catering Services Limited\n*/\n/*\nColumns in operate_company and all categories for low cardinality columns :\nType : Joint Venture, Subsidiary, Corporate\nPrincipal_activities : Laundry, Airline, Catering services, Travel agency, Ground handling, Cargo, Cargo airline\nIncorporated_in : Canada, China, Hong Kong, Vietnam, Taiwan\nGroup_Equity_Shareholding : 45.0, 60.0, 30.0, 49.0, 100.0, 40.0, 18.77\n*/\n \nCREATE TABLE stadium (\n\t\"ID\" INTEGER, \n\tname TEXT, \n\t\"Capacity\" INTEGER, \n\t\"City\" TEXT, \n\t\"Country\" TEXT, \n\t\"Opening_year\" INTEGER, \n\tPRIMARY KEY (\"ID\")\n)\n/*\nColumns in stadium and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Northumberland Development Project, Fisht Olympic Stadium, Ferenc Puskás Stadion, Nou Mestalla, Yubileyniy Stadium, Estadio La Peineta, Baku Olympic Stadium, Arena Baltika, Stade des Lumières, Gazprom Arena\nCapacity : 61556, 69501, 56250, 68000, 47659, 45015, 67500, 75000, 65000\nCity : London, Sochi, Budapest, Saint Petersburg, Baku, Kaliningrad, Madrid, Valencia, Lyon, Saransk\nCountry : Spain, France, England, Russia, Azerbaijan, Hungary\nOpening_year : 2004, 2005, 2007, 2006\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Reviewer\" (\n\t\"rID\" INTEGER, \n\tname TEXT, \n\tPRIMARY KEY (\"rID\")\n)\n/*\nColumns in Reviewer and all categories for low cardinality columns :\nrID : 201, 204, 205, 207, 206, 203, 208, 202\nname : Chris Jackson, Sarah Martinez, Mike Anderson, James Cameron, Elizabeth Thomas, Brittany Harris, Daniel Lewis, Ashley White\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 \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 airport (\n\t\"Airport_ID\" INTEGER, \n\t\"Airport_Name\" TEXT, \n\t\"Total_Passengers\" REAL, \n\t\"%_Change_2007\" TEXT, \n\t\"International_Passengers\" REAL, \n\t\"Domestic_Passengers\" REAL, \n\t\"Transit_Passengers\" REAL, \n\t\"Aircraft_Movements\" REAL, \n\t\"Freight_Metric_Tonnes\" REAL, \n\tPRIMARY KEY (\"Airport_ID\")\n)\n/*\nColumns in airport and all categories for low cardinality columns :\nAirport_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nAirport_Name : Bristol, London Luton, East Midlands, Birmingham Airport, Glasgow International, London Stansted, London Heathrow, London Gatwick, Edinburgh, Manchester\nTotal_Passengers : 8178891.0, 5620673.0, 34205887.0, 9627589.0, 67054745.0, 6267114.0, 10180734.0, 21219195.0, 22360364.0, 9006702.0\n%_Change_2007 : 2.6%, 4.0%, 6.0%, 1.5%, 0.5%, 5.7%, 2.9%, 4.3%, 3.8%, 7.0%\nInternational_Passengers : 3711140.0, 8105162.0, 3943139.0, 19996947.0, 5057051.0, 4870184.0, 8853224.0, 61344438.0, 30431051.0, 18119230.0\nDomestic_Passengers : 746094.0, 5562516.0, 1171605.0, 2943719.0, 1471538.0, 4192121.0, 3730963.0, 1320678.0, 2343428.0, 5281038.0\nTransit_Passengers : 156246.0, 50889.0, 6832.0, 19989.0, 43873.0, 43631.0, 14524.0, 38458.0, 4395.0, 147791.0\nAircraft_Movements : 478693.0, 117859.0, 204610.0, 193282.0, 125550.0, 76517.0, 112227.0, 100087.0, 93038.0, 263653.0\nFreight_Metric_Tonnes : 3.0, 261507.0, 12418.0, 40518.0, 197738.0, 141781.0, 107702.0, 3546.0, 12192.0, 1397054.0\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 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 \"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 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" }, { "role": "user", "content": "What are the cities that have more than 2 airports sorted by number of airports?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city.\nThe SQL query I'll be generating is:\nSELECT city FROM airports GROUP BY city HAVING count(*) > 2 ORDER BY count(*)" } ]
[ { "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 tweets (\n\tid BIGINT NOT NULL, \n\tuid INTEGER NOT NULL, \n\ttext CHAR(140) NOT NULL, \n\tcreatedate DATETIME DEFAULT CURRENT_TIMESTAMP, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(uid) REFERENCES user_profiles (uid)\n)\n/*\nColumns in tweets and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 9\nuid : 1, 5, 4, 6, 3\ntext : Today I have went shopping at Laffayette., Let’s celebrate women, fight for equality and support each other, not just today, but everyday!, Oh, I only have a few fans., I love my new boyfriend., I feel tired and don't want to write SQLs., My company is hiring interns., Hello I'm Tony Stark., I had a pretty rough time during the last couple of weeks\ncreatedate : 2018-03-09 20:00:14, 2018-03-12 02:30:30, 2018-03-09 20:01:02\n*/\n \nCREATE TABLE body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\n*/\n \nCREATE TABLE workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Age\" REAL, \n\t\"Height\" REAL, \n\t\"Hometown\" TEXT, \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, 10, 9\nName : Rosa Clarissa Ortíz Melo, Elizabeth Quiñónez Aroyo, Paul Hamm, Nadia Caba Rodríguez, Eve Tatiana Cruz Oviedo, Clary Sermina Delgado Cid, Lorraine Súarez Carmona, Ashley Pérez Cabrera, Marina Castro Medina, Endis de los Santos Álvarez\nAge : 24.0, 19.0, 21.0, 23.0, 22.0, 20.0\nHeight : 1.7, 1.76, 1.72, 1.79, 1.75, 1.71, 1.81\nHometown : Santo Domingo, La Romana, Santiago de los Caballeros, Bonao, Los Alcarrizos, Miami\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 railway (\n\t\"Railway_ID\" INTEGER, \n\t\"Railway\" TEXT, \n\t\"Builder\" TEXT, \n\t\"Built\" TEXT, \n\t\"Wheels\" TEXT, \n\t\"Location\" TEXT, \n\t\"ObjectNumber\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\")\n)\n/*\nColumns in railway and all categories for low cardinality columns :\nRailway_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nRailway : Longmoor, LTSR, GWRWk, GERSt, GWRSn, GERHt, MR, SECR, GWRS, GNRD\nBuilder : GNR Doncaster, Stephenson, Swindon Works, GWR Swindon, GER Stratford, MR Derby, GER Hartford, SECR Ashford, Avonside\nBuilt : 1902 Midland Railway 1000 was rebuilt in 1914., 1902, 1901, 1905, 1907, 1903, 1904, 1909, 1910\nWheels : 4-4-0, 4-6-0, 0-6-0T, 4-4-2, 4-4-2T, 2-8-0, 0-6-0, 0-6-0ST\nLocation : Shildon, Swindon, Basingstoke, York, Toddington, Barrow Hill, Bressingham, Bo'ness\nObjectNumber : 1975-7005, 1978-7028, 1978-7025, 1975-7003, 1978-7026, 2008-7159, 1975-7006, 1978-7027, 1975-7018, 1976-7001\n*/\n \nCREATE TABLE branch (\n\t\"Branch_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Open_year\" TEXT, \n\t\"Address_road\" TEXT, \n\t\"City\" TEXT, \n\tmembership_amount TEXT, \n\tPRIMARY KEY (\"Branch_ID\")\n)\n/*\nColumns in branch and all categories for low cardinality columns :\nBranch_ID : 1, 2, 5, 7, 8, 4, 6, 3\nName : Popert, Zytogorski, Alexandre, Brooke Greville, Taverner, Stanley, Saint Amant, Cochrane\nOpen_year : 2009, 2013, 2015, 2001, 2012, 2014\nAddress_road : Abbott Street, Concord Road, Brampton Road, Cecilia Avenue, Oaks Crescent, Valleys Place, Glebe Street, Abbey Rise\nCity : Oxford, London\nmembership_amount : 91, 56, 11, 1418, 7, 6, 112, 31\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 competition (\n\t\"Competition_ID\" INTEGER, \n\t\"Year\" REAL, \n\t\"Competition_type\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (\"Competition_ID\")\n)\n/*\nColumns in competition and 3 examples in each column for high cardinality columns :\nCompetition_ID : 1, 11, 2\n*/\n/*\nColumns in competition and all categories for low cardinality columns :\nYear : 2006.0, 2007.0\nCompetition_type : Tournament, Friendly\nCountry : Italy, Slovenia, Spain, Australia, Russia, Ireland\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 \"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 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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 user_profiles (\n\tuid INTEGER NOT NULL, \n\tname VARCHAR(255) DEFAULT NULL, \n\temail VARCHAR(255) DEFAULT NULL, \n\tpartitionid INTEGER DEFAULT NULL, \n\tfollowers INTEGER DEFAULT NULL, \n\tPRIMARY KEY (uid)\n)\n/*\nColumns in user_profiles and all categories for low cardinality columns :\nuid : 1, 2, 5, 7, 4, 6, 3\nname : Natalie Portman, Mary, Black Widow\n, Tyler Swift, Celine Dion, Iron Man, Susan\nemail : susan@gmail.com\n, ts@superstar.com\n, cd@superstar.com, np@superstar.com, ts@richest.com, bw@superhero.com, Mary@yale.edu\npartitionid : 1, 2, 5, 23, 10\nfollowers : 23927492, 100, 94375428, 35425845, 890, 99999998, 6662425\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 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" }, { "role": "user", "content": "Find the number of routes for each source airport and the airport name." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.src_apid.\nThe SQL query I'll be generating is:\nSELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name" } ]
[ { "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 host (\n\t\"Host_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Age\" TEXT, \n\tPRIMARY KEY (\"Host_ID\")\n)\n/*\nColumns in host and all categories for low cardinality columns :\nHost_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Lloyd Daniels, Kornel David, Antonio Davis, Carlos Delfino, DeMar DeRozan, Ed Davis, Austin Daye, Derrick Dial, Justin Dentmon, Hubert Davis\nNationality : United States, Argentina, Hungary\nAge : 26, 45, 37, 40, 30, 60, 47, 43, 31\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 station (\n\t\"Station_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Annual_entry_exit\" REAL, \n\t\"Annual_interchanges\" REAL, \n\t\"Total_Passengers\" REAL, \n\t\"Location\" TEXT, \n\t\"Main_Services\" TEXT, \n\t\"Number_of_Platforms\" INTEGER, \n\tPRIMARY KEY (\"Station_ID\")\n)\n/*\nColumns in station and 3 examples in each column for high cardinality columns :\nStation_ID : 1, 11, 2\nName : London King's Cross, London Waterloo, Birmingham New Street\nAnnual_entry_exit : 20.551, 21.797, 36.609\nAnnual_interchanges : 9.157, 2.064, 9.489\nTotal_Passengers : 26.892, 29.658, 30.896\nMain_Services : South Eastern Main Line, Great Eastern Main Line Lea Valley Lines, Midland Main Line Thameslink High-Speed 1 Eurostar\n*/\n/*\nColumns in station and all categories for low cardinality columns :\nLocation : Glasgow, London, Birmingham\nNumber_of_Platforms : 13, 15, 17, 6, 12, 19, 18\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 flight (\n\tflno NUMERIC(4, 0), \n\torigin TEXT(20), \n\tdestination TEXT(20), \n\tdistance NUMERIC(6, 0), \n\tdeparture_date DATE, \n\tarrival_date DATE, \n\tprice NUMERIC(7, 2), \n\taid NUMERIC(9, 0), \n\tPRIMARY KEY (flno), \n\tFOREIGN KEY(aid) REFERENCES aircraft (aid)\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 \"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 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 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 \"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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Addresses\" (\n\taddress_id INTEGER NOT NULL, \n\taddress_details VARCHAR(255), \n\tPRIMARY KEY (address_id)\n)\n/*\nColumns in Addresses and all categories for low cardinality columns :\naddress_id : 1, 2, 5, 7, 8, 4, 6, 3, 9, 0\naddress_details : PT, IT, MX, US, DE, IE, ES\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 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 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 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 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" }, { "role": "user", "content": "For each airport name, how many routes start at that airport?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.src_apid.\nThe SQL query I'll be generating is:\nSELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name" } ]
[ { "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 \"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 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 course (\n\tcourse_id VARCHAR(8), \n\ttitle VARCHAR(50), \n\tdept_name VARCHAR(20), \n\tcredits NUMERIC(2, 0), \n\tPRIMARY KEY (course_id), \n\tFOREIGN KEY(dept_name) REFERENCES department (dept_name), \n\tCHECK (credits > 0)\n)\n/*\nColumns in course and 3 examples in each column for high cardinality columns :\ncourse_id : 241, 586, 377\ntitle : Numerical Methods, Thermal Physics, Stream Processing\ndept_name : Math, Athletics, English\n*/\n/*\nColumns in course and all categories for low cardinality columns :\ncredits : 4, 3\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 accelerator_compatible_browser (\n\taccelerator_id INTEGER, \n\tbrowser_id INTEGER, \n\tcompatible_since_year INTEGER, \n\tPRIMARY KEY (accelerator_id, browser_id), \n\tFOREIGN KEY(browser_id) REFERENCES browser (id), \n\tFOREIGN KEY(accelerator_id) REFERENCES \"Web_client_accelerator\" (id)\n)\n/*\nColumns in accelerator_compatible_browser and all categories for low cardinality columns :\naccelerator_id : 1, 2, 4, 3, 9\nbrowser_id : 1, 2, 4, 3\ncompatible_since_year : 2009, 2005, 1995, 2008, 2000, 1996, 2010, 2007\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 city (\n\t\"City_ID\" INTEGER, \n\t\"Official_Name\" TEXT, \n\t\"Status\" TEXT, \n\t\"Area_km_2\" REAL, \n\t\"Population\" REAL, \n\t\"Census_Ranking\" TEXT, \n\tPRIMARY KEY (\"City_ID\")\n)\n/*\nColumns in city and all categories for low cardinality columns :\nCity_ID : 1, 2, 5, 4, 3\nOfficial_Name : Plaster Rock, Aroostook, Perth-Andover, Drummond, Grand Falls/Grand-Sault\nStatus : Village, Town\nArea_km_2 : 8.91, 18.06, 8.89, 2.24, 3.09\nPopulation : 351.0, 1135.0, 775.0, 1778.0, 5706.0\nCensus_Ranking : 3460 of 5008, 1936 of 5,008, 2418 of 5008, 636 of 5008, 1442 of 5,008\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 railway_manage (\n\t\"Railway_ID\" INTEGER, \n\t\"Manager_ID\" INTEGER, \n\t\"From_Year\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\", \"Manager_ID\"), \n\tFOREIGN KEY(\"Manager_ID\") REFERENCES manager (\"Manager_ID\"), \n\tFOREIGN KEY(\"Railway_ID\") REFERENCES railway (\"Railway_ID\")\n)\n/*\nColumns in railway_manage and all categories for low cardinality columns :\nRailway_ID : 7, 8, 2, 9\nManager_ID : 1, 2, 4, 3\nFrom_Year : 2012, 2010, 2011, 2013\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 \"Order_Items\" (\n\titem_id INTEGER NOT NULL, \n\torder_item_status_code VARCHAR(15) NOT NULL, \n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\titem_status_code VARCHAR(15), \n\titem_delivered_datetime DATETIME, \n\titem_order_quantity VARCHAR(80), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\nitem_id : 1, 13, 11\nitem_delivered_datetime : 2018-03-16 15:58:27, 2018-03-04 18:19:12, 2018-03-12 20:01:38\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\norder_item_status_code : Paid, Delivered, Cancelled\norder_id : 13, 11, 2, 15, 7, 8, 6, 14, 10\nproduct_id : 1, 13, 11, 5, 7, 6, 14, 3, 10, 9\nitem_status_code : good\nitem_order_quantity : 1, 2, 5, 7, 4, 6, 3, 9\n*/\n \nCREATE TABLE county_public_safety (\n\t\"County_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Population\" INTEGER, \n\t\"Police_officers\" INTEGER, \n\t\"Residents_per_officer\" INTEGER, \n\t\"Case_burden\" INTEGER, \n\t\"Crime_rate\" REAL, \n\t\"Police_force\" TEXT, \n\t\"Location\" TEXT, \n\tPRIMARY KEY (\"County_ID\")\n)\n/*\nColumns in county_public_safety and all categories for low cardinality columns :\nCounty_ID : 1, 2, 5, 4, 6, 3\nName : Central Saanich, Campbell River, Chilliwack, Castlegar, Burnaby, Abbotsford\nPopulation : 16821, 204320, 128165, 73066, 7821, 30810\nPolice_officers : 91, 11, 187, 253, 40, 21\nResidents_per_officer : 711, 770, 801, 808, 803, 685\nCase_burden : 100, 137, 140, 39, 107, 81\nCrime_rate : 178.0, 150.0, 49.0, 118.0, 174.0, 123.0\nPolice_force : Abbotsford Police Department, Central Saanich Police, RCMP\nLocation : West, East, North\n*/\n \nCREATE TABLE \"Order_Items\" (\n\t\"Order_Item_ID\" INTEGER NOT NULL, \n\t\"Order_ID\" INTEGER NOT NULL, \n\t\"Product_ID\" INTEGER NOT NULL, \n\t\"Order_Quantity\" VARCHAR(288), \n\t\"Other_Item_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Order_Item_ID\"), \n\tFOREIGN KEY(\"Order_ID\") REFERENCES \"Customer_Orders\" (\"Order_ID\"), \n\tFOREIGN KEY(\"Product_ID\") REFERENCES \"Products\" (\"Product_ID\")\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\nOrder_Item_ID : 1, 13, 11\nOrder_ID : 1, 10, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nProduct_ID : 300, 233, 46, 156, 83, 179, 216, 81, 273\nOrder_Quantity : 1, 2\nOther_Item_Details : None\n*/\n \nCREATE TABLE \"Mailshot_Customers\" (\n\tmailshot_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\toutcome_code VARCHAR(15) NOT NULL, \n\tmailshot_customer_date DATETIME, \n\tFOREIGN KEY(mailshot_id) REFERENCES \"Mailshot_Campaigns\" (mailshot_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Mailshot_Customers and 3 examples in each column for high cardinality columns :\nmailshot_customer_date : 2018-03-05 20:48:13, 2018-03-20 23:40:02, 2018-03-03 15:29:56\n*/\n/*\nColumns in Mailshot_Customers and all categories for low cardinality columns :\nmailshot_id : 20, 18, 15, 7, 17, 4, 6, 10\ncustomer_id : 1, 13, 11, 2, 4, 6, 14, 3, 9\noutcome_code : Order, No Response\n*/\n \nCREATE TABLE item (\n\ti_id INTEGER NOT NULL, \n\ttitle VARCHAR(20) DEFAULT NULL, \n\tPRIMARY KEY (i_id)\n)\n/*\nColumns in item and all categories for low cardinality columns :\ni_id : 1, 2, 5, 7, 4, 6, 3, 0\ntitle : pear, shampoo, blue hoodie, orange, comb, cup, avocado, apple\n*/\n" }, { "role": "user", "content": "Find the number of routes and airport name for each source airport, order the results by decreasing number of routes." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.src_apid.\nThe SQL query I'll be generating is:\nSELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC" } ]
[ { "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 employee (\n\teid NUMERIC(9, 0), \n\tname TEXT(30), \n\tsalary NUMERIC(10, 2), \n\tPRIMARY KEY (eid)\n)\n/*\nColumns in employee and 3 examples in each column for high cardinality columns :\neid : 573284895, 90873519, 552455318\nname : Dorthy Lewis, Jennifer Thomas, Eric Cooper\nsalary : 43001.00, 33546.00, 43723.00\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 \nCREATE TABLE \"Restaurant\" (\n\t\"ResID\" INTEGER, \n\t\"ResName\" VARCHAR(100), \n\t\"Address\" VARCHAR(100), \n\t\"Rating\" INTEGER, \n\tPRIMARY KEY (\"ResID\")\n)\n/*\nColumns in Restaurant and all categories for low cardinality columns :\nResID : 1, 2\nResName : Subway, Honeygrow\nAddress : 3212 St Paul St, Baltimore, MD 21218, 3233 St Paul St, Baltimore, MD 21218\nRating : 4, 3\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 gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\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 \nCREATE TABLE \"Customer_Addresses\" (\n\tcustomer_id INTEGER NOT NULL, \n\taddress_id INTEGER NOT NULL, \n\tdate_from DATETIME NOT NULL, \n\tdate_to DATETIME, \n\tPRIMARY KEY (customer_id, address_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in Customer_Addresses and 3 examples in each column for high cardinality columns :\ndate_from : 2018-01-07 13:31:08, 2017-07-31 20:18:52, 2017-08-27 13:38:37\ndate_to : 2018-03-05 21:19:53, 2018-03-22 17:22:34, 2018-03-17 15:44:10\n*/\n/*\nColumns in Customer_Addresses and all categories for low cardinality columns :\ncustomer_id : 1, 2, 7, 8, 4, 6, 12, 10\naddress_id : 13, 2, 7, 8, 4, 6, 14, 12, 10, 9\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 buildings (\n\tid INTEGER, \n\tname TEXT, \n\t\"City\" TEXT, \n\t\"Height\" INTEGER, \n\t\"Stories\" INTEGER, \n\t\"Status\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in buildings and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\nname : Torre Mitikah, Residencial Vidalta Torre Altaire 2, Reforma 90\nStories : 67, 100, 20\n*/\n/*\nColumns in buildings and all categories for low cardinality columns :\nCity : Monterrey, Mexico City\nHeight : 330, 300, 150, 100, 210, 200, 50, 220, 73\nStatus : on-hold, under construction, proposed\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 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 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 \"Customers\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Customer_Details\" VARCHAR(255) NOT NULL, \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_Details : Miss Felicita Reichel, Selena Gerhold, Mrs. Liza Heller V\n*/\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 \"Business_Rates\" (\n\tbusiness_rates_id INTEGER NOT NULL, \n\tcmi_cross_ref_id INTEGER NOT NULL, \n\tPRIMARY KEY (business_rates_id), \n\tFOREIGN KEY(cmi_cross_ref_id) REFERENCES \"CMI_Cross_References\" (cmi_cross_ref_id)\n)\n/*\nColumns in Business_Rates and all categories for low cardinality columns :\nbusiness_rates_id : 8, 2, 5\ncmi_cross_ref_id : 95, 99, 49\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 flight (\n\tflno NUMERIC(4, 0), \n\torigin TEXT(20), \n\tdestination TEXT(20), \n\tdistance NUMERIC(6, 0), \n\tdeparture_date DATE, \n\tarrival_date DATE, \n\tprice NUMERIC(7, 2), \n\taid NUMERIC(9, 0), \n\tPRIMARY KEY (flno), \n\tFOREIGN KEY(aid) REFERENCES aircraft (aid)\n) \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n" }, { "role": "user", "content": "For each airport name, how many routes start at that airport, ordered from most to least?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.src_apid.\nThe SQL query I'll be generating is:\nSELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC" } ]
[ { "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 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 \"Apartment_Facilities\" (\n\tapt_id INTEGER NOT NULL, \n\tfacility_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (apt_id, facility_code), \n\tFOREIGN KEY(apt_id) REFERENCES \"Apartments\" (apt_id)\n)\n/*\nColumns in Apartment_Facilities and all categories for low cardinality columns :\napt_id : 1, 2, 5, 6, 3, 15, 9\nfacility_code : Gym, Swimming Pool, Boardband, Cable TV\n*/\n \nCREATE TABLE \"Settlements\" (\n\t\"Settlement_ID\" INTEGER NOT NULL, \n\t\"Claim_ID\" INTEGER, \n\t\"Effective_Date\" DATE, \n\t\"Settlement_Amount\" REAL, \n\tPRIMARY KEY (\"Settlement_ID\"), \n\tFOREIGN KEY(\"Claim_ID\") REFERENCES \"Claims\" (\"Claim_ID\"), \n\tUNIQUE (\"Settlement_ID\")\n)\n/*\nColumns in Settlements and all categories for low cardinality columns :\nSettlement_ID : 616, 543, 205, 544, 628, 393, 161, 208, 176, 604\nClaim_ID : 428, 309, 717, 145, 228, 311, 360, 134, 641, 604\nEffective_Date : 2009-11-20, 1978-09-09, 1973-10-27, 1971-06-29, 1995-04-02, 2006-04-19, 2014-12-09, 2001-07-02, 2003-12-28, 1972-03-02\nSettlement_Amount : 8013.95, 8827.06, 9164.1, 2138.96, 2722.67, 1721.17, 1588.45, 9814.39, 3101.3, 6451.65\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 \"Undergoes\" (\n\t\"Patient\" INTEGER NOT NULL, \n\t\"Procedures\" INTEGER NOT NULL, \n\t\"Stay\" INTEGER NOT NULL, \n\t\"DateUndergoes\" DATETIME NOT NULL, \n\t\"Physician\" INTEGER NOT NULL, \n\t\"AssistingNurse\" INTEGER, \n\tPRIMARY KEY (\"Patient\", \"Procedures\", \"Stay\", \"DateUndergoes\"), \n\tCONSTRAINT \"fk_Undergoes_Patient_SSN\" FOREIGN KEY(\"Patient\") REFERENCES \"Patient\" (\"SSN\"), \n\tCONSTRAINT \"fk_Undergoes_Procedures_Code\" FOREIGN KEY(\"Procedures\") REFERENCES \"Procedures\" (\"Code\"), \n\tCONSTRAINT \"fk_Undergoes_Stay_StayID\" FOREIGN KEY(\"Stay\") REFERENCES \"Stay\" (\"StayID\"), \n\tCONSTRAINT \"fk_Undergoes_Physician_EmployeeID\" FOREIGN KEY(\"Physician\") REFERENCES \"Physician\" (\"EmployeeID\"), \n\tCONSTRAINT \"fk_Undergoes_Nurse_EmployeeID\" FOREIGN KEY(\"AssistingNurse\") REFERENCES \"Nurse\" (\"EmployeeID\")\n)\n/*\nColumns in Undergoes and all categories for low cardinality columns :\nPatient : 100000001, 100000004\nProcedures : 1, 2, 5, 7, 4, 6\nStay : 3215, 3217\nDateUndergoes : 2008-05-09 00:00:00, 2008-05-10 00:00:00, 2008-05-13 00:00:00, 2008-05-03 00:00:00, 2008-05-02 00:00:00, 2008-05-07 00:00:00\nPhysician : 7, 6, 3\nAssistingNurse : 102, 101, 105, 103\n*/\n \nCREATE TABLE actor (\n\t\"Actor_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Musical_ID\" INTEGER, \n\t\"Character\" TEXT, \n\t\"Duration\" TEXT, \n\tage INTEGER, \n\tPRIMARY KEY (\"Actor_ID\"), \n\tFOREIGN KEY(\"Musical_ID\") REFERENCES actor (\"Actor_ID\")\n)\n/*\nColumns in actor and all categories for low cardinality columns :\nActor_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Ray Meagher, Lynne McGranger, Ian Smith, Tom Oliver, Kate Ritchie, Ryan Moloney, Alan Fletcher, Stefan Dennis, Jackie Woodburne\nMusical_ID : 1, 2, 4, 6\nCharacter : Harold Bishop, Susan Kennedy, Karl Kennedy, Alf Stewart, Toadfish Rebecchi, Sally Fletcher, Paul Robinson, Lou Carpenter, Irene Roberts\nDuration : 1988—, 1985–1992, 1993, 2004—, 1993—, 1988, 1992—, 1995, 1996—, 1987–1991, 1996–2009, 2011, 1994—, 1988–2008, 2013\nage : 26, 20, 17, 21, 18, 22\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 \"Accounts\" (\n\taccount_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tdate_account_opened DATETIME, \n\taccount_name VARCHAR(50), \n\tother_account_details VARCHAR(255), \n\tPRIMARY KEY (account_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Accounts and 3 examples in each column for high cardinality columns :\naccount_id : 1, 13, 11\ndate_account_opened : 2016-07-30 22:22:24, 2016-04-25 21:49:17, 2017-05-29 16:45:17\naccount_name : 601, 398, 900\n*/\n/*\nColumns in Accounts and all categories for low cardinality columns :\ncustomer_id : 13, 8, 6, 12, 3, 15, 9\nother_account_details : VIP, Regular\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 \"Course_Authors_and_Tutors\" (\n\tauthor_id INTEGER, \n\t\"author_tutor_ATB\" VARCHAR(3), \n\tlogin_name VARCHAR(40), \n\tpassword VARCHAR(40), \n\tpersonal_name VARCHAR(80), \n\tmiddle_name VARCHAR(80), \n\tfamily_name VARCHAR(80), \n\tgender_mf VARCHAR(1), \n\taddress_line_1 VARCHAR(80), \n\tPRIMARY KEY (author_id)\n)\n/*\nColumns in Course_Authors_and_Tutors and 3 examples in each column for high cardinality columns :\nauthor_id : 1, 13, 11\nauthor_tutor_ATB : 388, 782, 159\nlogin_name : heidenreich.ara, qking, fiona77\npassword : 2c196efe8aee23a1b9a7e752fe63029c5879af6f, cdaf6c3483f19e2253659a40a3aab786a3390f78, 120ac8a5744f5b710ecaebbd8dd1633e3e33886e\npersonal_name : Dusty, Cathrine, Shakira\nmiddle_name : Kennith, Ruthie, Joyce\nfamily_name : Treutel, Zboncak, Rowe\naddress_line_1 : 644 Montana Hill Suite 489\nDaijamouth, CA 19587-4254, 139 O'Conner Circles\nVirginieland, KS 23365, 92220 Hellen Skyway Apt. 635\nRennerview, MS 81036\n*/\n/*\nColumns in Course_Authors_and_Tutors and all categories for low cardinality columns :\ngender_mf : 1, 0\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 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 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 railway_manage (\n\t\"Railway_ID\" INTEGER, \n\t\"Manager_ID\" INTEGER, \n\t\"From_Year\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\", \"Manager_ID\"), \n\tFOREIGN KEY(\"Manager_ID\") REFERENCES manager (\"Manager_ID\"), \n\tFOREIGN KEY(\"Railway_ID\") REFERENCES railway (\"Railway_ID\")\n)\n/*\nColumns in railway_manage and all categories for low cardinality columns :\nRailway_ID : 7, 8, 2, 9\nManager_ID : 1, 2, 4, 3\nFrom_Year : 2012, 2010, 2011, 2013\n*/\n" }, { "role": "user", "content": "Find the average elevation of all airports for each country." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: elevation, country.\nThe SQL query I'll be generating is:\nSELECT avg(elevation) , country FROM airports GROUP BY country" } ]
[ { "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 company (\n\t\"Company_ID\" INTEGER, \n\t\"Rank\" INTEGER, \n\t\"Company\" TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Main_Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value\" REAL, \n\tPRIMARY KEY (\"Company_ID\")\n)\n/*\nColumns in company and all categories for low cardinality columns :\nCompany_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nRank : 1, 11, 5, 7, 8, 4, 6, 3, 10, 9\nCompany : ExxonMobil, HSBC, General Electric, PetroChina, Industrial and Commercial Bank of China, Wells Fargo, Berkshire Hathaway, Petrobras, Royal Dutch Shell, BP\nHeadquarters : UK, China, Brazil, USA, Netherlands\nMain_Industry : Conglomerate, Banking, Oil and gas\nSales_billion : 143.7, 310.1, 433.5, 147.3, 470.2, 145.9, 87.6, 82.6, 375.5, 102.0\nProfits_billion : 20.1, 41.1, 30.9, 25.1, 14.2, 25.7, 20.6, 16.2, 15.9, 10.3\nAssets_billion : 1313.9, 319.4, 717.2, 340.5, 331.1, 2039.1, 292.5, 304.7, 392.6, 2550.0\nMarket_Value : 237.4, 213.7, 227.6, 147.4, 164.3, 202.2, 294.7, 180.0, 407.4, 178.7\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 accelerator_compatible_browser (\n\taccelerator_id INTEGER, \n\tbrowser_id INTEGER, \n\tcompatible_since_year INTEGER, \n\tPRIMARY KEY (accelerator_id, browser_id), \n\tFOREIGN KEY(browser_id) REFERENCES browser (id), \n\tFOREIGN KEY(accelerator_id) REFERENCES \"Web_client_accelerator\" (id)\n)\n/*\nColumns in accelerator_compatible_browser and all categories for low cardinality columns :\naccelerator_id : 1, 2, 4, 3, 9\nbrowser_id : 1, 2, 4, 3\ncompatible_since_year : 2009, 2005, 1995, 2008, 2000, 1996, 2010, 2007\n*/\n \nCREATE TABLE \"Customer_Addresses\" (\n\tcustomer_id INTEGER NOT NULL, \n\tpremise_id INTEGER NOT NULL, \n\tdate_address_from DATETIME NOT NULL, \n\taddress_type_code VARCHAR(15) NOT NULL, \n\tdate_address_to DATETIME, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(premise_id) REFERENCES \"Premises\" (premise_id)\n)\n/*\nColumns in Customer_Addresses and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\ndate_address_from : 1975-04-23 20:41:01, 1939-01-15 17:55:39, 1990-12-19 22:02:27\ndate_address_to : 2018-03-08 08:03:51, 2018-03-15 18:34:41, 2018-03-16 11:55:11\n*/\n/*\nColumns in Customer_Addresses and all categories for low cardinality columns :\npremise_id : 1, 2, 5, 8, 4, 6, 12, 3, 14, 10\naddress_type_code : Billing, Shipping\n*/\n \nCREATE TABLE \"Users\" (\n\tuser_id INTEGER, \n\trole_code VARCHAR(15) NOT NULL, \n\tuser_name VARCHAR(40), \n\tuser_login VARCHAR(40), \n\tpassword VARCHAR(40), \n\tPRIMARY KEY (user_id), \n\tFOREIGN KEY(role_code) REFERENCES \"Roles\" (role_code)\n)\n/*\nColumns in Users and 3 examples in each column for high cardinality columns :\nuser_id : 1, 13, 11\nuser_name : glenna.simonis, jacklyn.schmitt, larson.vesta\npassword : 20241478f890508ac47870cfba472e1db04a71ca, 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb, 27cca8f94136f0e8971b5ca555a21ff756871b27\n*/\n/*\nColumns in Users and all categories for low cardinality columns :\nrole_code : PROJ-MGR, DBA\nuser_login : 1, 0\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 screen_mode (\n\t\"Graphics_mode\" REAL, \n\t\"Char_cells\" TEXT, \n\t\"Pixels\" TEXT, \n\t\"Hardware_colours\" REAL, \n\tused_kb REAL, \n\tmap TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"Graphics_mode\")\n)\n/*\nColumns in screen_mode and all categories for low cardinality columns :\nGraphics_mode : 3.0, 1.0, 0.0, 2.0, 6.0, 4.0, 5.0\nChar_cells : 40 × 32, 20 × 32, 80 × 25, 40 × 25, 80 × 32\nPixels : 320 × 200, 640 × 200, 320 × 256, 640 × 256, 160 × 256\nHardware_colours : 8.0, 2.0, 4.0\nused_kb : 8.0, 10.0, 16.0, 20.0\nmap : 4000–7FFF, 3000–7FFF, 5800–7FFF, 6000–7FFF\nType : Text, Graphics\n*/\n \nCREATE TABLE aircraft (\n\t\"Aircraft_ID\" INTEGER NOT NULL, \n\t\"Aircraft\" VARCHAR(50) NOT NULL, \n\t\"Description\" VARCHAR(50) NOT NULL, \n\t\"Max_Gross_Weight\" VARCHAR(50) NOT NULL, \n\t\"Total_disk_area\" VARCHAR(50) NOT NULL, \n\t\"Max_disk_Loading\" VARCHAR(50) NOT NULL, \n\tPRIMARY KEY (\"Aircraft_ID\")\n)\n/*\nColumns in aircraft and all categories for low cardinality columns :\nAircraft_ID : 1, 2, 5, 4, 3\nAircraft : Bell 206B3 JetRanger, Mil Mi-26, CH-53E Super Stallion, Robinson R-22, CH-47D Chinook\nDescription : Light utility helicopter, Heavy-lift helicopter, Turboshaft utility helicopter, Tandem rotor helicopter\nMax_Gross_Weight : 50,000 lb (22,680 kg), 123,500 lb (56,000 kg), 73,500 lb (33,300 kg), 3,200 lb (1,451 kg), 1,370 lb (635 kg)\nTotal_disk_area : 872 ft² (81.1 m²), 5,655 ft² (526 m²), 8,495 ft² (789 m²), 497 ft² (46.2 m²), 4,900 ft² (460 m²)\nMax_disk_Loading : 15 lb/ft² (72 kg/m²), 2.6 lb/ft² (14 kg/m²), 14.5 lb/ft² (71 kg/m²), 8.8 lb/ft² (43 kg/m²), 3.7 lb/ft² (18 kg/m²)\n*/\n \nCREATE TABLE stock (\n\t\"Shop_ID\" INTEGER, \n\t\"Device_ID\" INTEGER, \n\t\"Quantity\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\", \"Device_ID\"), \n\tFOREIGN KEY(\"Device_ID\") REFERENCES device (\"Device_ID\"), \n\tFOREIGN KEY(\"Shop_ID\") REFERENCES shop (\"Shop_ID\")\n)\n/*\nColumns in stock and all categories for low cardinality columns :\nShop_ID : 1, 11, 2, 4, 3, 9\nDevice_ID : 4, 6\nQuantity : 110, 56, 124, 100, 200, 112, 134, 51\n*/\n \nCREATE TABLE \"Timed_Status_of_Things\" (\n\tthing_id INTEGER NOT NULL, \n\t\"Date_and_Date\" DATETIME NOT NULL, \n\t\"Status_of_Thing_Code\" CHAR(15) NOT NULL, \n\tPRIMARY KEY (thing_id, \"Date_and_Date\", \"Status_of_Thing_Code\"), \n\tFOREIGN KEY(thing_id) REFERENCES \"Things\" (thing_id)\n)\n/*\nColumns in Timed_Status_of_Things and 3 examples in each column for high cardinality columns :\nthing_id : 26, 80, 2\nDate_and_Date : 2017-06-19 02:59:21, 2017-08-05 02:10:02, 2016-10-08 08:02:57\n*/\n/*\nColumns in Timed_Status_of_Things and all categories for low cardinality columns :\nStatus_of_Thing_Code : Open, Close, In Progress\n*/\n \nCREATE TABLE \"Has_amenity\" (\n\tdormid INTEGER, \n\tamenid INTEGER, \n\tFOREIGN KEY(amenid) REFERENCES \"Dorm_amenity\" (amenid), \n\tFOREIGN KEY(dormid) REFERENCES \"Dorm\" (dormid)\n)\n/*\nColumns in Has_amenity and 3 examples in each column for high cardinality columns :\namenid : 902, 955, 930\n*/\n/*\nColumns in Has_amenity and all categories for low cardinality columns :\ndormid : 109, 110, 100, 117, 140, 104, 160\n*/\n \nCREATE TABLE \"Bookings\" (\n\t\"Booking_ID\" INTEGER NOT NULL, \n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Workshop_Group_ID\" VARCHAR(100) NOT NULL, \n\t\"Status_Code\" CHAR(15) NOT NULL, \n\t\"Store_ID\" INTEGER NOT NULL, \n\t\"Order_Date\" DATETIME NOT NULL, \n\t\"Planned_Delivery_Date\" DATETIME NOT NULL, \n\t\"Actual_Delivery_Date\" DATETIME NOT NULL, \n\t\"Other_Order_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Booking_ID\"), \n\tFOREIGN KEY(\"Customer_ID\") REFERENCES \"Clients\" (\"Client_ID\"), \n\tFOREIGN KEY(\"Workshop_Group_ID\") REFERENCES \"Drama_Workshop_Groups\" (\"Workshop_Group_ID\"), \n\tUNIQUE (\"Booking_ID\")\n)\n/*\nColumns in Bookings and 3 examples in each column for high cardinality columns :\nBooking_ID : 1, 13, 11\nCustomer_ID : 938, 605, 591\nOrder_Date : 1971-05-11 06:53:01, 1975-11-23 06:28:47, 1975-12-30 14:12:32\nPlanned_Delivery_Date : 2014-06-05 10:19:46, 2013-03-10 18:47:05, 1993-04-17 23:53:01\nActual_Delivery_Date : 1983-02-07 20:27:10, 1971-01-13 13:24:52, 1983-10-09 10:48:48\n*/\n/*\nColumns in Bookings and all categories for low cardinality columns :\nWorkshop_Group_ID : 954, 838, 405, 735, 140, 708, 176, 685, 136\nStatus_Code : stop, good\nStore_ID : 1, 2, 5, 7, 8, 4, 6, 9\nOther_Order_Details : None\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 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 \"Investors\" (\n\tinvestor_id INTEGER, \n\t\"Investor_details\" VARCHAR(255), \n\tPRIMARY KEY (investor_id)\n)\n/*\nColumns in Investors and 3 examples in each column for high cardinality columns :\ninvestor_id : 17, 9, 16\nInvestor_details : d, t, b\n*/\n\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n" }, { "role": "user", "content": "For each country, what is the average elevation of that country's airports?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: elevation, country.\nThe SQL query I'll be generating is:\nSELECT avg(elevation) , country FROM airports GROUP BY country" } ]
[ { "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 (\n\t\"Party_ID\" INTEGER, \n\t\"Party_Theme\" TEXT, \n\t\"Location\" TEXT, \n\t\"First_year\" TEXT, \n\t\"Last_year\" TEXT, \n\t\"Number_of_hosts\" INTEGER, \n\tPRIMARY KEY (\"Party_ID\")\n)\n/*\nColumns in party and all categories for low cardinality columns :\nParty_ID : 1, 2, 5, 7, 8, 4, 6, 3\nParty_Theme : Qlubtempo, In Qontrol, Club Q-BASE, QrimeTime, Teqnology, Houseqlassics, Hardcore Resurrection, Spring\nLocation : Various locations, RAI Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam\nFirst_year : 2004, 2001, 1999, 2000, 2002\nLast_year : 2004, 2001, 2002, 2003, 2010, 2007\nNumber_of_hosts : 5, 7, 23, 4, 6, 18, 31\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 1, 2, 3\nproduct_details : Dove Chocolate, Americano, Latte\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 pilot_record (\n\t\"Record_ID\" INTEGER, \n\t\"Pilot_ID\" INTEGER, \n\t\"Aircraft_ID\" INTEGER, \n\t\"Date\" TEXT, \n\tPRIMARY KEY (\"Pilot_ID\", \"Aircraft_ID\", \"Date\"), \n\tFOREIGN KEY(\"Aircraft_ID\") REFERENCES aircraft (\"Aircraft_ID\"), \n\tFOREIGN KEY(\"Pilot_ID\") REFERENCES pilot (\"Pilot_ID\")\n)\n/*\nColumns in pilot_record and all categories for low cardinality columns :\nRecord_ID : 1, 2, 5, 4, 6, 3\nPilot_ID : 1, 2, 4, 3\nAircraft_ID : 1, 2, 5, 4, 6\nDate : 2006/01/04, 2005/01/04, 2008/01/04, 2004/01/04, 2007/01/04, 2003/01/04\n*/\n \nCREATE TABLE body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Ref_Calendar\" (\n\t\"Calendar_Date\" DATETIME NOT NULL, \n\t\"Day_Number\" INTEGER, \n\tPRIMARY KEY (\"Calendar_Date\")\n)\n/*\nColumns in Ref_Calendar and 3 examples in each column for high cardinality columns :\nCalendar_Date : 2009-08-18 03:29:08, 2012-07-03 09:48:46, 1972-03-31 09:47:22\n*/\n/*\nColumns in Ref_Calendar and all categories for low cardinality columns :\nDay_Number : 1, 2, 5, 7, 8, 3, 9\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 mission (\n\t\"Mission_ID\" INTEGER, \n\t\"Ship_ID\" INTEGER, \n\t\"Code\" TEXT, \n\t\"Launched_Year\" INTEGER, \n\t\"Location\" TEXT, \n\t\"Speed_knots\" INTEGER, \n\t\"Fate\" TEXT, \n\tPRIMARY KEY (\"Mission_ID\"), \n\tFOREIGN KEY(\"Ship_ID\") REFERENCES ship (\"Ship_ID\")\n)\n/*\nColumns in mission and all categories for low cardinality columns :\nMission_ID : 1, 2, 5, 7, 4, 6, 3\nShip_ID : 1, 2, 5, 7, 8, 6, 3\nCode : VMV-3, VMV-5, VMV-6, VMV-4 Former: Sterling, VMV-2, VMV-7, VMV-1\nLaunched_Year : 1932, 1916, 1930, 1931\nLocation : Turku , Finland, Helsinki , Finland, Norway, Germany, Uusikaupunki , Finland\nSpeed_knots : 16, 25, 23\nFate : Retired 1939, Decommissioned 1950, Lost (burned and sunk) 1933, Lost (burned) 1931, Decommissioned 1959, Decommissioned 1960\n*/\n \nCREATE TABLE aircraft (\n\t\"Aircraft_ID\" INTEGER, \n\t\"Order_Year\" INTEGER, \n\t\"Manufacturer\" TEXT, \n\t\"Model\" TEXT, \n\t\"Fleet_Series\" TEXT, \n\t\"Powertrain\" TEXT, \n\t\"Fuel_Propulsion\" TEXT, \n\tPRIMARY KEY (\"Aircraft_ID\")\n)\n/*\nColumns in aircraft and all categories for low cardinality columns :\nAircraft_ID : 1, 2, 5, 7, 4, 6, 3\nOrder_Year : 1992, 2000, 1996, 2002, 1998, 2011, 2010\nManufacturer : NFI, Gillig\nModel : C40LFR, GE40LFR, Phantom (High Floor), Advantage (Low Floor)\nFleet_Series : 310-329 (20), 465-467 (3), 468-473 (6), 444-464 (21), 474-481 (8), 300-309 (10), 482-492 (11)\nPowertrain : Cummins Westport ISL-G Allison WB-400R, Cummins ISC Allison WB-400R, DD S50 Allison WB-400R, Cummins ISL Allison WB-400R, Ford Triton V10 ISE-Thundervolt TB40-HG, DD S50EGR Allison WB-400R\nFuel_Propulsion : Hybrid, Diesel, CNG\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 dept_locations (\n\t\"Dnumber\" INTEGER, \n\t\"Dlocation\" TEXT, \n\tPRIMARY KEY (\"Dnumber\", \"Dlocation\")\n)\n/*\nColumns in dept_locations and all categories for low cardinality columns :\nDnumber : 1, 4, 5\nDlocation : Stafford, Sugarland, Bellaire, Houston\n*/\n \nCREATE TABLE \"Customers_Policies\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Date_Opened\" DATE, \n\t\"Date_Closed\" DATE, \n\tPRIMARY KEY (\"Customer_ID\", \"Policy_ID\"), \n\tFOREIGN KEY(\"Customer_ID\") REFERENCES \"Customers\" (\"Customer_ID\"), \n\tFOREIGN KEY(\"Policy_ID\") REFERENCES \"Available_Policies\" (\"Policy_ID\")\n)\n/*\nColumns in Customers_Policies and 3 examples in each column for high cardinality columns :\nPolicy_ID : 586, 346, 630\nDate_Opened : 2016-06-24, 2016-11-18, 2016-07-07\nDate_Closed : 2018-03-08, 2018-02-20, 2018-03-19\n*/\n/*\nColumns in Customers_Policies and all categories for low cardinality columns :\nCustomer_ID : 562, 582, 892, 826, 682, 214, 996, 256, 641\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 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 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 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 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" }, { "role": "user", "content": "Find the cities which have exactly two airports." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city.\nThe SQL query I'll be generating is:\nSELECT city FROM airports GROUP BY city HAVING count(*) = 2" } ]
[ { "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 grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\n*/\n \nCREATE TABLE \"Properties\" (\n\tproperty_id INTEGER NOT NULL, \n\tproperty_type_code CHAR(15) NOT NULL, \n\tproperty_address VARCHAR(255), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (property_id)\n)\n/*\nColumns in Properties and 3 examples in each column for high cardinality columns :\nproperty_id : 120, 954, 108\nproperty_address : 5983 Fleta Throughway, 54591 Bernard Ridges Suite 864, 7713 Bode Burgs Apt. 113\n*/\n/*\nColumns in Properties and all categories for low cardinality columns :\nproperty_type_code : apartment, house, flat\nother_details : USA\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 body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\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 \"Products\" (\n\t\"Product_ID\" VARCHAR(100) NOT NULL, \n\t\"Product_Name\" VARCHAR(255), \n\t\"Product_Price\" DECIMAL(20, 4), \n\t\"Product_Description\" VARCHAR(255), \n\t\"Other_Product_Service_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Product_ID\"), \n\tUNIQUE (\"Product_ID\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nProduct_ID : 250, 300, 233\nProduct_Price : 634660.0000, 1577.0000, 900.0000\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nProduct_Name : dinning, photo, film\nProduct_Description : None\nOther_Product_Service_Details : None\n*/\n \nCREATE TABLE \"Events\" (\n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Service_ID\" INTEGER NOT NULL, \n\t\"Event_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Event_ID\"), \n\tFOREIGN KEY(\"Service_ID\") REFERENCES \"Services\" (\"Service_ID\")\n)\n/*\nColumns in Events and 3 examples in each column for high cardinality columns :\nEvent_ID : 16, 95, 13\n*/\n/*\nColumns in Events and all categories for low cardinality columns :\nService_ID : 8, 2, 5, 6\nEvent_Details : Fail, Success\n*/\n \nCREATE TABLE \"Customer_Contact_Channels\" (\n\tcustomer_id INTEGER NOT NULL, \n\tchannel_code VARCHAR(15) NOT NULL, \n\tactive_from_date DATETIME NOT NULL, \n\tactive_to_date DATETIME, \n\tcontact_number VARCHAR(50) NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Customer_Contact_Channels and 3 examples in each column for high cardinality columns :\nactive_from_date : 2017-05-25 16:08:45, 2017-06-21 06:41:19, 2018-03-01 10:17:18\nactive_to_date : 2018-03-16 14:00:15, 2018-02-24 00:57:39, 2018-03-20 14:01:12\ncontact_number : 940.035.6435x0225, 846.043.4809x0426, 1-968-863-4947x96956\n*/\n/*\nColumns in Customer_Contact_Channels and all categories for low cardinality columns :\ncustomer_id : 13, 2, 5, 15, 4, 6, 14, 3, 10, 9\nchannel_code : Mobile, Email, Fax, Handheld, Cell\n*/\n \nCREATE TABLE \"Staff\" (\n\t\"Staff_ID\" INTEGER NOT NULL, \n\t\"Staff_Details\" VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (\"Staff_ID\")\n)\n/*\nColumns in Staff and 3 examples in each column for high cardinality columns :\nStaff_ID : 510, 427, 771\nStaff_Details : Gideon, Vernie, Roman\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 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 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 \"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 \"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 \"Features\" (\n\t\"Feature_ID\" INTEGER NOT NULL, \n\t\"Feature_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Feature_ID\")\n)\n/*\nColumns in Features and all categories for low cardinality columns :\nFeature_ID : 955, 543, 681, 528, 523\nFeature_Details : park, shopping, cafe, parking, garden\n*/\n \nCREATE TABLE train (\n\t\"Train_ID\" INTEGER, \n\t\"Train_Num\" TEXT, \n\t\"Name\" TEXT, \n\t\"From\" TEXT, \n\t\"Arrival\" TEXT, \n\t\"Railway_ID\" INTEGER, \n\tPRIMARY KEY (\"Train_ID\"), \n\tFOREIGN KEY(\"Railway_ID\") REFERENCES railway (\"Railway_ID\")\n)\n/*\nColumns in train and all categories for low cardinality columns :\nTrain_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nTrain_Num : 57136, 57135, 16032, 12140, 51195, 12139, 16031, 11401, 16094\nName : Wardha-Ballarshah Pass, Nagpur-Kazipet Pass, Ballarshah-Mumbai Pass, Nandigram Exp, Lucknow-Chennai Exp, Sewagram Exp, Andaman Exp, Kazipet-Nagpur Pass\nFrom : Lucknow, Ballarshah, Nagpur, Kazipet, Mumbai CST, Jammu Tawi, Wardha, Chennai\nArrival : 23:39, 08:54, 23:44, 05:09, 09:48, 13:28, 13:04, 09:08\nRailway_ID : 1, 2, 5, 7, 3, 10, 9\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 : 7089 Mueller Forks, 535 Ariel Brook, 3904 Stroman Passage\ncity : Buckridgehaven, South Eugene, Elviebury\nzip_postcode : 22194, 99903, 14445\nstate_province_county : Louisiana, Kentucky, Ohio\n*/\n/*\nColumns in Addresses and all categories for low cardinality columns :\ncountry : USA\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n" }, { "role": "user", "content": "What are the cities with exactly two airports?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports.\nFrom these tables, I'll be using the following columns: city.\nThe SQL query I'll be generating is:\nSELECT city FROM airports GROUP BY city HAVING count(*) = 2" } ]
[ { "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 book_club (\n\tbook_club_id INTEGER, \n\t\"Year\" INTEGER, \n\t\"Author_or_Editor\" TEXT, \n\t\"Book_Title\" TEXT, \n\t\"Publisher\" TEXT, \n\t\"Category\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (book_club_id)\n)\n/*\nColumns in book_club and 3 examples in each column for high cardinality columns :\nbook_club_id : 1, 11, 2\nAuthor_or_Editor : Dolores Klaich, Antoinette Azolakov, Sandy Bayer\nBook_Title : Lessons In Murder, Somewhere in the Night, Mundaneӳ World\n*/\n/*\nColumns in book_club and all categories for low cardinality columns :\nYear : 1989, 1990\nPublisher : International Polygonics, William Morrow, St. Martin's Press, Crossing Press, Alyson, Naiad Press, Banned Books, Mysterious Press\nCategory : Lesb. M/SF, Gay SF/F, Gay M/SF\nResult : Nom, Won [B ], Won, Won [A ]\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 department (\n\t\"Dname\" TEXT, \n\t\"Dnumber\" INTEGER, \n\t\"Mgr_ssn\" INTEGER, \n\t\"Mgr_start_date\" TEXT, \n\tPRIMARY KEY (\"Dnumber\")\n)\n/*\nColumns in department and all categories for low cardinality columns :\nDname : Headquarters, Administration, Research\nDnumber : 1, 4, 5\nMgr_ssn : 987654321, 333445555, 888665555\nMgr_start_date : 1988-05-22, 1995-01-01, 1981-06-19\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 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 editor (\n\t\"Editor_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Age\" REAL, \n\tPRIMARY KEY (\"Editor_ID\")\n)\n/*\nColumns in editor and all categories for low cardinality columns :\nEditor_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Maria Góralczyk, Władysław Grzywna, Grażyna Wolszczak, Szymon Wydra, Piotr Pręgowski, Kamila Porczyk, Marek Siudym, Anna Powierza, Mariusz Zalejski\nAge : 43.0, 24.0, 25.0, 34.0, 38.0, 54.0, 35.0, 21.0, 20.0\n*/\n \nCREATE TABLE host (\n\t\"Host_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Age\" TEXT, \n\tPRIMARY KEY (\"Host_ID\")\n)\n/*\nColumns in host and all categories for low cardinality columns :\nHost_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Lloyd Daniels, Kornel David, Antonio Davis, Carlos Delfino, DeMar DeRozan, Ed Davis, Austin Daye, Derrick Dial, Justin Dentmon, Hubert Davis\nNationality : United States, Argentina, Hungary\nAge : 26, 45, 37, 40, 30, 60, 47, 43, 31\n*/\n \nCREATE TABLE \"Course\" (\n\t\"CID\" VARCHAR(7), \n\t\"CName\" VARCHAR(40), \n\t\"Credits\" INTEGER, \n\t\"Instructor\" INTEGER, \n\t\"Days\" VARCHAR(5), \n\t\"Hours\" VARCHAR(11), \n\t\"DNO\" INTEGER, \n\tPRIMARY KEY (\"CID\"), \n\tFOREIGN KEY(\"Instructor\") REFERENCES \"Faculty\" (\"FacID\"), \n\tFOREIGN KEY(\"DNO\") REFERENCES \"Department\" (\"DNO\")\n)\n/*\nColumns in Course and 3 examples in each column for high cardinality columns :\nCID : 600.433, 550.413, 050.381\nCName : UNIX SYSTEMS PROGRAMMING, BUSINESS LAW II, HIGH PERFORMANCE GRAPHICS AND MODELING\nInstructor : 6112, 7134, 8918\nDays : Tu, TTh, M\nHours : 4-5:15, 9, 1-4\n*/\n/*\nColumns in Course and all categories for low cardinality columns :\nCredits : 1, 2, 4, 3\nDNO : 50, 520, 550, 600\n*/\n \nCREATE TABLE \"match\" (\n\t\"Match_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Score\" TEXT, \n\t\"Result\" TEXT, \n\t\"Competition\" TEXT, \n\tPRIMARY KEY (\"Match_ID\")\n)\n/*\nColumns in match and all categories for low cardinality columns :\nMatch_ID : 1, 2, 5, 4, 6, 3\nDate : 23 July 1992, 18 February 1992, 19 July 1992, 23 July 2000, 4 April 1993\nVenue : Estadio Rigoberto López , Managua , Nicaragua, Estadio Cuscatlán , San Salvador , El Salvador\nScore : 3-0, 2–1, 1-0, 1–0\nResult : 5-1, 7–1, 5-0, 2–1, 2-0\nCompetition : 1994 FIFA World Cup qualification, Friendly match, 2002 FIFA World Cup qualification\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE employees (\n\tid INTEGER, \n\tlast_name VARCHAR(20) NOT NULL, \n\tfirst_name VARCHAR(20) NOT NULL, \n\ttitle VARCHAR(30), \n\treports_to INTEGER, \n\tbirth_date TIMESTAMP, \n\thire_date TIMESTAMP, \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), \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(reports_to) REFERENCES employees (id)\n)\n/*\nColumns in employees and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 3\nlast_name : Callahan, Mitchell, Adams, Park, Edwards, Peacock, Johnson, King\nfirst_name : Jane, Michael, Steve, Laura, Margaret, Andrew, Robert, Nancy\ntitle : IT Staff, Sales Manager, IT Manager, Sales Support Agent, General Manager\nreports_to : 1, None, 2, 6\nbirth_date : 1973-07-01 00:00:00, 1962-02-18 00:00:00, 1968-01-09 00:00:00, 1947-09-19 00:00:00, 1973-08-29 00:00:00, 1965-03-03 00:00:00, 1970-05-29 00:00:00, 1958-12-08 00:00:00\nhire_date : 2002-04-01 00:00:00, 2003-10-17 00:00:00, 2002-05-01 00:00:00, 2004-01-02 00:00:00, 2003-05-03 00:00:00, 2002-08-14 00:00:00, 2004-03-04 00:00:00\naddress : 11120 Jasper Ave NW, 1111 6 Ave SW, 683 10 Street SW, 7727B 41 Ave, 590 Columbia Boulevard West, 923 7 ST NW, 825 8 Ave SW, 5827 Bowness Road NW\ncity : Edmonton, Calgary, Lethbridge\nstate : AB\ncountry : Canada\npostal_code : T1K 5N8, T3B 0C5, T5K 2N1, T2P 5G3, T2P 5M5, T3B 1Y7, T1H 1Y8, T2P 2T3\nphone : +1 (403) 262-3443, 1 (780) 836-9987, +1 (403) 246-9887, +1 (780) 428-9482, +1 (403) 456-9986, +1 (403) 467-3351, +1 (403) 263-4423\nfax : +1 (403) 467-8772, +1 (403) 262-3322, +1 (403) 456-8485, +1 (403) 246-9899, +1 (403) 262-6712, +1 (403) 263-4289, +1 (780) 428-3457, 1 (780) 836-9543\nemail : robert@chinookcorp.com, jane@chinookcorp.com, margaret@chinookcorp.com, steve@chinookcorp.com, michael@chinookcorp.com, andrew@chinookcorp.com, nancy@chinookcorp.com, laura@chinookcorp.com\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 \"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 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 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" }, { "role": "user", "content": "For each country and airline name, how many routes are there?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines, routes.\nFrom these tables, I'll be using the following columns: airlines.country, airlines.name, airlines.alid, routes.alid.\nThe SQL query I'll be generating is:\nSELECT T1.country , T1.name , count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.country , T1.name" } ]
[ { "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 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 \"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 school (\n\t\"School_ID\" INTEGER, \n\t\"Grade\" TEXT, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 7, 4, 6, 3\nGrade : Freshman–Sophomore year, 1st-3rd grade, Kindergarten, Junior–Senior year, College, 5th-12th grade, 4th grade\nSchool : Occidental College, Noelani Elementary School, Harvard Law School, Columbia University, Punahou School, St. Francis Assisi, State Elementary School Menteng 01\nLocation : Cambridge, Massachusetts, Honolulu, Hawaii, Jakarta, Indonesia, Los Angeles, California, New York City\nType : Public, Private Catholic, Private\n*/\n \nCREATE TABLE entrepreneur (\n\t\"Entrepreneur_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Company\" TEXT, \n\t\"Money_Requested\" REAL, \n\t\"Investor\" TEXT, \n\tPRIMARY KEY (\"Entrepreneur_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in entrepreneur and all categories for low cardinality columns :\nEntrepreneur_ID : 1, 2, 5, 4, 6, 3\nPeople_ID : 1, 2, 5, 8, 6, 3\nCompany : Mycorrhizal Systems, Le Beanock, Umbrolly, IV Cam, Elizabeth Galton Ltd, Grails Ltd\nMoney_Requested : 150000.0, 110000.0, 120000.0, 75000.0, 50000.0, 54000.0\nInvestor : Duncan Bannatyne, Doug Richard, Peter Jones, Rachel Elnaugh, Simon Woodroffe\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 body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\n*/\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 \"Institution\" (\n\t\"Institution_id\" TEXT, \n\t\"Institution\" TEXT, \n\t\"Location\" TEXT, \n\t\"Founded\" REAL, \n\t\"Type\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"Team\" TEXT, \n\t\"Primary_Conference\" TEXT, \n\tbuilding_id TEXT, \n\tPRIMARY KEY (\"Institution_id\"), \n\tFOREIGN KEY(building_id) REFERENCES building (building_id)\n)\n/*\nColumns in Institution and 3 examples in each column for high cardinality columns :\nInstitution_id : 1, 2, 5\nInstitution : Ave Maria University, Lindenwood University–Belleville, Point University\nLocation : Mayville, North Dakota, Jacksonville, Florida, Babson Park, Florida\nEnrollment : 967, 616, 3102\nTeam : Gyrenes, Comets, Warriors\n*/\n/*\nColumns in Institution and all categories for low cardinality columns :\nFounded : 1937.0, 1881.0, 1927.0, 2003.0, 1883.0, 1866.0, 1998.0, 1884.0, 1889.0, 1890.0\nType : Public, Tribal, Private\nPrimary_Conference : MCAC, CalPac, Gulf Coast (GCAC), AAC, none, The Sun\nbuilding_id : 1, 2, 5, 7, 4, 3, 0\n*/\n \nCREATE TABLE roller_coaster (\n\t\"Roller_Coaster_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Park\" TEXT, \n\t\"Country_ID\" INTEGER, \n\t\"Length\" REAL, \n\t\"Height\" REAL, \n\t\"Speed\" TEXT, \n\t\"Opened\" TEXT, \n\t\"Status\" TEXT, \n\tPRIMARY KEY (\"Roller_Coaster_ID\"), \n\tFOREIGN KEY(\"Country_ID\") REFERENCES country (\"Country_ID\")\n)\n/*\nColumns in roller_coaster and all categories for low cardinality columns :\nRoller_Coaster_ID : 1, 2, 5, 4, 6, 3\nName : The Voyage, Twister, Boardwalk Bullet, Hades 360, Dauling Dragon, Ravine Flyer II\nPark : Waldameer, Happy Valley, Mt. Olympus, Gröna Lund, Kemah Boardwalk, Holiday World\nCountry_ID : 1, 2, 3\nLength : 6442.0, 4726.0, 3236.0, 1574.0, 2900.0, 3914.0\nHeight : 96.0, 105.0, 136.0, 50.0, 120.0, 163.0\nSpeed : 67, 55, 37.9, 70, 57, 51\nOpened : May 14, 2005, 2012, August 31, 2007, 2011, May 6, 2006, May 17, 2008\nStatus : Operating\n*/\n \nCREATE TABLE \"Player\" (\n\tid INTEGER, \n\tplayer_api_id INTEGER, \n\tplayer_name TEXT, \n\tplayer_fifa_api_id INTEGER, \n\tbirthday TEXT, \n\theight INTEGER, \n\tweight INTEGER, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Player and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\nplayer_api_id : 148827, 38423, 176301\nplayer_name : Adam Ounas, Abdelmalek Cherrad, Adrian\nplayer_fifa_api_id : 197081, 211185, 184410\nbirthday : 1988-08-25 00:00:00, 1986-12-02 00:00:00, 1978-12-22 00:00:00\nheight : 172.72, 175.26, 187.96\nweight : 185, 187, 163\n*/\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 \"Undergoes\" (\n\t\"Patient\" INTEGER NOT NULL, \n\t\"Procedures\" INTEGER NOT NULL, \n\t\"Stay\" INTEGER NOT NULL, \n\t\"DateUndergoes\" DATETIME NOT NULL, \n\t\"Physician\" INTEGER NOT NULL, \n\t\"AssistingNurse\" INTEGER, \n\tPRIMARY KEY (\"Patient\", \"Procedures\", \"Stay\", \"DateUndergoes\"), \n\tCONSTRAINT \"fk_Undergoes_Patient_SSN\" FOREIGN KEY(\"Patient\") REFERENCES \"Patient\" (\"SSN\"), \n\tCONSTRAINT \"fk_Undergoes_Procedures_Code\" FOREIGN KEY(\"Procedures\") REFERENCES \"Procedures\" (\"Code\"), \n\tCONSTRAINT \"fk_Undergoes_Stay_StayID\" FOREIGN KEY(\"Stay\") REFERENCES \"Stay\" (\"StayID\"), \n\tCONSTRAINT \"fk_Undergoes_Physician_EmployeeID\" FOREIGN KEY(\"Physician\") REFERENCES \"Physician\" (\"EmployeeID\"), \n\tCONSTRAINT \"fk_Undergoes_Nurse_EmployeeID\" FOREIGN KEY(\"AssistingNurse\") REFERENCES \"Nurse\" (\"EmployeeID\")\n)\n/*\nColumns in Undergoes and all categories for low cardinality columns :\nPatient : 100000001, 100000004\nProcedures : 1, 2, 5, 7, 4, 6\nStay : 3215, 3217\nDateUndergoes : 2008-05-09 00:00:00, 2008-05-10 00:00:00, 2008-05-13 00:00:00, 2008-05-03 00:00:00, 2008-05-02 00:00:00, 2008-05-07 00:00:00\nPhysician : 7, 6, 3\nAssistingNurse : 102, 101, 105, 103\n*/\n \nCREATE TABLE member (\n\t\"Member_ID\" TEXT, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Role\" TEXT, \n\tPRIMARY KEY (\"Member_ID\")\n)\n/*\nColumns in member and 3 examples in each column for high cardinality columns :\nMember_ID : 1, 11, 2\n*/\n/*\nColumns in member and all categories for low cardinality columns :\nName : Andrew Moten, Juan Espil, Luis González, Corey Allen, John Eubanks, Charlie Burke, Joseph Bunn, Héctor Campana, Joshua Pittman, Wilfredo Ruiz\nNationality : United States, Uruguay, Argentina\nRole : Cello, Viola, Bass, Prime Violin, Violin\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 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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n" }, { "role": "user", "content": "What is the total number of routes for each country and airline in that country?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines, routes.\nFrom these tables, I'll be using the following columns: airlines.country, airlines.name, airlines.alid, routes.alid.\nThe SQL query I'll be generating is:\nSELECT T1.country , T1.name , count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.country , T1.name" } ]
[ { "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 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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"Authorship\" (\n\t\"authID\" INTEGER, \n\t\"instID\" INTEGER, \n\t\"paperID\" INTEGER, \n\t\"authOrder\" INTEGER, \n\tPRIMARY KEY (\"authID\", \"instID\", \"paperID\"), \n\tFOREIGN KEY(\"authID\") REFERENCES \"Authors\" (\"authID\"), \n\tFOREIGN KEY(\"instID\") REFERENCES \"Inst\" (\"instID\"), \n\tFOREIGN KEY(\"paperID\") REFERENCES \"Papers\" (\"paperID\")\n)\n/*\nColumns in Authorship and 3 examples in each column for high cardinality columns :\nauthID : 53, 56, 57\n*/\n/*\nColumns in Authorship and all categories for low cardinality columns :\ninstID : 1060, 1010, 1000, 1040, 1050, 1030, 1020, 1070\npaperID : 201, 204, 205, 200, 206, 203, 202\nauthOrder : 1, 2, 3\n*/\n \nCREATE TABLE furniture_manufacte (\n\t\"Manufacturer_ID\" INTEGER, \n\t\"Furniture_ID\" INTEGER, \n\t\"Price_in_Dollar\" REAL, \n\tPRIMARY KEY (\"Manufacturer_ID\", \"Furniture_ID\"), \n\tFOREIGN KEY(\"Furniture_ID\") REFERENCES furniture (\"Furniture_ID\"), \n\tFOREIGN KEY(\"Manufacturer_ID\") REFERENCES manufacturer (\"Manufacturer_ID\")\n)\n/*\nColumns in furniture_manufacte and all categories for low cardinality columns :\nManufacturer_ID : 1, 7, 4, 5\nFurniture_ID : 1, 2, 7, 4, 3\nPrice_in_Dollar : 239.0, 1234.0, 443.0, 2124.0, 450.0\n*/\n \nCREATE TABLE \"Problem_Category_Codes\" (\n\tproblem_category_code VARCHAR(20), \n\tproblem_category_description VARCHAR(80), \n\tPRIMARY KEY (problem_category_code)\n)\n/*\nColumns in Problem_Category_Codes and all categories for low cardinality columns :\nproblem_category_code : Datatabase, Middleware, GUI\nproblem_category_description : User Interface., Infrastructrure and Architecture, Database design or contents.\n*/\n \nCREATE TABLE \"Products\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Price\" DECIMAL NOT NULL, \n\t\"Manufacturer\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Manufacturer\") REFERENCES \"Manufacturers\" (\"Code\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nCode : 1, 11, 2\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nName : Printer, Floppy disk, Memory, Monitor, Toner cartridge, CD drive, DVD burner, Hard drive, ZIP drive, DVD drive\nPrice : 150.0000000000, 120.0000000000, 90.0000000000, 5.0000000000, 270.0000000000, 180.0000000000, 66.0000000000, 240.0000000000\nManufacturer : 1, 2, 5, 4, 6, 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 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 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 \"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 \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduct_category_code VARCHAR(20) NOT NULL, \n\tdate_product_first_available DATETIME, \n\tdate_product_discontinued DATETIME, \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tproduct_price DECIMAL(19, 4), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\nparent_product_id : 8, 4, 9, 3\nproduct_category_code : Food, Book, Hardware\ndate_product_first_available : 1988-09-29 17:54:50, 1998-06-20 15:04:11, 1994-12-18 15:13:19, 1974-06-25 12:26:47\ndate_product_discontinued : 1987-12-20 13:46:16, 1997-07-02 18:26:16, 1980-06-26 10:40:19, 1991-08-20 05:22:31\nproduct_name : Chocolate, The Great Gatsby, Mouse, Keyboard\nproduct_description : Designed for games, Handmade chocolate, American novel, Blue tooth mouse\nproduct_price : 23.3500, 2.8800, 109.9900, 35.0000\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 race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\n*/\n \nCREATE TABLE \"PersonFriend\" (\n\tname VARCHAR(20), \n\tfriend VARCHAR(20), \n\tyear INTEGER, \n\tFOREIGN KEY(name) REFERENCES \"Person\" (name), \n\tFOREIGN KEY(friend) REFERENCES \"Person\" (name)\n)\n/*\nColumns in PersonFriend and all categories for low cardinality columns :\nname : Alice, Zach, Bob\nfriend : Alice, Dan, Zach, Bob\nyear : 10, 5, 6, 12\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 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 \"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 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 \"Staff\" (\n\t\"Staff_ID\" INTEGER NOT NULL, \n\t\"Staff_Details\" VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (\"Staff_ID\")\n)\n/*\nColumns in Staff and 3 examples in each column for high cardinality columns :\nStaff_ID : 510, 427, 771\nStaff_Details : Gideon, Vernie, Roman\n*/\n\n" }, { "role": "user", "content": "Find the number of routes with destination airports in Italy." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports.\nFrom these tables, I'll be using the following columns: routes.dst_apid, airports.apid, airports.country.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy'" } ]
[ { "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 buildings (\n\tid INTEGER, \n\tname TEXT, \n\t\"City\" TEXT, \n\t\"Height\" INTEGER, \n\t\"Stories\" INTEGER, \n\t\"Status\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in buildings and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\nname : Torre Mitikah, Residencial Vidalta Torre Altaire 2, Reforma 90\nStories : 67, 100, 20\n*/\n/*\nColumns in buildings and all categories for low cardinality columns :\nCity : Monterrey, Mexico City\nHeight : 330, 300, 150, 100, 210, 200, 50, 220, 73\nStatus : on-hold, under construction, proposed\n*/\n \nCREATE TABLE film (\n\t\"Film_ID\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Studio\" TEXT, \n\t\"Director\" TEXT, \n\t\"Gross_in_dollar\" INTEGER, \n\tPRIMARY KEY (\"Film_ID\")\n)\n/*\nColumns in film and 3 examples in each column for high cardinality columns :\nFilm_ID : 1, 13, 11\nTitle : Annie, Rocky III, Tootsie\nDirector : Richard Attenborough, Nicholas Meyer, Ted Kotcheff\nGross_in_dollar : 53977250, 76606280, 125049125\n*/\n/*\nColumns in film and all categories for low cardinality columns :\nStudio : MGM, United Artists, Universal, 20th Century Fox, Columbia, Paramount, Columbia / Rastar, Paramount / Lorimar, Orion / Carolco, Universal / RKO\n*/\n \nCREATE TABLE medicine (\n\tid INTEGER, \n\tname TEXT, \n\t\"Trade_Name\" TEXT, \n\t\"FDA_approved\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in medicine and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Quetiapine, Carpipramine, Asenapine\nTrade_Name : Buronil, Fanapt, Nipolept\n*/\n/*\nColumns in medicine and all categories for low cardinality columns :\nFDA_approved : Yes, No\n*/\n \nCREATE TABLE volume (\n\t\"Volume_ID\" INTEGER, \n\t\"Volume_Issue\" TEXT, \n\t\"Issue_Date\" TEXT, \n\t\"Weeks_on_Top\" REAL, \n\t\"Song\" TEXT, \n\t\"Artist_ID\" INTEGER, \n\tPRIMARY KEY (\"Volume_ID\"), \n\tFOREIGN KEY(\"Artist_ID\") REFERENCES artist (\"Artist_ID\")\n)\n/*\nColumns in volume and all categories for low cardinality columns :\nVolume_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nVolume_Issue : 46:5, 46:16, 46:14-15, 45:15, 45:21-22, 45:16, 46:6-8, 45:14 §, 46:10, 46:9\nIssue_Date : 16 May - 30 May, 6 June, 27 December 1986 - 10 January, 28 February - 7 March, 13 June, 24 January, 9 May, 17 January, 11 July - 18 July, 25 July\nWeeks_on_Top : 3.0, 1.0, 2.0\nSong : Head to Toe , Always , With or Without You , Looking for a New Love, La Isla Bonita , The Way, Everybody Have Fun Tonight , Touch Me (I Want Your Body) , (I Just) Died in Your Arms , Walk Like an Egyptian \nArtist_ID : 1, 2, 5, 4, 6\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 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 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 \"Album\" (\n\t\"AlbumId\" INTEGER NOT NULL, \n\t\"Title\" VARCHAR(160) NOT NULL, \n\t\"ArtistId\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"AlbumId\"), \n\tFOREIGN KEY(\"ArtistId\") REFERENCES \"Artist\" (\"ArtistId\")\n)\n/*\nColumns in Album and 3 examples in each column for high cardinality columns :\nAlbumId : 87, 56, 65\nTitle : The Number of The Beast, One By One, Dance Of Death\nArtistId : 87, 56, 95\n*/\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 technician (\n\ttechnician_id REAL, \n\t\"Name\" TEXT, \n\t\"Team\" TEXT, \n\t\"Starting_Year\" REAL, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (technician_id)\n)\n/*\nColumns in technician and all categories for low cardinality columns :\ntechnician_id : 3.0, 8.0, 10.0, 1.0, 7.0, 2.0, 6.0, 9.0, 4.0, 5.0\nName : Mark Sewell, John Brown, Mickey Cochrane, Joe Sewell, Tony Sewell, Joe Cochrane, Eddie Collins, Charlie Hollocher, Lou Boudreau\nTeam : CHC, NYY, CLE, PHA, CWS\nStarting_Year : 2013.0, 2016.0, 2003.0, 2006.0, 2005.0, 2002.0, 2009.0, 2012.0\nAge : 38, 37, 45, 46, 28, 36, 32, 47, 43, 35\n*/\n \nCREATE TABLE gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE degrees (\n\t\"Year\" INTEGER, \n\t\"Campus\" INTEGER, \n\t\"Degrees\" INTEGER, \n\tPRIMARY KEY (\"Year\", \"Campus\"), \n\tFOREIGN KEY(\"Campus\") REFERENCES \"Campuses\" (\"Id\")\n)\n/*\nColumns in degrees and 3 examples in each column for high cardinality columns :\nYear : 2004, 1992, 1993\nCampus : 1, 13, 11\nDegrees : 2719, 4232, 2735\n*/\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 exhibition_record (\n\t\"Exhibition_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Exhibition_ID\", \"Date\"), \n\tFOREIGN KEY(\"Exhibition_ID\") REFERENCES exhibition (\"Exhibition_ID\")\n)\n/*\nColumns in exhibition_record and 3 examples in each column for high cardinality columns :\nDate : February 25, February 19, December 2\nAttendance : 1313, 24808, 1233\n*/\n/*\nColumns in exhibition_record and all categories for low cardinality columns :\nExhibition_ID : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"match\" (\n\t\"Match_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Score\" TEXT, \n\t\"Result\" TEXT, \n\t\"Competition\" TEXT, \n\tPRIMARY KEY (\"Match_ID\")\n)\n/*\nColumns in match and all categories for low cardinality columns :\nMatch_ID : 1, 2, 5, 4, 6, 3\nDate : 23 July 1992, 18 February 1992, 19 July 1992, 23 July 2000, 4 April 1993\nVenue : Estadio Rigoberto López , Managua , Nicaragua, Estadio Cuscatlán , San Salvador , El Salvador\nScore : 3-0, 2–1, 1-0, 1–0\nResult : 5-1, 7–1, 5-0, 2–1, 2-0\nCompetition : 1994 FIFA World Cup qualification, Friendly match, 2002 FIFA World Cup qualification\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 \"Lots\" (\n\tlot_id INTEGER, \n\tinvestor_id INTEGER NOT NULL, \n\tlot_details VARCHAR(255), \n\tPRIMARY KEY (lot_id), \n\tFOREIGN KEY(investor_id) REFERENCES \"Investors\" (investor_id)\n)\n/*\nColumns in Lots and 3 examples in each column for high cardinality columns :\nlot_id : 1, 13, 11\n*/\n/*\nColumns in Lots and all categories for low cardinality columns :\ninvestor_id : 1, 16, 13, 20, 7, 6, 19, 10, 9\nlot_details : d, m, q, s, r, h, x, z\n*/\n" }, { "role": "user", "content": "What is the number of routes whose destinations are Italian airports?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports.\nFrom these tables, I'll be using the following columns: routes.dst_apid, airports.apid, airports.country.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy'" } ]
[ { "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 workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\n*/\n \nCREATE TABLE \"Parking_Fines\" (\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 Parking_Fines and all categories for low cardinality columns :\ncouncil_tax_id : 10, 9\ncmi_cross_ref_id : 4, 81\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ncustomer_id : 1, 11, 10\ndate_order_placed : 2017-03-08 05:42:10, 2015-05-17 03:05:32, 2013-10-25 17:40:25\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\norder_details : None\n*/\n \nCREATE TABLE \"Sales\" (\n\tsales_transaction_id INTEGER, \n\tsales_details VARCHAR(255), \n\tPRIMARY KEY (sales_transaction_id), \n\tFOREIGN KEY(sales_transaction_id) REFERENCES \"Transactions\" (transaction_id)\n)\n/*\nColumns in Sales and 3 examples in each column for high cardinality columns :\nsales_transaction_id : 1, 13, 11\n*/\n/*\nColumns in Sales and all categories for low cardinality columns :\nsales_details : t, f, s, e, y, n, x, p, o, a\n*/\n \nCREATE TABLE \"Courses\" (\n\tcourse_id INTEGER, \n\tauthor_id INTEGER NOT NULL, \n\tsubject_id INTEGER NOT NULL, \n\tcourse_name VARCHAR(120), \n\tcourse_description VARCHAR(255), \n\tPRIMARY KEY (course_id), \n\tFOREIGN KEY(subject_id) REFERENCES \"Subjects\" (subject_id), \n\tFOREIGN KEY(author_id) REFERENCES \"Course_Authors_and_Tutors\" (author_id)\n)\n/*\nColumns in Courses and 3 examples in each column for high cardinality columns :\ncourse_id : 1, 13, 11\ncourse_name : modern Arts, AI, Writing in French\ncourse_description : modern Arts, AI, Writing in French\n*/\n/*\nColumns in Courses and all categories for low cardinality columns :\nauthor_id : 13, 11, 5, 8, 4, 6, 14, 12, 15, 9\nsubject_id : 1, 2, 3\n*/\n \nCREATE TABLE \"Has_Allergy\" (\n\t\"StuID\" INTEGER, \n\t\"Allergy\" VARCHAR(20), \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"Allergy\") REFERENCES \"Allergy_Type\" (\"Allergy\")\n)\n/*\nColumns in Has_Allergy and 3 examples in each column for high cardinality columns :\nStuID : 1003, 1017, 1002\nAllergy : Soy, Milk, Eggs\n*/\n\n \nCREATE TABLE countries (\n\t\"COUNTRY_ID\" VARCHAR(2) NOT NULL, \n\t\"COUNTRY_NAME\" VARCHAR(40) DEFAULT NULL, \n\t\"REGION_ID\" DECIMAL(10, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"COUNTRY_ID\"), \n\tFOREIGN KEY(\"REGION_ID\") REFERENCES regions (\"REGION_ID\")\n)\n/*\nColumns in countries and 3 examples in each column for high cardinality columns :\nCOUNTRY_ID : AR, JP, DE\nCOUNTRY_NAME : Israel, Australia, India\n*/\n/*\nColumns in countries and all categories for low cardinality columns :\nREGION_ID : 1, 2, 4, 3\n*/\n \nCREATE TABLE \"Invoice_Line_Items\" (\n\torder_item_id INTEGER NOT NULL, \n\tinvoice_number INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tproduct_title VARCHAR(80), \n\tproduct_quantity VARCHAR(50), \n\tproduct_price DECIMAL(19, 4), \n\tderived_product_cost DECIMAL(19, 4), \n\tderived_vat_payable DECIMAL(19, 4), \n\tderived_total_cost DECIMAL(19, 4), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(invoice_number) REFERENCES \"Invoices\" (invoice_number), \n\tFOREIGN KEY(order_item_id) REFERENCES \"Order_Items\" (order_item_id)\n)\n/*\nColumns in Invoice_Line_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 11, 10, 5\nproduct_price : 556.3600, 727.4100, 559.9500\nderived_product_cost : 73.1400, 28.1800, 249.1900\nderived_total_cost : 82.7700, 71.2200, 78.2600\n*/\n/*\nColumns in Invoice_Line_Items and all categories for low cardinality columns :\ninvoice_number : 1, 11, 5, 15, 7, 14, 12, 10, 9\nproduct_id : 1, 11, 5, 15, 8, 6, 14, 3, 10, 9\nproduct_title : prod_name\nproduct_quantity : 1, 2, 5, 7, 8, 4, 6, 3, 9\nderived_vat_payable : None\n*/\n \nCREATE TABLE station (\n\tid INTEGER, \n\tnetwork_name TEXT, \n\tservices TEXT, \n\tlocal_authority TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in station and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\nnetwork_name : Chalfont & Latimer, Chorleywood, Brentwood\n*/\n/*\nColumns in station and all categories for low cardinality columns :\nservices : Greater Anglia, Metropolitan line and Chiltern Railways, Metropolitan line, c2c, London Overground and London Midland, London Overground\nlocal_authority : Three Rivers, Brentwood, Broxbourne, Thurrock, Watford, Chiltern\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE furniture_manufacte (\n\t\"Manufacturer_ID\" INTEGER, \n\t\"Furniture_ID\" INTEGER, \n\t\"Price_in_Dollar\" REAL, \n\tPRIMARY KEY (\"Manufacturer_ID\", \"Furniture_ID\"), \n\tFOREIGN KEY(\"Furniture_ID\") REFERENCES furniture (\"Furniture_ID\"), \n\tFOREIGN KEY(\"Manufacturer_ID\") REFERENCES manufacturer (\"Manufacturer_ID\")\n)\n/*\nColumns in furniture_manufacte and all categories for low cardinality columns :\nManufacturer_ID : 1, 7, 4, 5\nFurniture_ID : 1, 2, 7, 4, 3\nPrice_in_Dollar : 239.0, 1234.0, 443.0, 2124.0, 450.0\n*/\n \nCREATE TABLE \"Ref_Product_Categories\" (\n\tproduct_category_code VARCHAR(15), \n\tproduct_category_description VARCHAR(80), \n\tunit_of_measure VARCHAR(20), \n\tPRIMARY KEY (product_category_code)\n)\n/*\nColumns in Ref_Product_Categories and all categories for low cardinality columns :\nproduct_category_code : Spices, Seeds, Herbs\nproduct_category_description : Spices, Seeds, Herbs\nunit_of_measure : Weight - pound,kilo., Handful \n*/\n \nCREATE TABLE editor (\n\t\"Editor_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Age\" REAL, \n\tPRIMARY KEY (\"Editor_ID\")\n)\n/*\nColumns in editor and all categories for low cardinality columns :\nEditor_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Maria Góralczyk, Władysław Grzywna, Grażyna Wolszczak, Szymon Wydra, Piotr Pręgowski, Kamila Porczyk, Marek Siudym, Anna Powierza, Mariusz Zalejski\nAge : 43.0, 24.0, 25.0, 34.0, 38.0, 54.0, 35.0, 21.0, 20.0\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 \"Product_Characteristics\" (\n\tproduct_id INTEGER NOT NULL, \n\tcharacteristic_id INTEGER NOT NULL, \n\tproduct_characteristic_value VARCHAR(50), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(characteristic_id) REFERENCES \"Characteristics\" (characteristic_id)\n)\n/*\nColumns in Product_Characteristics and all categories for low cardinality columns :\nproduct_id : 1, 13, 11, 5, 7, 8, 6, 12, 14\ncharacteristic_id : 13, 10, 11, 2, 4, 6, 12, 3, 15\nproduct_characteristic_value : high, low, medium\n*/\n \nCREATE TABLE \"Participates_in\" (\n\tstuid INTEGER, \n\tactid INTEGER, \n\tFOREIGN KEY(stuid) REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(actid) REFERENCES \"Activity\" (actid)\n)\n/*\nColumns in Participates_in and 3 examples in each column for high cardinality columns :\nstuid : 1003, 1017, 1002\nactid : 771, 782, 770\n*/\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 \"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 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 performance (\n\t\"Performance_ID\" REAL, \n\t\"Date\" TEXT, \n\t\"Host\" TEXT, \n\t\"Location\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Performance_ID\")\n)\n/*\nColumns in performance and all categories for low cardinality columns :\nPerformance_ID : 3.0, 1.0, 2.0, 6.0, 4.0, 5.0\nDate : February 7, February 4, February 2, February 5, February 10, February 11\nHost : Ottawa Senators, New York Rangers, Pittsburgh Penguins, Atlanta Thrashers, Montreal Canadiens, Boston Bruins\nLocation : Madison Square Garden, Scotiabank Place, Verizon Center, TD Garden, Bell Centre\nAttendance : 2173, 1878, 1877, 1820, 1982, 165\n*/\n \nCREATE TABLE user_profiles (\n\tuid INTEGER NOT NULL, \n\tname VARCHAR(255) DEFAULT NULL, \n\temail VARCHAR(255) DEFAULT NULL, \n\tpartitionid INTEGER DEFAULT NULL, \n\tfollowers INTEGER DEFAULT NULL, \n\tPRIMARY KEY (uid)\n)\n/*\nColumns in user_profiles and all categories for low cardinality columns :\nuid : 1, 2, 5, 7, 4, 6, 3\nname : Natalie Portman, Mary, Black Widow\n, Tyler Swift, Celine Dion, Iron Man, Susan\nemail : susan@gmail.com\n, ts@superstar.com\n, cd@superstar.com, np@superstar.com, ts@richest.com, bw@superhero.com, Mary@yale.edu\npartitionid : 1, 2, 5, 23, 10\nfollowers : 23927492, 100, 94375428, 35425845, 890, 99999998, 6662425\n*/\n" }, { "role": "user", "content": "Return the number of routes with destination airport in Italy operated by the airline with name 'American Airlines'." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports, airlines.\nFrom these tables, I'll be using the following columns: routes.dst_apid, airports.apid, routes.alid, airlines.alid, airports.country, airlines.name.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid JOIN airlines AS T3 ON T1.alid = T3.alid WHERE T2.country = 'Italy' AND T3.name = 'American Airlines'" } ]
[ { "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 railway (\n\t\"Railway_ID\" INTEGER, \n\t\"Railway\" TEXT, \n\t\"Builder\" TEXT, \n\t\"Built\" TEXT, \n\t\"Wheels\" TEXT, \n\t\"Location\" TEXT, \n\t\"ObjectNumber\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\")\n)\n/*\nColumns in railway and all categories for low cardinality columns :\nRailway_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nRailway : Longmoor, LTSR, GWRWk, GERSt, GWRSn, GERHt, MR, SECR, GWRS, GNRD\nBuilder : GNR Doncaster, Stephenson, Swindon Works, GWR Swindon, GER Stratford, MR Derby, GER Hartford, SECR Ashford, Avonside\nBuilt : 1902 Midland Railway 1000 was rebuilt in 1914., 1902, 1901, 1905, 1907, 1903, 1904, 1909, 1910\nWheels : 4-4-0, 4-6-0, 0-6-0T, 4-4-2, 4-4-2T, 2-8-0, 0-6-0, 0-6-0ST\nLocation : Shildon, Swindon, Basingstoke, York, Toddington, Barrow Hill, Bressingham, Bo'ness\nObjectNumber : 1975-7005, 1978-7028, 1978-7025, 1975-7003, 1978-7026, 2008-7159, 1975-7006, 1978-7027, 1975-7018, 1976-7001\n*/\n \nCREATE TABLE \"Gradeconversion\" (\n\tlettergrade VARCHAR(2), \n\tgradepoint FLOAT, \n\tPRIMARY KEY (lettergrade)\n)\n/*\nColumns in Gradeconversion and 3 examples in each column for high cardinality columns :\nlettergrade : D+, F, B-\ngradepoint : 3.7, 3.0, 2.7\n*/\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 \"SAVINGS\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in SAVINGS and all categories for low cardinality columns :\ncustid : 1, 2, 5, 4, 6, 3\nbalance : 80000.0, 230000.0, 999999999.0, 60.0, 240.0, 200000.0\n*/\n \nCREATE TABLE manufacturer (\n\t\"Manufacturer_ID\" INTEGER, \n\t\"Open_Year\" REAL, \n\t\"Name\" TEXT, \n\t\"Num_of_Factories\" INTEGER, \n\t\"Num_of_Shops\" INTEGER, \n\tPRIMARY KEY (\"Manufacturer_ID\")\n)\n/*\nColumns in manufacturer and all categories for low cardinality columns :\nManufacturer_ID : 1, 2, 5, 7, 4, 6, 3\nOpen_Year : 2001.0, 2008.0, 2000.0, 1980.0, 1992.0, 1991.0, 1990.0\nName : Tomorrow, Chevrolet, Chevrolet House, Jiaju, Ford Make, IKEA, Dodge\nNum_of_Factories : 1, 38, 36, 21, 12, 3\nNum_of_Shops : 2, 7, 8, 24, 4, 19, 35\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 \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 \"Customers\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Customer_Details\" VARCHAR(255) NOT NULL, \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_Details : Miss Felicita Reichel, Selena Gerhold, Mrs. Liza Heller V\n*/\n\n \nCREATE TABLE member (\n\t\"Member_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Membership_card\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Time_of_purchase\" INTEGER, \n\t\"Level_of_membership\" INTEGER, \n\t\"Address\" TEXT, \n\tPRIMARY KEY (\"Member_ID\")\n)\n/*\nColumns in member and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Peeler, Russell, Rizzo, Todd, Campbell, Jessie, Breton, Robert, Komisarjevsky, Joshua, Webb, Daniel, Ashby, Lazale, Hayes, Steven, Reynolds, Richard, Cobb, Sedrick\nMembership_card : White, Black\nAge : 67, 45, 33, 50, 34, 42, 29, 51, 35\nTime_of_purchase : 26, 20, 44, 24, 18, 27, 41\nLevel_of_membership : 1, 2, 5, 4, 6, 3, 22\nAddress : Hartford, Bridgeport, Cheshire, Waterbury\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 \"Financial_Transactions\" (\n\ttransaction_id INTEGER NOT NULL, \n\tprevious_transaction_id INTEGER, \n\taccount_id INTEGER NOT NULL, \n\tcard_id INTEGER NOT NULL, \n\ttransaction_type VARCHAR(15) NOT NULL, \n\ttransaction_date DATETIME, \n\ttransaction_amount DOUBLE, \n\ttransaction_comment VARCHAR(255), \n\tother_transaction_details VARCHAR(255), \n\tFOREIGN KEY(account_id) REFERENCES \"Accounts\" (account_id), \n\tFOREIGN KEY(card_id) REFERENCES \"Customers_Cards\" (card_id)\n)\n/*\nColumns in Financial_Transactions and 3 examples in each column for high cardinality columns :\ntransaction_id : 1, 13, 11\nprevious_transaction_id : 925, 947, 986\naccount_id : 1, 13, 11\ntransaction_date : 2018-03-24 10:39:09, 2018-03-23 21:59:28, 2018-03-24 05:45:57\ntransaction_amount : 486.56, 1336.21, 945.43\n*/\n/*\nColumns in Financial_Transactions and all categories for low cardinality columns :\ncard_id : 1, 11, 2, 5, 7, 4, 6, 12, 3, 9\ntransaction_type : Refund, Payment\ntransaction_comment : None\nother_transaction_details : None\n*/\n \nCREATE TABLE book_club (\n\tbook_club_id INTEGER, \n\t\"Year\" INTEGER, \n\t\"Author_or_Editor\" TEXT, \n\t\"Book_Title\" TEXT, \n\t\"Publisher\" TEXT, \n\t\"Category\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (book_club_id)\n)\n/*\nColumns in book_club and 3 examples in each column for high cardinality columns :\nbook_club_id : 1, 11, 2\nAuthor_or_Editor : Dolores Klaich, Antoinette Azolakov, Sandy Bayer\nBook_Title : Lessons In Murder, Somewhere in the Night, Mundaneӳ World\n*/\n/*\nColumns in book_club and all categories for low cardinality columns :\nYear : 1989, 1990\nPublisher : International Polygonics, William Morrow, St. Martin's Press, Crossing Press, Alyson, Naiad Press, Banned Books, Mysterious Press\nCategory : Lesb. M/SF, Gay SF/F, Gay M/SF\nResult : Nom, Won [B ], Won, Won [A ]\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE artist (\n\t\"Artist_ID\" INTEGER, \n\t\"Artist\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Famous_Title\" TEXT, \n\t\"Famous_Release_date\" TEXT, \n\tPRIMARY KEY (\"Artist_ID\")\n)\n/*\nColumns in artist and all categories for low cardinality columns :\nArtist_ID : 1, 2, 5, 7, 4, 6, 3\nArtist : Gorgoroth, Tangorodrim, Triumfall, Black Flame, Ophiolatry\nAge : 49, 34, 18, 27, 22, 35\nFamous_Title : Unholy Metal Way (re-release), Antievangelistical Process (re-release), Imperivm, Those Who Unleashed (re-release), Antithesis of All Flesh, Bergen 1996, Transmutation\nFamous_Release_date : November 2007, 2009, June 15, 2009, January 21, 2008, June 23, 2008\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER NOT NULL, \n\tcustomer_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 : 79, 87, 16\ncustomer_details : Esteban Senger, Elva Boehm, Mr. Raul Prosacco\n*/\n\n \nCREATE TABLE \"Characteristics\" (\n\tcharacteristic_id INTEGER, \n\tcharacteristic_type_code VARCHAR(15) NOT NULL, \n\tcharacteristic_data_type VARCHAR(10), \n\tcharacteristic_name VARCHAR(80), \n\tother_characteristic_details VARCHAR(255), \n\tPRIMARY KEY (characteristic_id), \n\tFOREIGN KEY(characteristic_type_code) REFERENCES \"Ref_Characteristic_Types\" (characteristic_type_code)\n)\n/*\nColumns in Characteristics and 3 examples in each column for high cardinality columns :\ncharacteristic_id : 1, 13, 11\ncharacteristic_data_type : placeat, dolores, mollitia\n*/\n/*\nColumns in Characteristics and all categories for low cardinality columns :\ncharacteristic_type_code : Grade, Purity\ncharacteristic_name : hot, error, cool, fast, warm, slow\nother_characteristic_details : None\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 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 \"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" }, { "role": "user", "content": "What is the number of routes operated by the airline American Airlines whose destinations are in Italy?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports, airlines.\nFrom these tables, I'll be using the following columns: routes.dst_apid, airports.apid, routes.alid, airlines.alid, airports.country, airlines.name.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid JOIN airlines AS T3 ON T1.alid = T3.alid WHERE T2.country = 'Italy' AND T3.name = 'American Airlines'" } ]
[ { "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 \"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 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 airport (\n\t\"Airport_ID\" INTEGER, \n\t\"Airport_Name\" TEXT, \n\t\"Total_Passengers\" REAL, \n\t\"%_Change_2007\" TEXT, \n\t\"International_Passengers\" REAL, \n\t\"Domestic_Passengers\" REAL, \n\t\"Transit_Passengers\" REAL, \n\t\"Aircraft_Movements\" REAL, \n\t\"Freight_Metric_Tonnes\" REAL, \n\tPRIMARY KEY (\"Airport_ID\")\n)\n/*\nColumns in airport and all categories for low cardinality columns :\nAirport_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nAirport_Name : Bristol, London Luton, East Midlands, Birmingham Airport, Glasgow International, London Stansted, London Heathrow, London Gatwick, Edinburgh, Manchester\nTotal_Passengers : 8178891.0, 5620673.0, 34205887.0, 9627589.0, 67054745.0, 6267114.0, 10180734.0, 21219195.0, 22360364.0, 9006702.0\n%_Change_2007 : 2.6%, 4.0%, 6.0%, 1.5%, 0.5%, 5.7%, 2.9%, 4.3%, 3.8%, 7.0%\nInternational_Passengers : 3711140.0, 8105162.0, 3943139.0, 19996947.0, 5057051.0, 4870184.0, 8853224.0, 61344438.0, 30431051.0, 18119230.0\nDomestic_Passengers : 746094.0, 5562516.0, 1171605.0, 2943719.0, 1471538.0, 4192121.0, 3730963.0, 1320678.0, 2343428.0, 5281038.0\nTransit_Passengers : 156246.0, 50889.0, 6832.0, 19989.0, 43873.0, 43631.0, 14524.0, 38458.0, 4395.0, 147791.0\nAircraft_Movements : 478693.0, 117859.0, 204610.0, 193282.0, 125550.0, 76517.0, 112227.0, 100087.0, 93038.0, 263653.0\nFreight_Metric_Tonnes : 3.0, 261507.0, 12418.0, 40518.0, 197738.0, 141781.0, 107702.0, 3546.0, 12192.0, 1397054.0\n*/\n \nCREATE TABLE body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\n*/\n \nCREATE TABLE \"Ref_Characteristic_Types\" (\n\tcharacteristic_type_code VARCHAR(15), \n\tcharacteristic_type_description VARCHAR(80), \n\tPRIMARY KEY (characteristic_type_code)\n)\n/*\nColumns in Ref_Characteristic_Types and all categories for low cardinality columns :\ncharacteristic_type_code : Grade, Purity\ncharacteristic_type_description : Grade, Purity\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 \"Candidate_Assessments\" (\n\tcandidate_id INTEGER NOT NULL, \n\tqualification CHAR(15) NOT NULL, \n\tassessment_date DATETIME NOT NULL, \n\tasessment_outcome_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (candidate_id, qualification), \n\tFOREIGN KEY(candidate_id) REFERENCES \"Candidates\" (candidate_id)\n)\n/*\nColumns in Candidate_Assessments and all categories for low cardinality columns :\ncandidate_id : 151, 141, 131, 111, 121\nqualification : A, C, D, B\nassessment_date : 2010-04-06 11:44:34, 2010-04-17 11:44:34, 2010-04-09 11:44:34, 2010-04-07 11:44:34, 2010-04-05 11:44:34\nasessment_outcome_code : Fail, Pass\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 gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\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 \"Document_Structures\" (\n\tdocument_structure_code VARCHAR(15), \n\tparent_document_structure_code VARCHAR(15), \n\tdocument_structure_description VARCHAR(80), \n\tPRIMARY KEY (document_structure_code)\n)\n/*\nColumns in Document_Structures and all categories for low cardinality columns :\ndocument_structure_code : 1, 5, 8, 6, 9\nparent_document_structure_code : 1, 8, 6\ndocument_structure_description : Main section, Image section, Header, Bib, Author section\n*/\n \nCREATE TABLE \"Student_Course_Attendance\" (\n\tstudent_id INTEGER NOT NULL, \n\tcourse_id INTEGER NOT NULL, \n\tdate_of_attendance DATETIME NOT NULL, \n\tPRIMARY KEY (student_id, course_id), \n\tFOREIGN KEY(student_id, course_id) REFERENCES \"Student_Course_Registrations\" (student_id, course_id)\n)\n/*\nColumns in Student_Course_Attendance and all categories for low cardinality columns :\nstudent_id : 151, 141, 171, 161, 111, 121\ncourse_id : 302, 303, 301, 305\ndate_of_attendance : 2012-09-09 11:44:34, 2012-05-09 11:44:34, 2014-01-09 11:44:34, 2014-04-09 11:44:34, 2008-11-04 10:35:13, 2012-04-09 11:44:34, 2013-04-09 11:44:34, 2015-04-09 11:44:34\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 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" }, { "role": "user", "content": "Find the number of routes that have destination John F Kennedy International Airport." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.apid, routes.dst_apid, airports.name.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport'" } ]
[ { "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 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 \"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 \"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 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 \"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 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 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 \"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 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 photos (\n\tid INTEGER, \n\tcamera_lens_id INTEGER, \n\tmountain_id INTEGER, \n\tcolor TEXT, \n\tname TEXT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(mountain_id) REFERENCES mountain (id), \n\tFOREIGN KEY(camera_lens_id) REFERENCES camera_lens (id)\n)\n/*\nColumns in photos and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\ncamera_lens_id : 1, 5, 7, 6, 10\nmountain_id : 1, 20, 2, 14, 12, 10\ncolor : Black/White, RBG\nname : life, wolfs, deers, grass, rabbits, sunset, cloud, river, monkey, the mountain\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Claims_Processing\" (\n\t\"Claim_Processing_ID\" INTEGER NOT NULL, \n\t\"Claim_ID\" INTEGER NOT NULL, \n\t\"Claim_Outcome_Code\" CHAR(15) NOT NULL, \n\t\"Claim_Stage_ID\" INTEGER NOT NULL, \n\t\"Staff_ID\" INTEGER, \n\tPRIMARY KEY (\"Claim_Processing_ID\"), \n\tFOREIGN KEY(\"Claim_ID\") REFERENCES \"Claim_Headers\" (\"Claim_Header_ID\"), \n\tFOREIGN KEY(\"Staff_ID\") REFERENCES \"Staff\" (\"Staff_ID\")\n)\n/*\nColumns in Claims_Processing and 3 examples in each column for high cardinality columns :\nClaim_Processing_ID : 243, 342, 818\n*/\n/*\nColumns in Claims_Processing and all categories for low cardinality columns :\nClaim_ID : 45, 28, 90, 24, 34, 62, 15, 27, 81\nClaim_Outcome_Code : Settled, In progress, Disputed\nClaim_Stage_ID : 1, 3\nStaff_ID : 771, 427, 510, 673, 986, 687, 822, 589, 718\n*/\n \nCREATE TABLE race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\n*/\n \nCREATE TABLE \"Ref_Product_Categories\" (\n\tproduct_category_code VARCHAR(15), \n\tproduct_category_description VARCHAR(80), \n\tunit_of_measure VARCHAR(20), \n\tPRIMARY KEY (product_category_code)\n)\n/*\nColumns in Ref_Product_Categories and all categories for low cardinality columns :\nproduct_category_code : Spices, Seeds, Herbs\nproduct_category_description : Spices, Seeds, Herbs\nunit_of_measure : Weight - pound,kilo., Handful \n*/\n \nCREATE TABLE \"Properties\" (\n\tproperty_id INTEGER NOT NULL, \n\tproperty_type_code CHAR(15) NOT NULL, \n\tproperty_address VARCHAR(255), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (property_id)\n)\n/*\nColumns in Properties and 3 examples in each column for high cardinality columns :\nproperty_id : 120, 954, 108\nproperty_address : 5983 Fleta Throughway, 54591 Bernard Ridges Suite 864, 7713 Bode Burgs Apt. 113\n*/\n/*\nColumns in Properties and all categories for low cardinality columns :\nproperty_type_code : apartment, house, flat\nother_details : USA\n*/\n \nCREATE TABLE \"Rating\" (\n\t\"rID\" INTEGER, \n\t\"mID\" INTEGER, \n\tstars INTEGER, \n\t\"ratingDate\" DATE, \n\tFOREIGN KEY(\"mID\") REFERENCES \"Movie\" (\"mID\"), \n\tFOREIGN KEY(\"rID\") REFERENCES \"Reviewer\" (\"rID\")\n)\n/*\nColumns in Rating and all categories for low cardinality columns :\nrID : 201, 204, 205, 207, 206, 203, 208, 202\nmID : 108, 106, 103, 101, 104, 107\nstars : 2, 4, 5, 3\nratingDate : 2011-01-20, 2011-01-09, 2011-01-30, 2011-01-22, 2011-01-27, 2011-01-19, 2011-01-02, None, 2011-01-12, 2011-01-15\n*/\n \nCREATE TABLE \"Products_for_Hire\" (\n\tproduct_id INTEGER, \n\tproduct_type_code VARCHAR(15) NOT NULL, \n\tdaily_hire_cost DECIMAL(19, 4), \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products_for_Hire and all categories for low cardinality columns :\nproduct_id : 1, 2, 5, 4, 3\nproduct_type_code : Din_Plates, Cutlery\ndaily_hire_cost : 18.5000, 39.5800, 15.6200, 39.7300, 26.1500\nproduct_name : DVD collection B, DVD collection A, Book collection C, Book collection A, Book collection B\nproduct_description : The Great Gatsby, Anna Karenina, One Hundred Years of Solitude, War and Peace, Twilight\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" }, { "role": "user", "content": "What is the number of routes that end at John F Kennedy International Airport?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.apid, routes.dst_apid, airports.name.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport'" } ]
[ { "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 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 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 \"Ref_Incident_Type\" (\n\tincident_type_code VARCHAR(10), \n\tincident_type_description VARCHAR(80), \n\tPRIMARY KEY (incident_type_code)\n)\n/*\nColumns in Ref_Incident_Type and all categories for low cardinality columns :\nincident_type_code : VIOLENCE, DISTURB, NOISE\nincident_type_description : Noise, Violence, Disturbance\n*/\n \nCREATE TABLE repair_assignment (\n\ttechnician_id INTEGER, \n\t\"repair_ID\" INTEGER, \n\t\"Machine_ID\" INTEGER, \n\tPRIMARY KEY (technician_id, \"repair_ID\", \"Machine_ID\"), \n\tFOREIGN KEY(\"Machine_ID\") REFERENCES machine (\"Machine_ID\"), \n\tFOREIGN KEY(\"repair_ID\") REFERENCES repair (\"repair_ID\"), \n\tFOREIGN KEY(technician_id) REFERENCES technician (technician_id)\n)\n/*\nColumns in repair_assignment and all categories for low cardinality columns :\ntechnician_id : 1, 2, 5, 7, 3\nrepair_ID : 1, 2, 5, 8, 4, 3\nMachine_ID : 1, 2, 7, 4, 6, 3\n*/\n \nCREATE TABLE school (\n\t\"School_ID\" INTEGER, \n\t\"Grade\" TEXT, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 7, 4, 6, 3\nGrade : Freshman–Sophomore year, 1st-3rd grade, Kindergarten, Junior–Senior year, College, 5th-12th grade, 4th grade\nSchool : Occidental College, Noelani Elementary School, Harvard Law School, Columbia University, Punahou School, St. Francis Assisi, State Elementary School Menteng 01\nLocation : Cambridge, Massachusetts, Honolulu, Hawaii, Jakarta, Indonesia, Los Angeles, California, New York City\nType : Public, Private Catholic, Private\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 \"Rooms\" (\n\t\"RoomId\" TEXT, \n\t\"roomName\" TEXT, \n\tbeds INTEGER, \n\t\"bedType\" TEXT, \n\t\"maxOccupancy\" INTEGER, \n\t\"basePrice\" INTEGER, \n\tdecor TEXT, \n\tPRIMARY KEY (\"RoomId\")\n)\n/*\nColumns in Rooms and all categories for low cardinality columns :\nRoomId : IBD, IBS, RTE, CAS, FNA, HBB, AOB, MWC, TAA, RND\nroomName : Convoke and sanguine, Immutable before decorum, Abscond or bolster, Recluse and defiance, Thrift and accolade, Riddle to exculpate, Harbinger but bequest, Frugal not apropos, Interim but salutary, Mendicant with cryptic\nbeds : 1, 2\nbedType : King, Double, Queen\nmaxOccupancy : 2, 4\nbasePrice : 250, 75, 100, 150, 125, 175\ndecor : modern, rustic, traditional\n*/\n \nCREATE TABLE \"Department_Store_Chain\" (\n\tdept_store_chain_id INTEGER, \n\tdept_store_chain_name VARCHAR(80), \n\tPRIMARY KEY (dept_store_chain_id)\n)\n/*\nColumns in Department_Store_Chain and all categories for low cardinality columns :\ndept_store_chain_id : 1, 2, 4, 3\ndept_store_chain_name : West, East, North, South\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 film (\n\t\"Film_ID\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Studio\" TEXT, \n\t\"Director\" TEXT, \n\t\"Gross_in_dollar\" INTEGER, \n\tPRIMARY KEY (\"Film_ID\")\n)\n/*\nColumns in film and 3 examples in each column for high cardinality columns :\nFilm_ID : 1, 13, 11\nTitle : Annie, Rocky III, Tootsie\nDirector : Richard Attenborough, Nicholas Meyer, Ted Kotcheff\nGross_in_dollar : 53977250, 76606280, 125049125\n*/\n/*\nColumns in film and all categories for low cardinality columns :\nStudio : MGM, United Artists, Universal, 20th Century Fox, Columbia, Paramount, Columbia / Rastar, Paramount / Lorimar, Orion / Carolco, Universal / RKO\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 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 \"Document_Functional_Areas\" (\n\tdocument_code VARCHAR(15) NOT NULL, \n\tfunctional_area_code VARCHAR(15) NOT NULL, \n\tFOREIGN KEY(functional_area_code) REFERENCES \"Functional_Areas\" (functional_area_code), \n\tFOREIGN KEY(document_code) REFERENCES \"Documents\" (document_code)\n)\n/*\nColumns in Document_Functional_Areas and 3 examples in each column for high cardinality columns :\ndocument_code : 217, 930, 958\n*/\n/*\nColumns in Document_Functional_Areas and all categories for low cardinality columns :\nfunctional_area_code : 1, 8, 9\n*/\n \nCREATE TABLE school_bus (\n\t\"School_ID\" INTEGER, \n\t\"Driver_ID\" INTEGER, \n\t\"Years_Working\" INTEGER, \n\t\"If_full_time\" BOOLEAN, \n\tPRIMARY KEY (\"School_ID\", \"Driver_ID\"), \n\tFOREIGN KEY(\"Driver_ID\") REFERENCES driver (\"Driver_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in school_bus and all categories for low cardinality columns :\nSchool_ID : 1, 5, 7, 4, 3\nDriver_ID : 7, 4, 3, 10, 9\nYears_Working : 2, 8, 6, 3, 10\nIf_full_time : True\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE election (\n\t\"Election_ID\" INTEGER, \n\t\"Counties_Represented\" TEXT, \n\t\"District\" INTEGER, \n\t\"Delegate\" TEXT, \n\t\"Party\" INTEGER, \n\t\"First_Elected\" REAL, \n\t\"Committee\" TEXT, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"District\") REFERENCES county (\"County_Id\"), \n\tFOREIGN KEY(\"Party\") REFERENCES party (\"Party_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 7, 8, 4, 6, 3\nCounties_Represented : 09.1 9A, 13, 12.1 12A, 12.2 12B\nDistrict : 1, 2, 4, 3\nDelegate : Miller, Warren E. Warren E. Miller, Bobo, Elizabeth Elizabeth Bobo, Pendergrass, Shane E. Shane Pendergrass, Bates, Gail H. Gail H. Bates, DeBoy, Steven J. Sr. Steven J. DeBoy, Sr., Guzzone, Guy Guy Guzzone, Turner, Frank S. Frank S. Turner, Malone, James E. Jr. James E. Malone, Jr.\nParty : 1, 2, 7, 4, 3\nFirst_Elected : 2002.0, 2006.0, 1994.0, 2003.0\nCommittee : Environmental Matters, Economic Matters, Ways and Means, Environmental Matters (Vice-Chair), Health and Government Operations, Appropriations\n*/\n \nCREATE TABLE \"Staff\" (\n\tstaff_id INTEGER, \n\tgender VARCHAR(1), \n\tfirst_name VARCHAR(80), \n\tlast_name VARCHAR(80), \n\temail_address VARCHAR(255), \n\tphone_number VARCHAR(80), \n\tPRIMARY KEY (staff_id)\n)\n/*\nColumns in Staff and all categories for low cardinality columns :\nstaff_id : 120, 114, 116, 117, 115, 119, 118\ngender : 1, 0\nfirst_name : Dorian, Austin, Bradly, Ward, Dagmar, Mikel, Lucie\nlast_name : Zieme, Hahn, Oberbrunner, Lynch, Erdman, Boehm, Lowe\nemail_address : ohintz@example.org, brett99@example.net, glen.borer@example.com, reichel.armani@example.org, wrau@example.com, marcelle.ritchie@example.com, richard.gutkowski@example.com\nphone_number : 345-656-5571, 1-132-839-9409x288, 751-262-8424x575, (379)551-0838x146, 142-311-6503x206, (383)553-1035x20399, 155-811-6153\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 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" }, { "role": "user", "content": "Find the number of routes from the United States to Canada." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports.\nFrom these tables, I'll be using the following columns: dst_apid, apid, country, src_apid.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')" } ]
[ { "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 election (\n\t\"Election_ID\" INTEGER, \n\t\"Representative_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Votes\" REAL, \n\t\"Vote_Percent\" REAL, \n\t\"Seats\" REAL, \n\t\"Place\" REAL, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"Representative_ID\") REFERENCES representative (\"Representative_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 4, 3\nRepresentative_ID : 1, 2, 5, 7, 4\nDate : 1946, 1949, July 1942, October 1942, 1953\nVotes : 11059.0, 9423.0, 13049.0, 12422.0, 14077.0\nVote_Percent : 16.0, 19.5, 16.2, 18.5\nSeats : 10.0, 6.0, 7.0, 9.0\nPlace : 3.0, 1.0, 2.0\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 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 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 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 \"Block\" (\n\t\"BlockFloor\" INTEGER NOT NULL, \n\t\"BlockCode\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"BlockFloor\", \"BlockCode\")\n)\n/*\nColumns in Block and all categories for low cardinality columns :\nBlockFloor : 1, 2, 4, 3\nBlockCode : 1, 2, 3\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE culture_company (\n\t\"Company_name\" TEXT, \n\t\"Type\" TEXT, \n\t\"Incorporated_in\" TEXT, \n\t\"Group_Equity_Shareholding\" REAL, \n\tbook_club_id TEXT, \n\tmovie_id TEXT, \n\tPRIMARY KEY (\"Company_name\"), \n\tFOREIGN KEY(book_club_id) REFERENCES book_club (book_club_id), \n\tFOREIGN KEY(movie_id) REFERENCES movie (movie_id)\n)\n/*\nColumns in culture_company and all categories for low cardinality columns :\nCompany_name : Cathay Pacific Culture, Culture China Cargo, Culture Hong Kong, Cathay Pacific Culture Services (HK) Limited, Culture China, Dragonair\nType : Joint Venture, Subsidiary, Corporate\nIncorporated_in : Hong Kong, China\nGroup_Equity_Shareholding : 49.0, 60.0, 18.77, 100.0\nbook_club_id : 1, 2, 5, 6, 3\nmovie_id : 2, 5, 7, 4, 6, 3\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 medicine_enzyme_interaction (\n\tenzyme_id INTEGER, \n\tmedicine_id INTEGER, \n\tinteraction_type TEXT, \n\tPRIMARY KEY (enzyme_id, medicine_id), \n\tFOREIGN KEY(medicine_id) REFERENCES medicine (id), \n\tFOREIGN KEY(enzyme_id) REFERENCES enzyme (id)\n)\n/*\nColumns in medicine_enzyme_interaction and 3 examples in each column for high cardinality columns :\nmedicine_id : 1, 13, 20\n*/\n/*\nColumns in medicine_enzyme_interaction and all categories for low cardinality columns :\nenzyme_id : 1, 2, 5, 4, 6, 3\ninteraction_type : inhibitor, activitor\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 \"Financial_Transactions\" (\n\ttransaction_id INTEGER NOT NULL, \n\taccount_id INTEGER NOT NULL, \n\tinvoice_number INTEGER, \n\ttransaction_type VARCHAR(15) NOT NULL, \n\ttransaction_date DATETIME, \n\ttransaction_amount DECIMAL(19, 4), \n\ttransaction_comment VARCHAR(255), \n\tother_transaction_details VARCHAR(255), \n\tFOREIGN KEY(account_id) REFERENCES \"Accounts\" (account_id), \n\tFOREIGN KEY(invoice_number) REFERENCES \"Invoices\" (invoice_number)\n)\n/*\nColumns in Financial_Transactions and 3 examples in each column for high cardinality columns :\ntransaction_id : 1, 13, 11\ntransaction_date : 2018-03-10 13:46:48, 2018-03-11 21:57:47, 2018-03-13 03:51:59\ntransaction_amount : 540.7300, 368.4600, 1214.2200\n*/\n/*\nColumns in Financial_Transactions and all categories for low cardinality columns :\naccount_id : 13, 11, 8, 4, 6, 14, 12, 9\ninvoice_number : 1, 3, 13, 2, 5, 6, 14, 12, 15\ntransaction_type : Refund, Payment\ntransaction_comment : None\nother_transaction_details : None\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\tpayment_method VARCHAR(15) NOT NULL, \n\tcustomer_name VARCHAR(80), \n\tdate_became_customer DATETIME, \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_name : Alexane Kilback, Salvatore Tillman, Eunice Morar\ndate_became_customer : 2018-03-01 23:20:10, 2018-03-09 17:41:58, 2018-03-07 18:05:11\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\npayment_method : Cheque, Credit Card, Cash\nother_customer_details : None, VIP\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 \"Companies\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value_billion\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Companies and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : PetroChina, Berkshire Hathaway, Petrobras\nSales_billion : 69.2, 189.6, 421.8\nProfits_billion : 16.4, 19.9, 17.4\nAssets_billion : 2467.9, 192.8, 1913.9\nMarket_Value_billion : 239.5, 186.5, 224.8\n*/\n/*\nColumns in Companies and all categories for low cardinality columns :\nHeadquarters : Spain, UK, China, Brazil, France, Russia, USA, Netherlands\nIndustry : Retailing, Conglomerate, Oil and gas, Telecommunications, Banking\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_type_code VARCHAR(15), \n\tproduct_name VARCHAR(80), \n\tproduct_price DOUBLE, \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nproduct_price : 5927021.8748021, 622.79275984494, 22956668.699482\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_type_code : Hardware, Clothes\nproduct_name : Apple, jcrew, Sony, gucci\n*/\n" }, { "role": "user", "content": "How many routes go from the United States to Canada?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports.\nFrom these tables, I'll be using the following columns: dst_apid, apid, country, src_apid.\nThe SQL query I'll be generating is:\nSELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')" } ]
[ { "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 wine (\n\t\"No\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Winery\" TEXT, \n\t\"Appelation\" TEXT, \n\t\"State\" TEXT, \n\t\"Name\" TEXT, \n\t\"Year\" INTEGER, \n\t\"Price\" INTEGER, \n\t\"Score\" INTEGER, \n\t\"Cases\" INTEGER, \n\t\"Drink\" TEXT, \n\tFOREIGN KEY(\"Grape\") REFERENCES grapes (\"Grape\"), \n\tFOREIGN KEY(\"Appelation\") REFERENCES appellations (\"Appelation\")\n)\n/*\nColumns in wine and 3 examples in each column for high cardinality columns :\nNo : 87, 56, 65\nWinery : Novy, Turnbull, Loring\nAppelation : Mendocino County, Happy Canyon of Santa Barbara, Russian River Valley\nName : Wheelhouse, Limited Release, Mother Clone\nPrice : 56, 65, 75\nScore : 87, 91, 89\nCases : NULL, 377, 575\n*/\n/*\nColumns in wine and all categories for low cardinality columns :\nGrape : Sauvignon Blanc, Pinot Noir, Malbec, Merlot, Petite Sirah, Syrah, Cabernet Sauvingnon, Grenache, Zinfandel\nState : California\nYear : 2006, 2008, 2009, 2007\nDrink : 2013, 2001, 2012, 2011, now, 2010\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 \"Club\" (\n\t\"ClubID\" INTEGER, \n\t\"ClubName\" VARCHAR(40), \n\t\"ClubDesc\" VARCHAR(1024), \n\t\"ClubLocation\" VARCHAR(40), \n\tPRIMARY KEY (\"ClubID\")\n)\n/*\nColumns in Club and all categories for low cardinality columns :\nClubID : 1, 2, 4, 3\nClubName : Bootup Baltimore, Pen and Paper Gaming, Tennis Club, Hopkins Student Enterprises\nClubDesc : Venture capital fund for student business., A competitive tennis club., Refurbish computers; teach kids and adults about computer basics., Play pen and paper games on campus.\nClubLocation : HHH, AKW\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_type_code VARCHAR(20) NOT NULL, \n\taddress_line_1 VARCHAR(80), \n\taddress_line_2 VARCHAR(80), \n\ttown_city VARCHAR(80), \n\tstate VARCHAR(80), \n\temail_address VARCHAR(255), \n\tphone_number VARCHAR(80), \n\tPRIMARY KEY (customer_id)\n)\n/*\nColumns in Customers and all categories for low cardinality columns :\ncustomer_id : 120, 114, 113, 116, 117, 115, 119, 118\ncustomer_type_code : Defaults on payments, Good Credit Rating\naddress_line_1 : 92189 Gulgowski Ranch Apt. 683, 05355 Marcelle Radial, 039 Jedidiah Estate Suite 537, 72144 Katlynn Flat Suite 512, 518 Mann Park, 425 Roman Tunnel, 1566 Ramona Overpass Apt. 464, 144 Legros Landing\naddress_line_2 : Suite 151, Apt. 551, Suite 035, Suite 959, Apt. 245, Apt. 495, Apt. 828, Suite 054\ntown_city : Funkstad, Tyreekhaven, North Alisaville, Maryamport, Hansenbury, Port Joshuah, West Annamariestad, Sauerberg\nstate : Pennsylvania, Hawaii, Tennessee, Kansas, Colorado, Iowa, Florida\nemail_address : hsteuber@example.org, vbogisich@example.org, rzulauf@example.org, cayla.satterfield@example.net, paige.hyatt@example.com, lavonne.frami@example.com, ubeier@example.org, vida86@example.com\nphone_number : 548.373.3603x59134, 044-468-4549, 06963347450, 997.698.4779x882, +38(3)9011433816, 578.019.7943x328, 1-369-302-7623x576, 470-803-0244\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 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 \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 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 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 election (\n\t\"Election_ID\" INTEGER, \n\t\"Counties_Represented\" TEXT, \n\t\"District\" INTEGER, \n\t\"Delegate\" TEXT, \n\t\"Party\" INTEGER, \n\t\"First_Elected\" REAL, \n\t\"Committee\" TEXT, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"District\") REFERENCES county (\"County_Id\"), \n\tFOREIGN KEY(\"Party\") REFERENCES party (\"Party_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 7, 8, 4, 6, 3\nCounties_Represented : 09.1 9A, 13, 12.1 12A, 12.2 12B\nDistrict : 1, 2, 4, 3\nDelegate : Miller, Warren E. Warren E. Miller, Bobo, Elizabeth Elizabeth Bobo, Pendergrass, Shane E. Shane Pendergrass, Bates, Gail H. Gail H. Bates, DeBoy, Steven J. Sr. Steven J. DeBoy, Sr., Guzzone, Guy Guy Guzzone, Turner, Frank S. Frank S. Turner, Malone, James E. Jr. James E. Malone, Jr.\nParty : 1, 2, 7, 4, 3\nFirst_Elected : 2002.0, 2006.0, 1994.0, 2003.0\nCommittee : Environmental Matters, Economic Matters, Ways and Means, Environmental Matters (Vice-Chair), Health and Government Operations, Appropriations\n*/\n \nCREATE TABLE exhibition_record (\n\t\"Exhibition_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Exhibition_ID\", \"Date\"), \n\tFOREIGN KEY(\"Exhibition_ID\") REFERENCES exhibition (\"Exhibition_ID\")\n)\n/*\nColumns in exhibition_record and 3 examples in each column for high cardinality columns :\nDate : February 25, February 19, December 2\nAttendance : 1313, 24808, 1233\n*/\n/*\nColumns in exhibition_record and all categories for low cardinality columns :\nExhibition_ID : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE photos (\n\tid INTEGER, \n\tcamera_lens_id INTEGER, \n\tmountain_id INTEGER, \n\tcolor TEXT, \n\tname TEXT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(mountain_id) REFERENCES mountain (id), \n\tFOREIGN KEY(camera_lens_id) REFERENCES camera_lens (id)\n)\n/*\nColumns in photos and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\ncamera_lens_id : 1, 5, 7, 6, 10\nmountain_id : 1, 20, 2, 14, 12, 10\ncolor : Black/White, RBG\nname : life, wolfs, deers, grass, rabbits, sunset, cloud, river, monkey, the mountain\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 \nCREATE TABLE files (\n\tf_id NUMERIC(10) NOT NULL, \n\tartist_name TEXT(50), \n\tfile_size TEXT(20), \n\tduration TEXT(20), \n\tformats TEXT(20), \n\tPRIMARY KEY (f_id), \n\tFOREIGN KEY(artist_name) REFERENCES artist (artist_name) ON DELETE CASCADE\n)\n/*\nColumns in files and all categories for low cardinality columns :\nf_id : 1.0000000000, 5.0000000000, 6.0000000000, 3.0000000000, 2.0000000000, 4.0000000000\nartist_name : Prity, Michel, Topu, Shrikanta, Enrique, Farida\nfile_size : 4.58 MB, 5.10 MB, 4.10 MB, 3.69 MB, 3.78 MB, 4.12 MB\nduration : 4:30, 5:23, 2:56, 4:34, 3:45, 4:12\nformats : mp3, mp4\n*/\n" }, { "role": "user", "content": "Find the id of routes whose source and destination airports are in the United States." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports.\nFrom these tables, I'll be using the following columns: rid, dst_apid, apid, country, src_apid.\nThe SQL query I'll be generating is:\nSELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'United States') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')" } ]
[ { "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 \"Employees\" (\n\t\"Employee_ID\" INTEGER NOT NULL, \n\t\"Role_Code\" CHAR(15) NOT NULL, \n\t\"Employee_Name\" VARCHAR(255), \n\t\"Gender_MFU\" CHAR(1) NOT NULL, \n\t\"Date_of_Birth\" DATETIME NOT NULL, \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Employee_ID\"), \n\tFOREIGN KEY(\"Role_Code\") REFERENCES \"Roles\" (\"Role_Code\")\n)\n/*\nColumns in Employees and 3 examples in each column for high cardinality columns :\nEmployee_ID : 173, 159, 38\nEmployee_Name : Harley, Armani, Leo\nDate_of_Birth : 1973-04-04 21:41:22, 1977-07-04 16:25:21, 1979-09-20 12:50:15\n*/\n/*\nColumns in Employees and all categories for low cardinality columns :\nRole_Code : PR, HR, PT, MG, ED\nGender_MFU : , 1\nOther_Details : None\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Customer_Orders\" (\n\t\"Order_ID\" INTEGER NOT NULL, \n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Store_ID\" INTEGER NOT NULL, \n\t\"Order_Date\" DATETIME NOT NULL, \n\t\"Planned_Delivery_Date\" DATETIME NOT NULL, \n\t\"Actual_Delivery_Date\" DATETIME NOT NULL, \n\t\"Other_Order_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Order_ID\"), \n\tFOREIGN KEY(\"Customer_ID\") REFERENCES \"Customers\" (\"Customer_ID\"), \n\tFOREIGN KEY(\"Store_ID\") REFERENCES \"Stores\" (\"Store_ID\"), \n\tUNIQUE (\"Order_ID\")\n)\n/*\nColumns in Customer_Orders and 3 examples in each column for high cardinality columns :\nOrder_ID : 1, 13, 11\nOrder_Date : 2000-07-03 21:41:50, 2003-06-24 11:44:51, 1998-03-10 14:01:00\nPlanned_Delivery_Date : 2012-05-19 00:38:52, 1990-09-25 07:14:01, 2004-04-24 01:52:57\nActual_Delivery_Date : 2003-12-16 23:37:19, 1998-08-22 17:57:32, 1993-09-16 23:20:05\n*/\n/*\nColumns in Customer_Orders and all categories for low cardinality columns :\nCustomer_ID : 556, 240, 712, 304, 546, 516, 418\nStore_ID : 518, 150, 229, 291, 444, 231, 512, 421, 344\nOther_Order_Details : None\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 \"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 grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\n*/\n \nCREATE TABLE \"Video_Games\" (\n\t\"GameID\" INTEGER, \n\t\"GName\" VARCHAR(40), \n\t\"GType\" VARCHAR(40), \n\tPRIMARY KEY (\"GameID\")\n)\n/*\nColumns in Video_Games and all categories for low cardinality columns :\nGameID : 1, 2, 5, 4, 6, 3\nGName : Call of Destiny, Grand Term Assignment, The Vanishing of Eric Calder, Europe is the Universe, Works of Widenius, RNG Stone\nGType : Role-playing game, Collectible card game, Frist-person shooter, Walking Simulator, Grand strategy, Massively multiplayer online game\n*/\n \nCREATE TABLE \"Office_locations\" (\n\tbuilding_id INTEGER, \n\tcompany_id INTEGER, \n\tmove_in_year INTEGER, \n\tPRIMARY KEY (building_id, company_id), \n\tFOREIGN KEY(building_id) REFERENCES buildings (id), \n\tFOREIGN KEY(company_id) REFERENCES \"Companies\" (id)\n)\n/*\nColumns in Office_locations and 3 examples in each column for high cardinality columns :\nbuilding_id : 1, 11, 2\nmove_in_year : 2023, 2020, 2022\n*/\n/*\nColumns in Office_locations and all categories for low cardinality columns :\ncompany_id : 1, 11, 2, 5, 19, 7, 4, 3, 10, 9\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 \"Functional_Areas\" (\n\tfunctional_area_code VARCHAR(15), \n\tparent_functional_area_code VARCHAR(15), \n\tfunctional_area_description VARCHAR(80) NOT NULL, \n\tPRIMARY KEY (functional_area_code)\n)\n/*\nColumns in Functional_Areas and all categories for low cardinality columns :\nfunctional_area_code : 1, 8, 9\nparent_functional_area_code : 8\nfunctional_area_description : Keep blank, Signature, Acknowledgement\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 \"College\" (\n\t\"cName\" VARCHAR(20) NOT NULL, \n\tstate VARCHAR(2), \n\tenr NUMERIC(5, 0), \n\tPRIMARY KEY (\"cName\")\n)\n/*\nColumns in College and all categories for low cardinality columns :\ncName : FSU, OU, ASU, LSU\nstate : AZ, FL, LA, OK\nenr : 22000, 19000, 12000, 18000\n*/\n \nCREATE TABLE \"First_Notification_of_Loss\" (\n\t\"FNOL_ID\" INTEGER NOT NULL, \n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Service_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"FNOL_ID\"), \n\tFOREIGN KEY(\"Service_ID\") REFERENCES \"Services\" (\"Service_ID\"), \n\tFOREIGN KEY(\"Customer_ID\", \"Policy_ID\") REFERENCES \"Customers_Policies\" (\"Customer_ID\", \"Policy_ID\"), \n\tUNIQUE (\"FNOL_ID\")\n)\n/*\nColumns in First_Notification_of_Loss and all categories for low cardinality columns :\nFNOL_ID : 1611, 4226, 2543, 4525, 1722, 4323, 532\nCustomer_ID : 582, 892, 826, 214, 996\nPolicy_ID : 586, 630, 257, 927, 366, 879, 993\nService_ID : 1, 9, 4, 6\n*/\n \nCREATE TABLE entrepreneur (\n\t\"Entrepreneur_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Company\" TEXT, \n\t\"Money_Requested\" REAL, \n\t\"Investor\" TEXT, \n\tPRIMARY KEY (\"Entrepreneur_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in entrepreneur and all categories for low cardinality columns :\nEntrepreneur_ID : 1, 2, 5, 4, 6, 3\nPeople_ID : 1, 2, 5, 8, 6, 3\nCompany : Mycorrhizal Systems, Le Beanock, Umbrolly, IV Cam, Elizabeth Galton Ltd, Grails Ltd\nMoney_Requested : 150000.0, 110000.0, 120000.0, 75000.0, 50000.0, 54000.0\nInvestor : Duncan Bannatyne, Doug Richard, Peter Jones, Rachel Elnaugh, Simon Woodroffe\n*/\n \nCREATE TABLE grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\n*/\n \nCREATE TABLE performance (\n\t\"Performance_ID\" REAL, \n\t\"Date\" TEXT, \n\t\"Host\" TEXT, \n\t\"Location\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Performance_ID\")\n)\n/*\nColumns in performance and all categories for low cardinality columns :\nPerformance_ID : 3.0, 1.0, 2.0, 6.0, 4.0, 5.0\nDate : February 7, February 4, February 2, February 5, February 10, February 11\nHost : Ottawa Senators, New York Rangers, Pittsburgh Penguins, Atlanta Thrashers, Montreal Canadiens, Boston Bruins\nLocation : Madison Square Garden, Scotiabank Place, Verizon Center, TD Garden, Bell Centre\nAttendance : 2173, 1878, 1877, 1820, 1982, 165\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 \nCREATE TABLE station (\n\tid INTEGER, \n\tname TEXT, \n\tlat NUMERIC, \n\tlong NUMERIC, \n\tdock_count INTEGER, \n\tcity TEXT, \n\tinstallation_date TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in station and 3 examples in each column for high cardinality columns :\nid : 56, 65, 75\nname : Howard at 2nd, 2nd at Folsom, Market at 10th\nlat : 37.7954250000, 37.7863050000, 37.3297320000\nlong : -122.2362340000, -122.2274240000, -122.4182350000\ninstallation_date : 8/20/2013, 1/22/2014, 8/15/2013\n*/\n/*\nColumns in station and all categories for low cardinality columns :\ndock_count : 11, 25, 23, 19, 15, 27\ncity : San Jose, Mountain View, Palo Alto, Redwood City, San Francisco\n*/\n" }, { "role": "user", "content": "What is the id of the routes whose source and destination airports are in the United States?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: routes, airports.\nFrom these tables, I'll be using the following columns: rid, dst_apid, apid, country, src_apid.\nThe SQL query I'll be generating is:\nSELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'United States') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')" } ]
[ { "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 \"Timed_Status_of_Things\" (\n\tthing_id INTEGER NOT NULL, \n\t\"Date_and_Date\" DATETIME NOT NULL, \n\t\"Status_of_Thing_Code\" CHAR(15) NOT NULL, \n\tPRIMARY KEY (thing_id, \"Date_and_Date\", \"Status_of_Thing_Code\"), \n\tFOREIGN KEY(thing_id) REFERENCES \"Things\" (thing_id)\n)\n/*\nColumns in Timed_Status_of_Things and 3 examples in each column for high cardinality columns :\nthing_id : 26, 80, 2\nDate_and_Date : 2017-06-19 02:59:21, 2017-08-05 02:10:02, 2016-10-08 08:02:57\n*/\n/*\nColumns in Timed_Status_of_Things and all categories for low cardinality columns :\nStatus_of_Thing_Code : Open, Close, In Progress\n*/\n \nCREATE TABLE \"Catalog_Contents_Additional_Attributes\" (\n\tcatalog_entry_id INTEGER NOT NULL, \n\tcatalog_level_number INTEGER NOT NULL, \n\tattribute_id INTEGER NOT NULL, \n\tattribute_value VARCHAR(255) NOT NULL, \n\tFOREIGN KEY(catalog_level_number) REFERENCES \"Catalog_Structure\" (catalog_level_number), \n\tFOREIGN KEY(catalog_entry_id) REFERENCES \"Catalog_Contents\" (catalog_entry_id)\n)\n/*\nColumns in Catalog_Contents_Additional_Attributes and all categories for low cardinality columns :\ncatalog_entry_id : 1, 11, 2, 5, 8, 4, 6, 12, 14, 15\ncatalog_level_number : 1, 8, 9\nattribute_id : 1, 2, 4, 3\nattribute_value : 1, 0\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 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 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 performance (\n\t\"Performance_ID\" REAL, \n\t\"Date\" TEXT, \n\t\"Host\" TEXT, \n\t\"Location\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Performance_ID\")\n)\n/*\nColumns in performance and all categories for low cardinality columns :\nPerformance_ID : 3.0, 1.0, 2.0, 6.0, 4.0, 5.0\nDate : February 7, February 4, February 2, February 5, February 10, February 11\nHost : Ottawa Senators, New York Rangers, Pittsburgh Penguins, Atlanta Thrashers, Montreal Canadiens, Boston Bruins\nLocation : Madison Square Garden, Scotiabank Place, Verizon Center, TD Garden, Bell Centre\nAttendance : 2173, 1878, 1877, 1820, 1982, 165\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 church (\n\t\"Church_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Organized_by\" TEXT, \n\t\"Open_Date\" INTEGER, \n\t\"Continuation_of\" TEXT, \n\tPRIMARY KEY (\"Church_ID\")\n)\n/*\nColumns in church and all categories for low cardinality columns :\nChurch_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Pure Church of Christ, True Church of Jesus Christ of Latter Day Saints, Alston Church, Church of Christ, Church of Jesus Christ, the Bride, the Lamb's Wife, Church of Christ (Parrishite), Independent Church\nOrganized_by : Hiram Page, George M. Hinkle, Isaac Russell, Wycam Clark, Ezra Booth, William Chubby, William Law, – Hoton, Warren Parrish\nOpen_Date : 1840, 1839, 1836, 1832, 1837, 1844, 1831, 1830, 1842\nContinuation_of : Church of Jesus Christ of Latter Day Saints, Church of Christ, Church of the Latter Day Saints\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 \"Ref_Payment_Methods\" (\n\tpayment_method_code CHAR(10) NOT NULL, \n\tpayment_method_description VARCHAR(80), \n\tPRIMARY KEY (payment_method_code), \n\tUNIQUE (payment_method_code)\n)\n/*\nColumns in Ref_Payment_Methods and all categories for low cardinality columns :\npayment_method_code : Visa, MasterCard, American E\npayment_method_description : Visa, debit, credit\n*/\n \nCREATE TABLE \"Staff\" (\n\tstaff_id INTEGER, \n\tgender VARCHAR(1), \n\tfirst_name VARCHAR(80), \n\tlast_name VARCHAR(80), \n\temail_address VARCHAR(255), \n\tphone_number VARCHAR(80), \n\tPRIMARY KEY (staff_id)\n)\n/*\nColumns in Staff and all categories for low cardinality columns :\nstaff_id : 120, 114, 116, 117, 115, 119, 118\ngender : 1, 0\nfirst_name : Dorian, Austin, Bradly, Ward, Dagmar, Mikel, Lucie\nlast_name : Zieme, Hahn, Oberbrunner, Lynch, Erdman, Boehm, Lowe\nemail_address : ohintz@example.org, brett99@example.net, glen.borer@example.com, reichel.armani@example.org, wrau@example.com, marcelle.ritchie@example.com, richard.gutkowski@example.com\nphone_number : 345-656-5571, 1-132-839-9409x288, 751-262-8424x575, (379)551-0838x146, 142-311-6503x206, (383)553-1035x20399, 155-811-6153\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 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 \"Things\" (\n\tthing_id INTEGER NOT NULL, \n\torganization_id INTEGER NOT NULL, \n\t\"Type_of_Thing_Code\" CHAR(15) NOT NULL, \n\tservice_type_code CHAR(10) NOT NULL, \n\tservice_details VARCHAR(255), \n\tPRIMARY KEY (thing_id), \n\tFOREIGN KEY(organization_id) REFERENCES \"Organizations\" (organization_id)\n)\n/*\nColumns in Things and 3 examples in each column for high cardinality columns :\nthing_id : 1, 26, 45\n*/\n/*\nColumns in Things and all categories for low cardinality columns :\norganization_id : 10, 7, 8\nType_of_Thing_Code : Electronics, Commen, Furniture\nservice_type_code : Cleanning, Check\nservice_details : Satisfied, Unsatisfied\n*/\n \nCREATE TABLE bridge (\n\tarchitect_id INTEGER, \n\tid INTEGER, \n\tname TEXT, \n\tlocation TEXT, \n\tlength_meters REAL, \n\tlength_feet REAL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(architect_id) REFERENCES architect (id)\n)\n/*\nColumns in bridge and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nname : Xian Ren Qiao (Fairy Bridge), Hazarchishma Natural Bridge, Stevens Arch\nlocation : Guizhou , China, Natural Bridges National Monument , Utah , USA, Dinosaur National Monument , Colorado , USA\nlength_meters : 64.2, 69.0, 67.0\nlength_feet : 290.0, 225.0, 400.0\n*/\n/*\nColumns in bridge and all categories for low cardinality columns :\narchitect_id : 1, 2, 5, 4, 3\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 \"Undergoes\" (\n\t\"Patient\" INTEGER NOT NULL, \n\t\"Procedures\" INTEGER NOT NULL, \n\t\"Stay\" INTEGER NOT NULL, \n\t\"DateUndergoes\" DATETIME NOT NULL, \n\t\"Physician\" INTEGER NOT NULL, \n\t\"AssistingNurse\" INTEGER, \n\tPRIMARY KEY (\"Patient\", \"Procedures\", \"Stay\", \"DateUndergoes\"), \n\tCONSTRAINT \"fk_Undergoes_Patient_SSN\" FOREIGN KEY(\"Patient\") REFERENCES \"Patient\" (\"SSN\"), \n\tCONSTRAINT \"fk_Undergoes_Procedures_Code\" FOREIGN KEY(\"Procedures\") REFERENCES \"Procedures\" (\"Code\"), \n\tCONSTRAINT \"fk_Undergoes_Stay_StayID\" FOREIGN KEY(\"Stay\") REFERENCES \"Stay\" (\"StayID\"), \n\tCONSTRAINT \"fk_Undergoes_Physician_EmployeeID\" FOREIGN KEY(\"Physician\") REFERENCES \"Physician\" (\"EmployeeID\"), \n\tCONSTRAINT \"fk_Undergoes_Nurse_EmployeeID\" FOREIGN KEY(\"AssistingNurse\") REFERENCES \"Nurse\" (\"EmployeeID\")\n)\n/*\nColumns in Undergoes and all categories for low cardinality columns :\nPatient : 100000001, 100000004\nProcedures : 1, 2, 5, 7, 4, 6\nStay : 3215, 3217\nDateUndergoes : 2008-05-09 00:00:00, 2008-05-10 00:00:00, 2008-05-13 00:00:00, 2008-05-03 00:00:00, 2008-05-02 00:00:00, 2008-05-07 00:00:00\nPhysician : 7, 6, 3\nAssistingNurse : 102, 101, 105, 103\n*/\n" }, { "role": "user", "content": "Find the name of airline which runs the most number of routes." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines, routes.\nFrom these tables, I'll be using the following columns: airlines.name, airlines.alid, routes.alid.\nThe SQL query I'll be generating is:\nSELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.name 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 \"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 screen_mode (\n\t\"Graphics_mode\" REAL, \n\t\"Char_cells\" TEXT, \n\t\"Pixels\" TEXT, \n\t\"Hardware_colours\" REAL, \n\tused_kb REAL, \n\tmap TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"Graphics_mode\")\n)\n/*\nColumns in screen_mode and all categories for low cardinality columns :\nGraphics_mode : 3.0, 1.0, 0.0, 2.0, 6.0, 4.0, 5.0\nChar_cells : 40 × 32, 20 × 32, 80 × 25, 40 × 25, 80 × 32\nPixels : 320 × 200, 640 × 200, 320 × 256, 640 × 256, 160 × 256\nHardware_colours : 8.0, 2.0, 4.0\nused_kb : 8.0, 10.0, 16.0, 20.0\nmap : 4000–7FFF, 3000–7FFF, 5800–7FFF, 6000–7FFF\nType : Text, Graphics\n*/\n \nCREATE TABLE \"Investors\" (\n\tinvestor_id INTEGER, \n\t\"Investor_details\" VARCHAR(255), \n\tPRIMARY KEY (investor_id)\n)\n/*\nColumns in Investors and 3 examples in each column for high cardinality columns :\ninvestor_id : 17, 9, 16\nInvestor_details : d, t, b\n*/\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 film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\n*/\n \nCREATE TABLE race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 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 aircraft (\n\t\"Aircraft_ID\" INTEGER, \n\t\"Order_Year\" INTEGER, \n\t\"Manufacturer\" TEXT, \n\t\"Model\" TEXT, \n\t\"Fleet_Series\" TEXT, \n\t\"Powertrain\" TEXT, \n\t\"Fuel_Propulsion\" TEXT, \n\tPRIMARY KEY (\"Aircraft_ID\")\n)\n/*\nColumns in aircraft and all categories for low cardinality columns :\nAircraft_ID : 1, 2, 5, 7, 4, 6, 3\nOrder_Year : 1992, 2000, 1996, 2002, 1998, 2011, 2010\nManufacturer : NFI, Gillig\nModel : C40LFR, GE40LFR, Phantom (High Floor), Advantage (Low Floor)\nFleet_Series : 310-329 (20), 465-467 (3), 468-473 (6), 444-464 (21), 474-481 (8), 300-309 (10), 482-492 (11)\nPowertrain : Cummins Westport ISL-G Allison WB-400R, Cummins ISC Allison WB-400R, DD S50 Allison WB-400R, Cummins ISL Allison WB-400R, Ford Triton V10 ISE-Thundervolt TB40-HG, DD S50EGR Allison WB-400R\nFuel_Propulsion : Hybrid, Diesel, CNG\n*/\n \nCREATE TABLE film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\n*/\n \nCREATE TABLE \"Artist\" (\n\t\"ArtistId\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(120) DEFAULT NULL, \n\tPRIMARY KEY (\"ArtistId\")\n)\n/*\nColumns in Artist and 3 examples in each column for high cardinality columns :\nArtistId : 87, 56, 65\nName : Smashing Pumpkins, Santana Feat. Eric Clapton, Godsmack\n*/\n\n \nCREATE TABLE \"Complaints\" (\n\tcomplaint_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\tcomplaint_outcome_code VARCHAR(20) NOT NULL, \n\tcomplaint_status_code VARCHAR(20) NOT NULL, \n\tcomplaint_type_code VARCHAR(20) NOT NULL, \n\tdate_complaint_raised DATETIME, \n\tdate_complaint_closed DATETIME, \n\tstaff_id INTEGER NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Complaints and 3 examples in each column for high cardinality columns :\ncomplaint_id : 1, 11, 2\n*/\n/*\nColumns in Complaints and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\ncustomer_id : 120, 114, 113, 116, 117, 115, 118\ncomplaint_outcome_code : OK\ncomplaint_status_code : Open, Closed, New\ncomplaint_type_code : Product Failure, Product Unusable\ndate_complaint_raised : 2006-10-29 07:08:46, 2002-07-18 10:59:35, 1977-08-06 00:31:19, 1987-07-11 14:40:30, 1973-02-10 22:55:56, 2007-10-14 21:50:43\ndate_complaint_closed : 2013-09-14 02:59:10, 1975-10-11 05:54:30, 1970-10-14 00:57:25, 1976-04-19 11:03:06, 1995-09-11 14:48:46, 2000-08-17 17:02:48\nstaff_id : 120, 114, 116, 117, 115, 118\n*/\n \nCREATE TABLE \"Plays_Games\" (\n\t\"StuID\" INTEGER, \n\t\"GameID\" INTEGER, \n\t\"Hours_Played\" INTEGER, \n\tFOREIGN KEY(\"GameID\") REFERENCES \"Video_Games\" (\"GameID\"), \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\")\n)\n/*\nColumns in Plays_Games and all categories for low cardinality columns :\nStuID : 1007, 1008, 1032, 1010, 1001\nGameID : 1, 2, 5, 4, 6, 3\nHours_Played : 1, 100, 10, 1000, 50, 47, 15, 1337, 35\n*/\n \nCREATE TABLE instructor (\n\t\"ID\" VARCHAR(5), \n\tname VARCHAR(20) NOT NULL, \n\tdept_name VARCHAR(20), \n\tsalary NUMERIC(8, 2), \n\tPRIMARY KEY (\"ID\"), \n\tFOREIGN KEY(dept_name) REFERENCES department (dept_name), \n\tCHECK (salary > 29000)\n)\n/*\nColumns in instructor and 3 examples in each column for high cardinality columns :\nID : 99052, 6569, 79081\nname : McKinnon, Sarkar, Vicentino\ndept_name : Marketing, Comp. Sci., Statistics\nsalary : 43770.36, 35023.18, 117836.50\n*/\n\n \nCREATE TABLE device (\n\t\"Device_ID\" INTEGER, \n\t\"Device\" TEXT, \n\t\"Carrier\" TEXT, \n\t\"Package_Version\" TEXT, \n\t\"Applications\" TEXT, \n\t\"Software_Platform\" TEXT, \n\tPRIMARY KEY (\"Device_ID\")\n)\n/*\nColumns in device and all categories for low cardinality columns :\nDevice_ID : 1, 2, 5, 4, 6, 3\nDevice : Huawei, Galaxy, Apple, Xiaomi, BlackBerry Storm 9530, Samsung\nCarrier : MTS Mobility, Bell Mobility, Telus Mobility, Vodafone AU, Verizon Wireless, Iusacell\nPackage_Version : 4.7.0.208, 5.0.0.742, 5.0.0.808, 5.0.0.328, 5.0.0.419\nApplications : 4.7.0.151, 5.0.0.451, 5.0.0.328, 5.0.0.419\nSoftware_Platform : iOS, Android\n*/\n" }, { "role": "user", "content": "What is the name of the airline with the most routes?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airlines, routes.\nFrom these tables, I'll be using the following columns: airlines.name, airlines.alid, routes.alid.\nThe SQL query I'll be generating is:\nSELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.name 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 status (\n\t\"statusId\" INTEGER, \n\tstatus TEXT, \n\tPRIMARY KEY (\"statusId\")\n)\n/*\nColumns in status and 3 examples in each column for high cardinality columns :\nstatusId : 87, 56, 65\nstatus : Safety concerns, Suspension, Spark plugs\n*/\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 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 \"Player\" (\n\t\"pID\" NUMERIC(5, 0) NOT NULL, \n\t\"pName\" VARCHAR(20), \n\t\"yCard\" VARCHAR(3), \n\t\"HS\" NUMERIC(5, 0), \n\tPRIMARY KEY (\"pID\")\n)\n/*\nColumns in Player and all categories for low cardinality columns :\npID : 40002, 20002, 40004, 30003, 10001, 50005\npName : Charles, Drago, Eddie, Blake, Andrew, David\nyCard : yes, no\nHS : 1600, 1200, 300, 600\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 \"Rating\" (\n\t\"rID\" INTEGER, \n\t\"mID\" INTEGER, \n\tstars INTEGER, \n\t\"ratingDate\" DATE, \n\tFOREIGN KEY(\"mID\") REFERENCES \"Movie\" (\"mID\"), \n\tFOREIGN KEY(\"rID\") REFERENCES \"Reviewer\" (\"rID\")\n)\n/*\nColumns in Rating and all categories for low cardinality columns :\nrID : 201, 204, 205, 207, 206, 203, 208, 202\nmID : 108, 106, 103, 101, 104, 107\nstars : 2, 4, 5, 3\nratingDate : 2011-01-20, 2011-01-09, 2011-01-30, 2011-01-22, 2011-01-27, 2011-01-19, 2011-01-02, None, 2011-01-12, 2011-01-15\n*/\n \nCREATE TABLE aircraft (\n\taid NUMERIC(9, 0), \n\tname TEXT(30), \n\tdistance NUMERIC(6, 0), \n\tPRIMARY KEY (aid)\n)\n/*\nColumns in aircraft and 3 examples in each column for high cardinality columns :\naid : 1, 16, 13\nname : Boeing 757-300, Lockheed L1011, Airbus A319\ndistance : 2128, 6475, 8430\n*/\n\n \nCREATE TABLE \"Assessment_Notes\" (\n\tnotes_id INTEGER NOT NULL, \n\tstudent_id INTEGER, \n\tteacher_id INTEGER NOT NULL, \n\tdate_of_notes DATETIME, \n\ttext_of_notes VARCHAR(255), \n\tother_details VARCHAR(255), \n\tFOREIGN KEY(teacher_id) REFERENCES \"Teachers\" (teacher_id), \n\tFOREIGN KEY(student_id) REFERENCES \"Students\" (student_id)\n)\n/*\nColumns in Assessment_Notes and 3 examples in each column for high cardinality columns :\nnotes_id : 1, 13, 11\ndate_of_notes : 2014-01-31 02:05:02, 2014-04-28 02:07:53, 1978-04-15 04:49:18\n*/\n/*\nColumns in Assessment_Notes and all categories for low cardinality columns :\nstudent_id : 1, 3, 13, 11, 7, 4, 12, 14, 15\nteacher_id : 1, 15, 7, 6, 14, 3, 10, 9\ntext_of_notes : None\nother_details : None\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 \"Bookings_Services\" (\n\t\"Order_ID\" INTEGER NOT NULL, \n\t\"Product_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Order_ID\", \"Product_ID\"), \n\tFOREIGN KEY(\"Order_ID\") REFERENCES \"Bookings\" (\"Booking_ID\"), \n\tFOREIGN KEY(\"Product_ID\") REFERENCES \"Services\" (\"Service_ID\")\n)\n/*\nColumns in Bookings_Services and all categories for low cardinality columns :\nOrder_ID : 1, 13, 5, 7, 8, 4, 12, 14, 9\nProduct_ID : 640, 630, 779, 525, 396, 773, 414, 597, 191\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 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 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 aircraft (\n\taid NUMERIC(9, 0), \n\tname TEXT(30), \n\tdistance NUMERIC(6, 0), \n\tPRIMARY KEY (aid)\n)\n/*\nColumns in aircraft and 3 examples in each column for high cardinality columns :\naid : 1, 16, 13\nname : Boeing 757-300, Lockheed L1011, Airbus A319\ndistance : 2128, 6475, 8430\n*/\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 \"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 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 \"Documents\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Document_Type_Code\" CHAR(15) NOT NULL, \n\t\"Project_ID\" INTEGER NOT NULL, \n\t\"Document_Date\" DATETIME, \n\t\"Document_Name\" VARCHAR(255), \n\t\"Document_Description\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Document_Type_Code\") REFERENCES \"Ref_Document_Types\" (\"Document_Type_Code\"), \n\tFOREIGN KEY(\"Project_ID\") REFERENCES \"Projects\" (\"Project_ID\")\n)\n/*\nColumns in Documents and 3 examples in each column for high cardinality columns :\nDocument_ID : 121, 300, 240\nDocument_Date : 2007-09-26 02:39:11, 1981-11-29 10:23:01, 1970-01-30 10:53:35\nDocument_Name : Katheryn statement, Review on UK files, Noel CV\n*/\n/*\nColumns in Documents and all categories for low cardinality columns :\nDocument_Type_Code : FM, BK, PP, CV\nProject_ID : 195, 30, 134, 105, 35\nDocument_Description : None\nOther_Details : None\n*/\n" }, { "role": "user", "content": "Find the busiest source airport that runs most number of routes in China." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.src_apid, airports.country.\nThe SQL query I'll be generating is:\nSELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name 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 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 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 \"Courses\" (\n\tcourse_id VARCHAR(100) NOT NULL, \n\tcourse_name VARCHAR(120), \n\tcourse_description VARCHAR(255), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (course_id)\n)\n/*\nColumns in Courses and all categories for low cardinality columns :\ncourse_id : 303, 305, 304, 306, 302, 301\ncourse_name : data structure, English, French, statistics, database, Art history\ncourse_description : data structure, English, French, statistics, database, Art history\nother_details : None\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE countries (\n\t\"COUNTRY_ID\" VARCHAR(2) NOT NULL, \n\t\"COUNTRY_NAME\" VARCHAR(40) DEFAULT NULL, \n\t\"REGION_ID\" DECIMAL(10, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"COUNTRY_ID\"), \n\tFOREIGN KEY(\"REGION_ID\") REFERENCES regions (\"REGION_ID\")\n)\n/*\nColumns in countries and 3 examples in each column for high cardinality columns :\nCOUNTRY_ID : AR, JP, DE\nCOUNTRY_NAME : Israel, Australia, India\n*/\n/*\nColumns in countries and all categories for low cardinality columns :\nREGION_ID : 1, 2, 4, 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 \"CHECKING\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in CHECKING and all categories for low cardinality columns :\ncustid : 1, 2, 5, 7, 4, 6, 3\nbalance : 3000.0, 10000.0, 2000.0, 7.0, 7000.0, 77.0\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 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 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 \"Accounts\" (\n\t\"Account_ID\" INTEGER NOT NULL, \n\t\"Statement_ID\" INTEGER NOT NULL, \n\t\"Account_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Account_ID\"), \n\tFOREIGN KEY(\"Statement_ID\") REFERENCES \"Statements\" (\"Statement_ID\")\n)\n/*\nColumns in Accounts and 3 examples in each column for high cardinality columns :\nAccount_ID : 321, 427, 240\nAccount_Details : 12223.93, 6352.31, 930.14\n*/\n/*\nColumns in Accounts and all categories for low cardinality columns :\nStatement_ID : 192, 57\n*/\n \nCREATE TABLE \"Ref_Colors\" (\n\tcolor_code VARCHAR(15), \n\tcolor_description VARCHAR(80), \n\tPRIMARY KEY (color_code)\n)\n/*\nColumns in Ref_Colors and all categories for low cardinality columns :\ncolor_code : 1, 2, 5, 7, 8, 4, 3, 9\ncolor_description : blue, green, gray, red, black, yellow, purple, white\n*/\n \nCREATE TABLE \"Students\" (\n\tstudent_id INTEGER, \n\taddress_id INTEGER NOT NULL, \n\tfirst_name VARCHAR(80), \n\tmiddle_name VARCHAR(40), \n\tlast_name VARCHAR(40), \n\tcell_mobile_number VARCHAR(40), \n\temail_address VARCHAR(40), \n\tdate_first_rental DATETIME, \n\tdate_left_university DATETIME, \n\tother_student_details VARCHAR(255), \n\tPRIMARY KEY (student_id), \n\tFOREIGN KEY(address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in Students and 3 examples in each column for high cardinality columns :\nstudent_id : 1, 13, 11\naddress_id : 1, 20, 2\nfirst_name : Louvenia, Isac, Emma\nmiddle_name : Gardner, Crystal, Cleta\nlast_name : Huels, Weimann, Fadel\ncell_mobile_number : 1-247-673-8446, 235.899.9744, 1-751-162-9676x115\nemail_address : frederique.mante@example.org, gbeatty@example.com, foster.zemlak@example.com\ndate_first_rental : 2017-07-20 18:20:27, 2017-12-05 15:20:04, 2017-05-24 05:00:18\ndate_left_university : 2018-03-03 03:33:05, 2018-03-12 15:05:53, 2018-03-15 01:47:11\n*/\n/*\nColumns in Students and all categories for low cardinality columns :\nother_student_details : None, first honor\n*/\n \nCREATE TABLE grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\n*/\n \nCREATE TABLE \"Institution\" (\n\t\"Institution_id\" TEXT, \n\t\"Institution\" TEXT, \n\t\"Location\" TEXT, \n\t\"Founded\" REAL, \n\t\"Type\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"Team\" TEXT, \n\t\"Primary_Conference\" TEXT, \n\tbuilding_id TEXT, \n\tPRIMARY KEY (\"Institution_id\"), \n\tFOREIGN KEY(building_id) REFERENCES building (building_id)\n)\n/*\nColumns in Institution and 3 examples in each column for high cardinality columns :\nInstitution_id : 1, 2, 5\nInstitution : Ave Maria University, Lindenwood University–Belleville, Point University\nLocation : Mayville, North Dakota, Jacksonville, Florida, Babson Park, Florida\nEnrollment : 967, 616, 3102\nTeam : Gyrenes, Comets, Warriors\n*/\n/*\nColumns in Institution and all categories for low cardinality columns :\nFounded : 1937.0, 1881.0, 1927.0, 2003.0, 1883.0, 1866.0, 1998.0, 1884.0, 1889.0, 1890.0\nType : Public, Tribal, Private\nPrimary_Conference : MCAC, CalPac, Gulf Coast (GCAC), AAC, none, The Sun\nbuilding_id : 1, 2, 5, 7, 4, 3, 0\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 airport (\n\t\"Airport_ID\" INTEGER, \n\t\"Airport_Name\" TEXT, \n\t\"Total_Passengers\" REAL, \n\t\"%_Change_2007\" TEXT, \n\t\"International_Passengers\" REAL, \n\t\"Domestic_Passengers\" REAL, \n\t\"Transit_Passengers\" REAL, \n\t\"Aircraft_Movements\" REAL, \n\t\"Freight_Metric_Tonnes\" REAL, \n\tPRIMARY KEY (\"Airport_ID\")\n)\n/*\nColumns in airport and all categories for low cardinality columns :\nAirport_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nAirport_Name : Bristol, London Luton, East Midlands, Birmingham Airport, Glasgow International, London Stansted, London Heathrow, London Gatwick, Edinburgh, Manchester\nTotal_Passengers : 8178891.0, 5620673.0, 34205887.0, 9627589.0, 67054745.0, 6267114.0, 10180734.0, 21219195.0, 22360364.0, 9006702.0\n%_Change_2007 : 2.6%, 4.0%, 6.0%, 1.5%, 0.5%, 5.7%, 2.9%, 4.3%, 3.8%, 7.0%\nInternational_Passengers : 3711140.0, 8105162.0, 3943139.0, 19996947.0, 5057051.0, 4870184.0, 8853224.0, 61344438.0, 30431051.0, 18119230.0\nDomestic_Passengers : 746094.0, 5562516.0, 1171605.0, 2943719.0, 1471538.0, 4192121.0, 3730963.0, 1320678.0, 2343428.0, 5281038.0\nTransit_Passengers : 156246.0, 50889.0, 6832.0, 19989.0, 43873.0, 43631.0, 14524.0, 38458.0, 4395.0, 147791.0\nAircraft_Movements : 478693.0, 117859.0, 204610.0, 193282.0, 125550.0, 76517.0, 112227.0, 100087.0, 93038.0, 263653.0\nFreight_Metric_Tonnes : 3.0, 261507.0, 12418.0, 40518.0, 197738.0, 141781.0, 107702.0, 3546.0, 12192.0, 1397054.0\n*/\n" }, { "role": "user", "content": "What is the name of the airport with the most number of routes that start in China?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.src_apid, airports.country.\nThe SQL query I'll be generating is:\nSELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name 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 book_club (\n\tbook_club_id INTEGER, \n\t\"Year\" INTEGER, \n\t\"Author_or_Editor\" TEXT, \n\t\"Book_Title\" TEXT, \n\t\"Publisher\" TEXT, \n\t\"Category\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (book_club_id)\n)\n/*\nColumns in book_club and 3 examples in each column for high cardinality columns :\nbook_club_id : 1, 11, 2\nAuthor_or_Editor : Dolores Klaich, Antoinette Azolakov, Sandy Bayer\nBook_Title : Lessons In Murder, Somewhere in the Night, Mundaneӳ World\n*/\n/*\nColumns in book_club and all categories for low cardinality columns :\nYear : 1989, 1990\nPublisher : International Polygonics, William Morrow, St. Martin's Press, Crossing Press, Alyson, Naiad Press, Banned Books, Mysterious Press\nCategory : Lesb. M/SF, Gay SF/F, Gay M/SF\nResult : Nom, Won [B ], Won, Won [A ]\n*/\n \nCREATE TABLE phone (\n\t\"Name\" TEXT, \n\t\"Phone_ID\" INTEGER, \n\t\"Memory_in_G\" INTEGER, \n\t\"Carrier\" TEXT, \n\t\"Price\" REAL, \n\tPRIMARY KEY (\"Phone_ID\")\n)\n/*\nColumns in phone and all categories for low cardinality columns :\nName : IPhone 6s, IPhone 7, IPhone X, IPhone 6, IPhone 5s\nPhone_ID : 1, 2, 5, 4, 3\nMemory_in_G : 128, 32, 16, 64\nCarrier : Sprint, TMobile\nPrice : 320.0, 1000.0, 480.0, 899.0, 699.0\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 \"Customer_Contact_Channels\" (\n\tcustomer_id INTEGER NOT NULL, \n\tchannel_code VARCHAR(15) NOT NULL, \n\tactive_from_date DATETIME NOT NULL, \n\tactive_to_date DATETIME, \n\tcontact_number VARCHAR(50) NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Customer_Contact_Channels and 3 examples in each column for high cardinality columns :\nactive_from_date : 2017-05-25 16:08:45, 2017-06-21 06:41:19, 2018-03-01 10:17:18\nactive_to_date : 2018-03-16 14:00:15, 2018-02-24 00:57:39, 2018-03-20 14:01:12\ncontact_number : 940.035.6435x0225, 846.043.4809x0426, 1-968-863-4947x96956\n*/\n/*\nColumns in Customer_Contact_Channels and all categories for low cardinality columns :\ncustomer_id : 13, 2, 5, 15, 4, 6, 14, 3, 10, 9\nchannel_code : Mobile, Email, Fax, Handheld, Cell\n*/\n \nCREATE TABLE \"Restaurant\" (\n\t\"ResID\" INTEGER, \n\t\"ResName\" VARCHAR(100), \n\t\"Address\" VARCHAR(100), \n\t\"Rating\" INTEGER, \n\tPRIMARY KEY (\"ResID\")\n)\n/*\nColumns in Restaurant and all categories for low cardinality columns :\nResID : 1, 2\nResName : Subway, Honeygrow\nAddress : 3212 St Paul St, Baltimore, MD 21218, 3233 St Paul St, Baltimore, MD 21218\nRating : 4, 3\n*/\n \nCREATE TABLE \"Participates_in\" (\n\tstuid INTEGER, \n\tactid INTEGER, \n\tFOREIGN KEY(stuid) REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(actid) REFERENCES \"Activity\" (actid)\n)\n/*\nColumns in Participates_in and 3 examples in each column for high cardinality columns :\nstuid : 1003, 1017, 1002\nactid : 771, 782, 770\n*/\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 election (\n\t\"Election_ID\" INTEGER, \n\t\"Counties_Represented\" TEXT, \n\t\"District\" INTEGER, \n\t\"Delegate\" TEXT, \n\t\"Party\" INTEGER, \n\t\"First_Elected\" REAL, \n\t\"Committee\" TEXT, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"District\") REFERENCES county (\"County_Id\"), \n\tFOREIGN KEY(\"Party\") REFERENCES party (\"Party_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 7, 8, 4, 6, 3\nCounties_Represented : 09.1 9A, 13, 12.1 12A, 12.2 12B\nDistrict : 1, 2, 4, 3\nDelegate : Miller, Warren E. Warren E. Miller, Bobo, Elizabeth Elizabeth Bobo, Pendergrass, Shane E. Shane Pendergrass, Bates, Gail H. Gail H. Bates, DeBoy, Steven J. Sr. Steven J. DeBoy, Sr., Guzzone, Guy Guy Guzzone, Turner, Frank S. Frank S. Turner, Malone, James E. Jr. James E. Malone, Jr.\nParty : 1, 2, 7, 4, 3\nFirst_Elected : 2002.0, 2006.0, 1994.0, 2003.0\nCommittee : Environmental Matters, Economic Matters, Ways and Means, Environmental Matters (Vice-Chair), Health and Government Operations, Appropriations\n*/\n \nCREATE TABLE \"Participants_in_Events\" (\n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Participant_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Event_ID\", \"Participant_ID\"), \n\tFOREIGN KEY(\"Participant_ID\") REFERENCES \"Participants\" (\"Participant_ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES \"Events\" (\"Event_ID\")\n)\n/*\nColumns in Participants_in_Events and 3 examples in each column for high cardinality columns :\nEvent_ID : 16, 95, 13\n*/\n/*\nColumns in Participants_in_Events and all categories for low cardinality columns :\nParticipant_ID : 26, 86, 37, 90, 36, 96, 66, 63, 60, 64\n*/\n \nCREATE TABLE workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\n*/\n \nCREATE TABLE invoice_lines (\n\tid INTEGER, \n\tinvoice_id INTEGER NOT NULL, \n\ttrack_id INTEGER NOT NULL, \n\tunit_price NUMERIC(10, 2) NOT NULL, \n\tquantity INTEGER NOT NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(invoice_id) REFERENCES invoices (id), \n\tFOREIGN KEY(track_id) REFERENCES tracks (id)\n)\n/*\nColumns in invoice_lines and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\ninvoice_id : 36, 17, 21\ntrack_id : 1188, 756, 988\n*/\n/*\nColumns in invoice_lines and all categories for low cardinality columns :\nunit_price : 0.99\nquantity : 1\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 \"Complaints\" (\n\tcomplaint_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\tcomplaint_outcome_code VARCHAR(20) NOT NULL, \n\tcomplaint_status_code VARCHAR(20) NOT NULL, \n\tcomplaint_type_code VARCHAR(20) NOT NULL, \n\tdate_complaint_raised DATETIME, \n\tdate_complaint_closed DATETIME, \n\tstaff_id INTEGER NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Complaints and 3 examples in each column for high cardinality columns :\ncomplaint_id : 1, 11, 2\n*/\n/*\nColumns in Complaints and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\ncustomer_id : 120, 114, 113, 116, 117, 115, 118\ncomplaint_outcome_code : OK\ncomplaint_status_code : Open, Closed, New\ncomplaint_type_code : Product Failure, Product Unusable\ndate_complaint_raised : 2006-10-29 07:08:46, 2002-07-18 10:59:35, 1977-08-06 00:31:19, 1987-07-11 14:40:30, 1973-02-10 22:55:56, 2007-10-14 21:50:43\ndate_complaint_closed : 2013-09-14 02:59:10, 1975-10-11 05:54:30, 1970-10-14 00:57:25, 1976-04-19 11:03:06, 1995-09-11 14:48:46, 2000-08-17 17:02:48\nstaff_id : 120, 114, 116, 117, 115, 118\n*/\n \nCREATE TABLE \"Plays_Games\" (\n\t\"StuID\" INTEGER, \n\t\"GameID\" INTEGER, \n\t\"Hours_Played\" INTEGER, \n\tFOREIGN KEY(\"GameID\") REFERENCES \"Video_Games\" (\"GameID\"), \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\")\n)\n/*\nColumns in Plays_Games and all categories for low cardinality columns :\nStuID : 1007, 1008, 1032, 1010, 1001\nGameID : 1, 2, 5, 4, 6, 3\nHours_Played : 1, 100, 10, 1000, 50, 47, 15, 1337, 35\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 \"Document_Drafts\" (\n\tdocument_id INTEGER NOT NULL, \n\tdraft_number INTEGER NOT NULL, \n\tdraft_details VARCHAR(255), \n\tPRIMARY KEY (document_id, draft_number), \n\tFOREIGN KEY(document_id) REFERENCES \"Documents\" (document_id)\n)\n/*\nColumns in Document_Drafts and 3 examples in each column for high cardinality columns :\ndocument_id : 1, 13, 20\ndraft_number : 1, 16, 20\ndraft_details : m, b, e\n*/\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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE \"Participates_in\" (\n\tstuid INTEGER, \n\tactid INTEGER, \n\tFOREIGN KEY(stuid) REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(actid) REFERENCES \"Activity\" (actid)\n)\n/*\nColumns in Participates_in and 3 examples in each column for high cardinality columns :\nstuid : 1003, 1017, 1002\nactid : 771, 782, 770\n*/\n\n" }, { "role": "user", "content": "Find the busiest destination airport that runs most number of routes in China." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.dst_apid, airports.country.\nThe SQL query I'll be generating is:\nSELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.country = 'China' GROUP BY T1.name 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 \"Player\" (\n\t\"pID\" NUMERIC(5, 0) NOT NULL, \n\t\"pName\" VARCHAR(20), \n\t\"yCard\" VARCHAR(3), \n\t\"HS\" NUMERIC(5, 0), \n\tPRIMARY KEY (\"pID\")\n)\n/*\nColumns in Player and all categories for low cardinality columns :\npID : 40002, 20002, 40004, 30003, 10001, 50005\npName : Charles, Drago, Eddie, Blake, Andrew, David\nyCard : yes, no\nHS : 1600, 1200, 300, 600\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 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 \"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 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 employee (\n\teid NUMERIC(9, 0), \n\tname TEXT(30), \n\tsalary NUMERIC(10, 2), \n\tPRIMARY KEY (eid)\n)\n/*\nColumns in employee and 3 examples in each column for high cardinality columns :\neid : 573284895, 90873519, 552455318\nname : Dorthy Lewis, Jennifer Thomas, Eric Cooper\nsalary : 43001.00, 33546.00, 43723.00\n*/\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 people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Age\" REAL, \n\t\"Height\" REAL, \n\t\"Hometown\" TEXT, \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, 10, 9\nName : Rosa Clarissa Ortíz Melo, Elizabeth Quiñónez Aroyo, Paul Hamm, Nadia Caba Rodríguez, Eve Tatiana Cruz Oviedo, Clary Sermina Delgado Cid, Lorraine Súarez Carmona, Ashley Pérez Cabrera, Marina Castro Medina, Endis de los Santos Álvarez\nAge : 24.0, 19.0, 21.0, 23.0, 22.0, 20.0\nHeight : 1.7, 1.76, 1.72, 1.79, 1.75, 1.71, 1.81\nHometown : Santo Domingo, La Romana, Santiago de los Caballeros, Bonao, Los Alcarrizos, Miami\n*/\n \nCREATE TABLE \"Student_Addresses\" (\n\tstudent_id INTEGER NOT NULL, \n\taddress_id INTEGER NOT NULL, \n\tdate_address_from DATETIME NOT NULL, \n\tdate_address_to DATETIME, \n\tmonthly_rental DECIMAL(19, 4), \n\tother_details VARCHAR(255), \n\tFOREIGN KEY(student_id) REFERENCES \"Students\" (student_id), \n\tFOREIGN KEY(address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in Student_Addresses and 3 examples in each column for high cardinality columns :\nstudent_id : 1, 13, 11\naddress_id : 1, 16, 13\ndate_address_from : 2017-09-23 05:16:17, 2017-03-29 18:22:55, 2017-09-10 19:41:10\ndate_address_to : 2018-03-05 21:12:37, 2018-03-07 04:29:28, 2018-03-14 09:12:05\nmonthly_rental : 1032.8717, 1007.2597, 756.6745\n*/\n/*\nColumns in Student_Addresses and all categories for low cardinality columns :\nother_details : house, apartment\n*/\n \nCREATE TABLE entrepreneur (\n\t\"Entrepreneur_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Company\" TEXT, \n\t\"Money_Requested\" REAL, \n\t\"Investor\" TEXT, \n\tPRIMARY KEY (\"Entrepreneur_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in entrepreneur and all categories for low cardinality columns :\nEntrepreneur_ID : 1, 2, 5, 4, 6, 3\nPeople_ID : 1, 2, 5, 8, 6, 3\nCompany : Mycorrhizal Systems, Le Beanock, Umbrolly, IV Cam, Elizabeth Galton Ltd, Grails Ltd\nMoney_Requested : 150000.0, 110000.0, 120000.0, 75000.0, 50000.0, 54000.0\nInvestor : Duncan Bannatyne, Doug Richard, Peter Jones, Rachel Elnaugh, Simon Woodroffe\n*/\n \nCREATE TABLE \"Complaints\" (\n\tcomplaint_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\tcomplaint_outcome_code VARCHAR(20) NOT NULL, \n\tcomplaint_status_code VARCHAR(20) NOT NULL, \n\tcomplaint_type_code VARCHAR(20) NOT NULL, \n\tdate_complaint_raised DATETIME, \n\tdate_complaint_closed DATETIME, \n\tstaff_id INTEGER NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Complaints and 3 examples in each column for high cardinality columns :\ncomplaint_id : 1, 11, 2\n*/\n/*\nColumns in Complaints and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\ncustomer_id : 120, 114, 113, 116, 117, 115, 118\ncomplaint_outcome_code : OK\ncomplaint_status_code : Open, Closed, New\ncomplaint_type_code : Product Failure, Product Unusable\ndate_complaint_raised : 2006-10-29 07:08:46, 2002-07-18 10:59:35, 1977-08-06 00:31:19, 1987-07-11 14:40:30, 1973-02-10 22:55:56, 2007-10-14 21:50:43\ndate_complaint_closed : 2013-09-14 02:59:10, 1975-10-11 05:54:30, 1970-10-14 00:57:25, 1976-04-19 11:03:06, 1995-09-11 14:48:46, 2000-08-17 17:02:48\nstaff_id : 120, 114, 116, 117, 115, 118\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\torder_quantity VARCHAR(80), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\norder_id : 13, 11, 5\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 13, 11, 2, 5, 4, 6, 12, 3, 15, 9\norder_quantity : 2, 5, 7, 8, 4, 3, 9, male\n*/\n \nCREATE TABLE \"Product_Characteristics\" (\n\tproduct_id INTEGER NOT NULL, \n\tcharacteristic_id INTEGER NOT NULL, \n\tproduct_characteristic_value VARCHAR(50), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(characteristic_id) REFERENCES \"Characteristics\" (characteristic_id)\n)\n/*\nColumns in Product_Characteristics and all categories for low cardinality columns :\nproduct_id : 1, 13, 11, 5, 7, 8, 6, 12, 14\ncharacteristic_id : 13, 10, 11, 2, 4, 6, 12, 3, 15\nproduct_characteristic_value : high, low, medium\n*/\n \nCREATE TABLE round (\n\t\"Round_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Decoration_Theme\" TEXT, \n\t\"Rank_in_Round\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\", \"Round_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in round and all categories for low cardinality columns :\nRound_ID : 1, 2\nMember_ID : 1, 2, 4, 6, 10, 9\nDecoration_Theme : Dark Nights, Summer, Walk on the Moon, Sweetie, Soft Dream, Happiness\nRank_in_Round : 1, 2, 4, 3\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 \"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 routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Date_of_Birth\" TEXT, \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\nName : Fabrizio Buonocore, Goran Fiorentini, Francesco Postiglione, Alberto Angelini, Leonardo Binchi, Marco Gerini, Roberto Calcaterra, Maurizio Felugo\nHeight : 1.9, 1.86, 1.72, 1.75, 1.95, 1.78, 1.82, 1.83\nWeight : 45.0, 89.0, 67.0, 58.0, 57.0, 75.0, 76.0, 80.0\nDate_of_Birth : 1975-08-27, 1971-08-05, 1972-04-29, 1977-04-28, 1981-03-04, 1972-02-06, 1981-11-21, 1974-09-28\n*/\n" }, { "role": "user", "content": "What is the name of the airport that is the destination of the most number of routes that start in China?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: airports, routes.\nFrom these tables, I'll be using the following columns: airports.name, airports.apid, routes.dst_apid, airports.country.\nThe SQL query I'll be generating is:\nSELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.country = 'China' GROUP BY T1.name 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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\n*/\n \nCREATE TABLE \"Stores\" (\n\t\"Store_ID\" VARCHAR(100) NOT NULL, \n\t\"Address_ID\" INTEGER 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 (\"Store_ID\"), \n\tFOREIGN KEY(\"Address_ID\") REFERENCES \"Addresses\" (\"Address_ID\"), \n\tFOREIGN KEY(\"Marketing_Region_Code\") REFERENCES \"Marketing_Regions\" (\"Marketing_Region_Code\"), \n\tUNIQUE (\"Store_ID\")\n)\n/*\nColumns in Stores and all categories for low cardinality columns :\nStore_ID : 518, 229, 150, 236, 291, 444, 231, 512, 421, 344\nAddress_ID : 230, 110, 192, 266, 286, 74, 369\nMarketing_Region_Code : FR, IN, CN, ES, RU, CA\nStore_Name : Rob Dinning, Fred Dinning, FJA Filming, Carmol Photo, Ewi Filming, Adam Photo, Shery Photo, Lur Photo, Adan Dinning, FK Filming\nStore_Phone : +65(1)3590790358, 127.870.0753x54565, (941)444-7666x7089, 896-931-9633x869, 086-705-8793, 893-457-3102x4293, 605-319-8245, +46(1)1411714927, 1-678-902-9434x1148, 1-327-185-9368\nStore_Email_Address : fkuvalis@example.net, frederik37@example.org, rborer@example.org, carmel04@example.com, adams.miles@example.net, ewisoky@example.org, shirley07@example.net, adan93@example.com, lurline24@example.org, fjacobson@example.com\nOther_Details : None, 5 stars, 3 stars, 4 stars\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"Customers\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Customer_Details\" VARCHAR(255) NOT NULL, \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_Details : Miss Felicita Reichel, Selena Gerhold, Mrs. Liza Heller V\n*/\n\n \nCREATE TABLE \"Lessons\" (\n\tlesson_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tlesson_status_code VARCHAR(15) NOT NULL, \n\tstaff_id INTEGER, \n\tvehicle_id INTEGER NOT NULL, \n\tlesson_date DATETIME, \n\tlesson_time VARCHAR(10), \n\tprice DOUBLE, \n\tPRIMARY KEY (lesson_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id), \n\tFOREIGN KEY(vehicle_id) REFERENCES \"Vehicles\" (vehicle_id)\n)\n/*\nColumns in Lessons and 3 examples in each column for high cardinality columns :\nlesson_id : 1, 13, 11\nlesson_date : 2018-03-03 15:10:16, 2018-03-07 16:12:36, 2018-03-08 16:05:05\nprice : 306.0, 492.0, 446.0\n*/\n/*\nColumns in Lessons and all categories for low cardinality columns :\ncustomer_id : 13, 11, 2, 5, 8, 6, 3, 10, 9\nlesson_status_code : Completed, Cancelled\nstaff_id : 1, 11, 5, 8, 4, 14, 3, 12, 15\nvehicle_id : 1, 2, 3\nlesson_time : 2, 5, 4, 6, 3, 9\n*/\n \nCREATE TABLE phone (\n\t\"Name\" TEXT, \n\t\"Phone_ID\" INTEGER, \n\t\"Memory_in_G\" INTEGER, \n\t\"Carrier\" TEXT, \n\t\"Price\" REAL, \n\tPRIMARY KEY (\"Phone_ID\")\n)\n/*\nColumns in phone and all categories for low cardinality columns :\nName : IPhone 6s, IPhone 7, IPhone X, IPhone 6, IPhone 5s\nPhone_ID : 1, 2, 5, 4, 3\nMemory_in_G : 128, 32, 16, 64\nCarrier : Sprint, TMobile\nPrice : 320.0, 1000.0, 480.0, 899.0, 699.0\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 \"constructorResults\" (\n\t\"constructorResultsId\" INTEGER, \n\t\"raceId\" INTEGER, \n\t\"constructorId\" INTEGER, \n\tpoints REAL, \n\tstatus TEXT, \n\tPRIMARY KEY (\"constructorResultsId\"), \n\tFOREIGN KEY(\"constructorId\") REFERENCES constructors (\"constructorId\"), \n\tFOREIGN KEY(\"raceId\") REFERENCES races (\"raceId\")\n)\n/*\nColumns in constructorResults and 3 examples in each column for high cardinality columns :\nconstructorResultsId : 87, 56, 65\nraceId : 36, 21, 35\nconstructorId : 1, 11, 2\npoints : 8.0, 3.0, 16.0\n*/\n/*\nColumns in constructorResults and all categories for low cardinality columns :\nstatus : NULL, D\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Claims\" (\n\t\"Claim_ID\" INTEGER NOT NULL, \n\t\"Policy_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\tPRIMARY KEY (\"Claim_ID\"), \n\tFOREIGN KEY(\"Policy_ID\") REFERENCES \"Customer_Policies\" (\"Policy_ID\")\n)\n/*\nColumns in Claims and 3 examples in each column for high cardinality columns :\nClaim_ID : 843, 143, 563\nDate_Claim_Made : 2018-11-08, 2016-08-12, 2016-08-02\nDate_Claim_Settled : 2017-12-20, 2018-02-20, 2017-09-04\nAmount_Claimed : 49743, 70088, 46479\nAmount_Settled : 1372, 1652, 1528\n*/\n/*\nColumns in Claims and all categories for low cardinality columns :\nPolicy_ID : 858, 143, 141, 744, 473, 352, 119, 738, 552\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n" }, { "role": "user", "content": "What is the id of the most recent order?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders.\nFrom these tables, I'll be using the following columns: order_id, date_order_placed.\nThe SQL query I'll be generating is:\nSELECT order_id FROM orders ORDER BY date_order_placed 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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Plays_Games\" (\n\t\"StuID\" INTEGER, \n\t\"GameID\" INTEGER, \n\t\"Hours_Played\" INTEGER, \n\tFOREIGN KEY(\"GameID\") REFERENCES \"Video_Games\" (\"GameID\"), \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\")\n)\n/*\nColumns in Plays_Games and all categories for low cardinality columns :\nStuID : 1007, 1008, 1032, 1010, 1001\nGameID : 1, 2, 5, 4, 6, 3\nHours_Played : 1, 100, 10, 1000, 50, 47, 15, 1337, 35\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 \"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 entrepreneur (\n\t\"Entrepreneur_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Company\" TEXT, \n\t\"Money_Requested\" REAL, \n\t\"Investor\" TEXT, \n\tPRIMARY KEY (\"Entrepreneur_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in entrepreneur and all categories for low cardinality columns :\nEntrepreneur_ID : 1, 2, 5, 4, 6, 3\nPeople_ID : 1, 2, 5, 8, 6, 3\nCompany : Mycorrhizal Systems, Le Beanock, Umbrolly, IV Cam, Elizabeth Galton Ltd, Grails Ltd\nMoney_Requested : 150000.0, 110000.0, 120000.0, 75000.0, 50000.0, 54000.0\nInvestor : Duncan Bannatyne, Doug Richard, Peter Jones, Rachel Elnaugh, Simon Woodroffe\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 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 \"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 \"Catalogs\" (\n\tcatalog_id INTEGER, \n\tcatalog_name VARCHAR(50), \n\tcatalog_publisher VARCHAR(80), \n\tdate_of_publication DATETIME, \n\tdate_of_latest_revision DATETIME, \n\tPRIMARY KEY (catalog_id)\n)\n/*\nColumns in Catalogs and all categories for low cardinality columns :\ncatalog_id : 1, 2, 5, 7, 8, 4, 6, 3\ncatalog_name : Coffee Bean, Latte, Sparkling Water, Breakfast Tea, Jam, Lemonade, Chocolate, Coco powder\ncatalog_publisher : Russel-Gislason Lemon shop, Lidl, Koepp-Rutherford handmade chocolate store, Murray Coffee shop, Grady & Kautzer\ndate_of_publication : 2012-04-13 06:37:09, 2011-07-22 04:57:19, 2013-03-15 05:09:17, 2012-11-27 19:29:22\ndate_of_latest_revision : 2017-03-30 09:15:37, 2017-10-26 01:16:51, 2017-09-26 12:10:36, 2017-12-04 06:48:13\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 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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 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 \"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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE furniture (\n\t\"Furniture_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Num_of_Component\" INTEGER, \n\t\"Market_Rate\" REAL, \n\tPRIMARY KEY (\"Furniture_ID\")\n)\n/*\nColumns in furniture and all categories for low cardinality columns :\nFurniture_ID : 1, 2, 5, 7, 4, 6, 3\nName : Dining set, Chabudai, Billiard table, Hatstand, Bookcase, Four-poster bed, Bench\nNum_of_Component : 5, 4, 6, 14, 3, 12\nMarket_Rate : 1.0, 3.5, 52.5, 0.5, 40.0, 2.0\n*/\n \nCREATE TABLE member (\n\t\"Member_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Country\" TEXT, \n\t\"College_ID\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\"), \n\tFOREIGN KEY(\"College_ID\") REFERENCES college (\"College_ID\")\n)\n/*\nColumns in member and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Tom Weiskopf, Tom Watson, Pat Fitzsimons, Homero Blancas, Jack Nicklaus, Billy Casper, J. C. Snead, Arnold Palmer, Lee Trevino, Bobby Nichols\nCountry : United States, Canada\nCollege_ID : 1, 2, 5, 4, 3\n*/\n" }, { "role": "user", "content": "Find the id of the order made most recently." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders.\nFrom these tables, I'll be using the following columns: order_id, date_order_placed.\nThe SQL query I'll be generating is:\nSELECT order_id FROM orders ORDER BY date_order_placed 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 \"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 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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"View_Product_Availability\" (\n\tproduct_id INTEGER NOT NULL, \n\tbooking_id INTEGER NOT NULL, \n\tstatus_date DATETIME, \n\tavailable_yn VARCHAR(1), \n\tPRIMARY KEY (status_date), \n\tFOREIGN KEY(product_id) REFERENCES \"Products_for_Hire\" (product_id), \n\tFOREIGN KEY(booking_id) REFERENCES \"Bookings\" (booking_id)\n)\n/*\nColumns in View_Product_Availability and all categories for low cardinality columns :\nproduct_id : 1, 2, 5, 3\nbooking_id : 11, 5\nstatus_date : 2018-03-18 05:25:55, 2018-03-25 10:20:15, 2018-03-21 15:20:32, 2018-03-22 00:16:58\navailable_yn : 1, 0\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE happy_hour (\n\t\"HH_ID\" INTEGER, \n\t\"Shop_ID\" INTEGER, \n\t\"Month\" TEXT, \n\t\"Num_of_shaff_in_charge\" INTEGER, \n\tPRIMARY KEY (\"HH_ID\", \"Shop_ID\", \"Month\"), \n\tFOREIGN KEY(\"Shop_ID\") REFERENCES shop (\"Shop_ID\")\n)\n/*\nColumns in happy_hour and all categories for low cardinality columns :\nHH_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nShop_ID : 1, 2, 5, 3, 10\nMonth : June, May, April, July\nNum_of_shaff_in_charge : 5, 15, 4, 12, 3, 10\n*/\n \nCREATE TABLE \"CHECKING\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in CHECKING and all categories for low cardinality columns :\ncustid : 1, 2, 5, 7, 4, 6, 3\nbalance : 3000.0, 10000.0, 2000.0, 7.0, 7000.0, 77.0\n*/\n \nCREATE TABLE \"Participates_in\" (\n\tstuid INTEGER, \n\tactid INTEGER, \n\tFOREIGN KEY(stuid) REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(actid) REFERENCES \"Activity\" (actid)\n)\n/*\nColumns in Participates_in and 3 examples in each column for high cardinality columns :\nstuid : 1003, 1017, 1002\nactid : 771, 782, 770\n*/\n\n \nCREATE TABLE bridge (\n\tarchitect_id INTEGER, \n\tid INTEGER, \n\tname TEXT, \n\tlocation TEXT, \n\tlength_meters REAL, \n\tlength_feet REAL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(architect_id) REFERENCES architect (id)\n)\n/*\nColumns in bridge and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nname : Xian Ren Qiao (Fairy Bridge), Hazarchishma Natural Bridge, Stevens Arch\nlocation : Guizhou , China, Natural Bridges National Monument , Utah , USA, Dinosaur National Monument , Colorado , USA\nlength_meters : 64.2, 69.0, 67.0\nlength_feet : 290.0, 225.0, 400.0\n*/\n/*\nColumns in bridge and all categories for low cardinality columns :\narchitect_id : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"Behavior_Incident\" (\n\tincident_id INTEGER, \n\tincident_type_code VARCHAR(10) NOT NULL, \n\tstudent_id INTEGER NOT NULL, \n\tdate_incident_start DATETIME, \n\tdate_incident_end DATETIME, \n\tincident_summary VARCHAR(255), \n\trecommendations VARCHAR(255), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (incident_id), \n\tFOREIGN KEY(student_id) REFERENCES \"Students\" (student_id), \n\tFOREIGN KEY(incident_type_code) REFERENCES \"Ref_Incident_Type\" (incident_type_code)\n)\n/*\nColumns in Behavior_Incident and 3 examples in each column for high cardinality columns :\nincident_id : 1, 13, 11\nstudent_id : 1, 13, 11\ndate_incident_start : 2018-01-31 10:51:13, 2017-08-27 03:21:30, 2017-05-02 12:52:09\ndate_incident_end : 2018-03-22 02:10:35, 2018-03-06 14:44:37, 2018-03-16 14:37:20\n*/\n/*\nColumns in Behavior_Incident and all categories for low cardinality columns :\nincident_type_code : VIOLENCE, DISTURB, NOISE\nincident_summary : None\nrecommendations : None, Transfer schools\nother_details : None\n*/\n \nCREATE TABLE gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\n*/\n \nCREATE TABLE \"Customer_Addresses\" (\n\tcustomer_id INTEGER NOT NULL, \n\taddress_id INTEGER NOT NULL, \n\tdate_from DATETIME NOT NULL, \n\tdate_to DATETIME, \n\tPRIMARY KEY (customer_id, address_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(address_id) REFERENCES \"Addresses\" (address_id)\n)\n/*\nColumns in Customer_Addresses and 3 examples in each column for high cardinality columns :\ndate_from : 2018-01-07 13:31:08, 2017-07-31 20:18:52, 2017-08-27 13:38:37\ndate_to : 2018-03-05 21:19:53, 2018-03-22 17:22:34, 2018-03-17 15:44:10\n*/\n/*\nColumns in Customer_Addresses and all categories for low cardinality columns :\ncustomer_id : 1, 2, 7, 8, 4, 6, 12, 10\naddress_id : 13, 2, 7, 8, 4, 6, 14, 12, 10, 9\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 election (\n\t\"Election_ID\" INTEGER, \n\t\"Representative_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Votes\" REAL, \n\t\"Vote_Percent\" REAL, \n\t\"Seats\" REAL, \n\t\"Place\" REAL, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"Representative_ID\") REFERENCES representative (\"Representative_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 4, 3\nRepresentative_ID : 1, 2, 5, 7, 4\nDate : 1946, 1949, July 1942, October 1942, 1953\nVotes : 11059.0, 9423.0, 13049.0, 12422.0, 14077.0\nVote_Percent : 16.0, 19.5, 16.2, 18.5\nSeats : 10.0, 6.0, 7.0, 9.0\nPlace : 3.0, 1.0, 2.0\n*/\n" }, { "role": "user", "content": "what are the order id and customer id of the oldest order?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders.\nFrom these tables, I'll be using the following columns: order_id, customer_id, date_order_placed.\nThe SQL query I'll be generating is:\nSELECT order_id , customer_id FROM orders ORDER BY date_order_placed 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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Lots\" (\n\tlot_id INTEGER, \n\tinvestor_id INTEGER NOT NULL, \n\tlot_details VARCHAR(255), \n\tPRIMARY KEY (lot_id), \n\tFOREIGN KEY(investor_id) REFERENCES \"Investors\" (investor_id)\n)\n/*\nColumns in Lots and 3 examples in each column for high cardinality columns :\nlot_id : 1, 13, 11\n*/\n/*\nColumns in Lots and all categories for low cardinality columns :\ninvestor_id : 1, 16, 13, 20, 7, 6, 19, 10, 9\nlot_details : d, m, q, s, r, h, x, z\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 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 invoice_lines (\n\tid INTEGER, \n\tinvoice_id INTEGER NOT NULL, \n\ttrack_id INTEGER NOT NULL, \n\tunit_price NUMERIC(10, 2) NOT NULL, \n\tquantity INTEGER NOT NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(invoice_id) REFERENCES invoices (id), \n\tFOREIGN KEY(track_id) REFERENCES tracks (id)\n)\n/*\nColumns in invoice_lines and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\ninvoice_id : 36, 17, 21\ntrack_id : 1188, 756, 988\n*/\n/*\nColumns in invoice_lines and all categories for low cardinality columns :\nunit_price : 0.99\nquantity : 1\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 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 track (\n\t\"Track_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Location\" TEXT, \n\t\"Seating\" REAL, \n\t\"Year_Opened\" REAL, \n\tPRIMARY KEY (\"Track_ID\")\n)\n/*\nColumns in track and all categories for low cardinality columns :\nTrack_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Homestead-Miami Speedway, Darlington Raceway, Chicagoland Speedway, Auto Club Speedway, Phoenix International Raceway, Martinsville Speedway, Michigan International Speedway, Kansas Speedway, Daytona International Speedway\nLocation : Homestead, FL, Kansas City, KS, Brooklyn, MI, Avondale, AZ, Daytona Beach, FL, Joliet, IL, Darlington, SC, Ridgeway, VA, Fontana, CA\nSeating : 76812.0, 92000.0, 63000.0, 75000.0, 137243.0, 65000.0, 81687.0, 168000.0\nYear_Opened : 2001.0, 1947.0, 1995.0, 1968.0, 1997.0, 1964.0, 1959.0, 1950.0\n*/\n \nCREATE TABLE gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\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 language (\n\tlanguage_id INTEGER NOT NULL, \n\tname CHAR(20) NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (language_id)\n)\n/*\nColumns in language and all categories for low cardinality columns :\nlanguage_id : \nname : \nlast_update : \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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Products\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Price\" DECIMAL NOT NULL, \n\t\"Manufacturer\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Manufacturer\") REFERENCES \"Manufacturers\" (\"Code\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nCode : 1, 11, 2\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nName : Printer, Floppy disk, Memory, Monitor, Toner cartridge, CD drive, DVD burner, Hard drive, ZIP drive, DVD drive\nPrice : 150.0000000000, 120.0000000000, 90.0000000000, 5.0000000000, 270.0000000000, 180.0000000000, 66.0000000000, 240.0000000000\nManufacturer : 1, 2, 5, 4, 6, 3\n*/\n" }, { "role": "user", "content": "Find the order id and customer id associated with the oldest order." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders.\nFrom these tables, I'll be using the following columns: order_id, customer_id, date_order_placed.\nThe SQL query I'll be generating is:\nSELECT order_id , customer_id FROM orders ORDER BY date_order_placed 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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Course_Authors_and_Tutors\" (\n\tauthor_id INTEGER, \n\t\"author_tutor_ATB\" VARCHAR(3), \n\tlogin_name VARCHAR(40), \n\tpassword VARCHAR(40), \n\tpersonal_name VARCHAR(80), \n\tmiddle_name VARCHAR(80), \n\tfamily_name VARCHAR(80), \n\tgender_mf VARCHAR(1), \n\taddress_line_1 VARCHAR(80), \n\tPRIMARY KEY (author_id)\n)\n/*\nColumns in Course_Authors_and_Tutors and 3 examples in each column for high cardinality columns :\nauthor_id : 1, 13, 11\nauthor_tutor_ATB : 388, 782, 159\nlogin_name : heidenreich.ara, qking, fiona77\npassword : 2c196efe8aee23a1b9a7e752fe63029c5879af6f, cdaf6c3483f19e2253659a40a3aab786a3390f78, 120ac8a5744f5b710ecaebbd8dd1633e3e33886e\npersonal_name : Dusty, Cathrine, Shakira\nmiddle_name : Kennith, Ruthie, Joyce\nfamily_name : Treutel, Zboncak, Rowe\naddress_line_1 : 644 Montana Hill Suite 489\nDaijamouth, CA 19587-4254, 139 O'Conner Circles\nVirginieland, KS 23365, 92220 Hellen Skyway Apt. 635\nRennerview, MS 81036\n*/\n/*\nColumns in Course_Authors_and_Tutors and all categories for low cardinality columns :\ngender_mf : 1, 0\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcoupon_id INTEGER NOT NULL, \n\tgood_or_bad_customer VARCHAR(4), \n\tfirst_name VARCHAR(80), \n\tlast_name VARCHAR(80), \n\tgender_mf VARCHAR(1), \n\tdate_became_customer DATETIME, \n\tdate_last_hire DATETIME, \n\tPRIMARY KEY (customer_id), \n\tFOREIGN KEY(coupon_id) REFERENCES \"Discount_Coupons\" (coupon_id)\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\ncustomer_id : 1, 13, 11\nfirst_name : Bridget, Marilou, Jailyn\nlast_name : Little, Greenholt, Schroeder\ndate_became_customer : 2017-02-28 14:40:25, 2015-05-05 20:29:01, 2015-07-21 09:24:57\ndate_last_hire : 2018-03-04 08:59:40, 2018-03-18 17:35:43, 2018-03-13 21:20:05\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\ncoupon_id : 1, 3, 11, 2, 7, 6, 14, 12, 10\ngood_or_bad_customer : bad, good\ngender_mf : 1, 0\n*/\n \nCREATE TABLE \"Institution\" (\n\t\"Institution_id\" TEXT, \n\t\"Institution\" TEXT, \n\t\"Location\" TEXT, \n\t\"Founded\" REAL, \n\t\"Type\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"Team\" TEXT, \n\t\"Primary_Conference\" TEXT, \n\tbuilding_id TEXT, \n\tPRIMARY KEY (\"Institution_id\"), \n\tFOREIGN KEY(building_id) REFERENCES building (building_id)\n)\n/*\nColumns in Institution and 3 examples in each column for high cardinality columns :\nInstitution_id : 1, 2, 5\nInstitution : Ave Maria University, Lindenwood University–Belleville, Point University\nLocation : Mayville, North Dakota, Jacksonville, Florida, Babson Park, Florida\nEnrollment : 967, 616, 3102\nTeam : Gyrenes, Comets, Warriors\n*/\n/*\nColumns in Institution and all categories for low cardinality columns :\nFounded : 1937.0, 1881.0, 1927.0, 2003.0, 1883.0, 1866.0, 1998.0, 1884.0, 1889.0, 1890.0\nType : Public, Tribal, Private\nPrimary_Conference : MCAC, CalPac, Gulf Coast (GCAC), AAC, none, The Sun\nbuilding_id : 1, 2, 5, 7, 4, 3, 0\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 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 \"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 \"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 \"Features\" (\n\t\"Feature_ID\" INTEGER NOT NULL, \n\t\"Feature_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Feature_ID\")\n)\n/*\nColumns in Features and all categories for low cardinality columns :\nFeature_ID : 955, 543, 681, 528, 523\nFeature_Details : park, shopping, cafe, parking, garden\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Payments\" (\n\t\"Payment_ID\" INTEGER NOT NULL, \n\t\"Settlement_ID\" INTEGER NOT NULL, \n\t\"Payment_Method_Code\" VARCHAR(255), \n\t\"Date_Payment_Made\" DATE, \n\t\"Amount_Payment\" INTEGER, \n\tPRIMARY KEY (\"Payment_ID\"), \n\tFOREIGN KEY(\"Settlement_ID\") REFERENCES \"Settlements\" (\"Settlement_ID\")\n)\n/*\nColumns in Payments and 3 examples in each column for high cardinality columns :\nPayment_ID : 754, 739, 542\nDate_Payment_Made : 2017-06-24, 2017-08-06, 2017-12-16\nAmount_Payment : 423154, 155654, 71246\n*/\n/*\nColumns in Payments and all categories for low cardinality columns :\nSettlement_ID : 527, 476, 564, 983, 682, 648, 597, 512, 516\nPayment_Method_Code : Visa, Discover Card, American Express, MasterCard\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" }, { "role": "user", "content": "Find the id of the order whose shipment tracking number is \"3452\"." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: shipments.\nFrom these tables, I'll be using the following columns: order_id, shipment_tracking_number, 3452.\nThe SQL query I'll be generating is:\nSELECT order_id FROM shipments WHERE shipment_tracking_number = \"3452\"" } ]
[ { "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 \"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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"SAVINGS\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in SAVINGS and all categories for low cardinality columns :\ncustid : 1, 2, 5, 4, 6, 3\nbalance : 80000.0, 230000.0, 999999999.0, 60.0, 240.0, 200000.0\n*/\n \nCREATE TABLE \"Events\" (\n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Service_ID\" INTEGER NOT NULL, \n\t\"Event_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Event_ID\"), \n\tFOREIGN KEY(\"Service_ID\") REFERENCES \"Services\" (\"Service_ID\")\n)\n/*\nColumns in Events and 3 examples in each column for high cardinality columns :\nEvent_ID : 16, 95, 13\n*/\n/*\nColumns in Events and all categories for low cardinality columns :\nService_ID : 8, 2, 5, 6\nEvent_Details : Fail, Success\n*/\n \nCREATE TABLE film (\n\t\"Film_ID\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Studio\" TEXT, \n\t\"Director\" TEXT, \n\t\"Gross_in_dollar\" INTEGER, \n\tPRIMARY KEY (\"Film_ID\")\n)\n/*\nColumns in film and 3 examples in each column for high cardinality columns :\nFilm_ID : 1, 13, 11\nTitle : Annie, Rocky III, Tootsie\nDirector : Richard Attenborough, Nicholas Meyer, Ted Kotcheff\nGross_in_dollar : 53977250, 76606280, 125049125\n*/\n/*\nColumns in film and all categories for low cardinality columns :\nStudio : MGM, United Artists, Universal, 20th Century Fox, Columbia, Paramount, Columbia / Rastar, Paramount / Lorimar, Orion / Carolco, Universal / RKO\n*/\n \nCREATE TABLE \"Parties_in_Events\" (\n\t\"Party_ID\" INTEGER NOT NULL, \n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Role_Code\" CHAR(15), \n\tPRIMARY KEY (\"Party_ID\", \"Event_ID\"), \n\tFOREIGN KEY(\"Party_ID\") REFERENCES \"Parties\" (\"Party_ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES \"Events\" (\"Event_ID\")\n)\n/*\nColumns in Parties_in_Events and 3 examples in each column for high cardinality columns :\nEvent_ID : 1, 13, 15\n*/\n/*\nColumns in Parties_in_Events and all categories for low cardinality columns :\nParty_ID : 5, 4, 6, 3, 9\nRole_Code : Organizer, Participant\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\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 employees (\n\t\"EMPLOYEE_ID\" DECIMAL(6, 0) DEFAULT '0' NOT NULL, \n\t\"FIRST_NAME\" VARCHAR(20) DEFAULT NULL, \n\t\"LAST_NAME\" VARCHAR(25) NOT NULL, \n\t\"EMAIL\" VARCHAR(25) NOT NULL, \n\t\"PHONE_NUMBER\" VARCHAR(20) DEFAULT NULL, \n\t\"HIRE_DATE\" DATE NOT NULL, \n\t\"JOB_ID\" VARCHAR(10) NOT NULL, \n\t\"SALARY\" DECIMAL(8, 2) DEFAULT NULL, \n\t\"COMMISSION_PCT\" DECIMAL(2, 2) DEFAULT NULL, \n\t\"MANAGER_ID\" DECIMAL(6, 0) DEFAULT NULL, \n\t\"DEPARTMENT_ID\" DECIMAL(4, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"EMPLOYEE_ID\"), \n\tFOREIGN KEY(\"DEPARTMENT_ID\") REFERENCES departments (\"DEPARTMENT_ID\"), \n\tFOREIGN KEY(\"JOB_ID\") REFERENCES jobs (\"JOB_ID\")\n)\n/*\nColumns in employees and 3 examples in each column for high cardinality columns :\nEMPLOYEE_ID : 135, 187, 194\nFIRST_NAME : Randall, Adam, Susan\nLAST_NAME : Mourgos, Baida, Ande\nEMAIL : SSTILES, SMAVRIS, GHIMURO\nPHONE_NUMBER : 515.123.8080, 515.127.4563, 011.44.1346.629268\nHIRE_DATE : 1987-07-25, 1987-07-09, 1987-06-29\nJOB_ID : HR_REP, ST_MAN, AD_PRES\nSALARY : 2500.00, 8000.00, 8600.00\nMANAGER_ID : 102, 147, 122\nDEPARTMENT_ID : 110, 100, 20\n*/\n/*\nColumns in employees and all categories for low cardinality columns :\nCOMMISSION_PCT : 0.00, 0.35, 0.25, 0.10, 0.15, 0.20, 0.30, 0.40\n*/\n \nCREATE TABLE \"Department_Store_Chain\" (\n\tdept_store_chain_id INTEGER, \n\tdept_store_chain_name VARCHAR(80), \n\tPRIMARY KEY (dept_store_chain_id)\n)\n/*\nColumns in Department_Store_Chain and all categories for low cardinality columns :\ndept_store_chain_id : 1, 2, 4, 3\ndept_store_chain_name : West, East, North, South\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 \"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 : 7089 Mueller Forks, 535 Ariel Brook, 3904 Stroman Passage\ncity : Buckridgehaven, South Eugene, Elviebury\nzip_postcode : 22194, 99903, 14445\nstate_province_county : Louisiana, Kentucky, Ohio\n*/\n/*\nColumns in Addresses and all categories for low cardinality columns :\ncountry : USA\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"CHECKING\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in CHECKING and all categories for low cardinality columns :\ncustid : 1, 2, 5, 7, 4, 6, 3\nbalance : 3000.0, 10000.0, 2000.0, 7.0, 7000.0, 77.0\n*/\n \nCREATE TABLE \"Customers\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Customer_name\" VARCHAR(40), \n\tPRIMARY KEY (\"Customer_ID\")\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\nCustomer_ID : 756, 882, 562\nCustomer_name : Miss Felicita Reichel, Selena Gerhold, Mrs. Liza Heller V\n*/\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 endowment (\n\tendowment_id INTEGER, \n\t\"School_id\" INTEGER, \n\tdonator_name TEXT, \n\tamount REAL, \n\tPRIMARY KEY (endowment_id), \n\tFOREIGN KEY(\"School_id\") REFERENCES \"School\" (\"School_id\")\n)\n/*\nColumns in endowment and 3 examples in each column for high cardinality columns :\nendowment_id : 1, 11, 2\ndonator_name : Santo Domingo Este, Duarte, San Cristóbal\namount : 9.05, 8.82, 8.85\n*/\n/*\nColumns in endowment and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 7, 8, 4, 6, 3\n*/\n" }, { "role": "user", "content": "Which order's shipment tracking number is \"3452\"? Give me the id of the order." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: shipments.\nFrom these tables, I'll be using the following columns: order_id, shipment_tracking_number, 3452.\nThe SQL query I'll be generating is:\nSELECT order_id FROM shipments WHERE shipment_tracking_number = \"3452\"" } ]
[ { "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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Albums\" (\n\t\"AId\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Year\" INTEGER, \n\t\"Label\" TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"AId\")\n)\n/*\nColumns in Albums and all categories for low cardinality columns :\nAId : \nTitle : \nYear : \nLabel : \nType : \n*/\n \nCREATE TABLE regions (\n\t\"REGION_ID\" DECIMAL(5, 0) NOT NULL, \n\t\"REGION_NAME\" VARCHAR(25) DEFAULT NULL, \n\tPRIMARY KEY (\"REGION_ID\")\n)\n/*\nColumns in regions and all categories for low cardinality columns :\nREGION_ID : 1, 2, 4, 3\nREGION_NAME : Europe\\r, Middle East and Africa\\r, Asia\\r, Americas\\r\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 \"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 \"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 train (\n\t\"Train_ID\" INTEGER, \n\t\"Train_Num\" TEXT, \n\t\"Name\" TEXT, \n\t\"From\" TEXT, \n\t\"Arrival\" TEXT, \n\t\"Railway_ID\" INTEGER, \n\tPRIMARY KEY (\"Train_ID\"), \n\tFOREIGN KEY(\"Railway_ID\") REFERENCES railway (\"Railway_ID\")\n)\n/*\nColumns in train and all categories for low cardinality columns :\nTrain_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nTrain_Num : 57136, 57135, 16032, 12140, 51195, 12139, 16031, 11401, 16094\nName : Wardha-Ballarshah Pass, Nagpur-Kazipet Pass, Ballarshah-Mumbai Pass, Nandigram Exp, Lucknow-Chennai Exp, Sewagram Exp, Andaman Exp, Kazipet-Nagpur Pass\nFrom : Lucknow, Ballarshah, Nagpur, Kazipet, Mumbai CST, Jammu Tawi, Wardha, Chennai\nArrival : 23:39, 08:54, 23:44, 05:09, 09:48, 13:28, 13:04, 09:08\nRailway_ID : 1, 2, 5, 7, 3, 10, 9\n*/\n \nCREATE TABLE station (\n\tid INTEGER, \n\tnetwork_name TEXT, \n\tservices TEXT, \n\tlocal_authority TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in station and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\nnetwork_name : Chalfont & Latimer, Chorleywood, Brentwood\n*/\n/*\nColumns in station and all categories for low cardinality columns :\nservices : Greater Anglia, Metropolitan line and Chiltern Railways, Metropolitan line, c2c, London Overground and London Midland, London Overground\nlocal_authority : Three Rivers, Brentwood, Broxbourne, Thurrock, Watford, Chiltern\n*/\n \nCREATE TABLE aircraft (\n\t\"Aircraft_ID\" INTEGER, \n\t\"Order_Year\" INTEGER, \n\t\"Manufacturer\" TEXT, \n\t\"Model\" TEXT, \n\t\"Fleet_Series\" TEXT, \n\t\"Powertrain\" TEXT, \n\t\"Fuel_Propulsion\" TEXT, \n\tPRIMARY KEY (\"Aircraft_ID\")\n)\n/*\nColumns in aircraft and all categories for low cardinality columns :\nAircraft_ID : 1, 2, 5, 7, 4, 6, 3\nOrder_Year : 1992, 2000, 1996, 2002, 1998, 2011, 2010\nManufacturer : NFI, Gillig\nModel : C40LFR, GE40LFR, Phantom (High Floor), Advantage (Low Floor)\nFleet_Series : 310-329 (20), 465-467 (3), 468-473 (6), 444-464 (21), 474-481 (8), 300-309 (10), 482-492 (11)\nPowertrain : Cummins Westport ISL-G Allison WB-400R, Cummins ISC Allison WB-400R, DD S50 Allison WB-400R, Cummins ISL Allison WB-400R, Ford Triton V10 ISE-Thundervolt TB40-HG, DD S50EGR Allison WB-400R\nFuel_Propulsion : Hybrid, Diesel, CNG\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"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 works_on (\n\t\"Essn\" INTEGER, \n\t\"Pno\" INTEGER, \n\t\"Hours\" REAL, \n\tPRIMARY KEY (\"Essn\", \"Pno\")\n)\n/*\nColumns in works_on and all categories for low cardinality columns :\nEssn : 987987987, 333445555, 453453453, 666884444, 123456789, 987654321, 888665555, 999887777\nPno : 1, 20, 2, 30, 3, 10\nHours : 30.0, 15.0, 32.5, 10.0, 7.5, 40.0, 35.0, None, 20.0, 5.0\n*/\n \nCREATE TABLE \"Features\" (\n\t\"Feature_ID\" INTEGER NOT NULL, \n\t\"Feature_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Feature_ID\")\n)\n/*\nColumns in Features and all categories for low cardinality columns :\nFeature_ID : 955, 543, 681, 528, 523\nFeature_Details : park, shopping, cafe, parking, garden\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"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 \"Player\" (\n\tid INTEGER, \n\tplayer_api_id INTEGER, \n\tplayer_name TEXT, \n\tplayer_fifa_api_id INTEGER, \n\tbirthday TEXT, \n\theight INTEGER, \n\tweight INTEGER, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Player and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\nplayer_api_id : 148827, 38423, 176301\nplayer_name : Adam Ounas, Abdelmalek Cherrad, Adrian\nplayer_fifa_api_id : 197081, 211185, 184410\nbirthday : 1988-08-25 00:00:00, 1986-12-02 00:00:00, 1978-12-22 00:00:00\nheight : 172.72, 175.26, 187.96\nweight : 185, 187, 163\n*/\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n" }, { "role": "user", "content": "Find the ids of all the order items whose product id is 11." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: order_items.\nFrom these tables, I'll be using the following columns: order_item_id, product_id.\nThe SQL query I'll be generating is:\nSELECT order_item_id FROM order_items WHERE product_id = 11" } ]
[ { "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 mountain (\n\tid INTEGER, \n\tname TEXT, \n\t\"Height\" REAL, \n\t\"Prominence\" REAL, \n\t\"Range\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in mountain and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Kaka / Kecha / Chiqe, Aksouâl, Ioll / Yoll\nHeight : 4167.0, 4120.0, 4071.0\nProminence : 1540.0, 3931.0, 610.0\nRange : Toubkal Atlas, Aberdare Range, Semien Mountains\n*/\n/*\nColumns in mountain and all categories for low cardinality columns :\nCountry : Cameroon, Morocco, Kenya, Rwanda Uganda, Ethiopia\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE school_bus (\n\t\"School_ID\" INTEGER, \n\t\"Driver_ID\" INTEGER, \n\t\"Years_Working\" INTEGER, \n\t\"If_full_time\" BOOLEAN, \n\tPRIMARY KEY (\"School_ID\", \"Driver_ID\"), \n\tFOREIGN KEY(\"Driver_ID\") REFERENCES driver (\"Driver_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in school_bus and all categories for low cardinality columns :\nSchool_ID : 1, 5, 7, 4, 3\nDriver_ID : 7, 4, 3, 10, 9\nYears_Working : 2, 8, 6, 3, 10\nIf_full_time : True\n*/\n \nCREATE TABLE \"Authorship\" (\n\t\"authID\" INTEGER, \n\t\"instID\" INTEGER, \n\t\"paperID\" INTEGER, \n\t\"authOrder\" INTEGER, \n\tPRIMARY KEY (\"authID\", \"instID\", \"paperID\"), \n\tFOREIGN KEY(\"authID\") REFERENCES \"Authors\" (\"authID\"), \n\tFOREIGN KEY(\"instID\") REFERENCES \"Inst\" (\"instID\"), \n\tFOREIGN KEY(\"paperID\") REFERENCES \"Papers\" (\"paperID\")\n)\n/*\nColumns in Authorship and 3 examples in each column for high cardinality columns :\nauthID : 53, 56, 57\n*/\n/*\nColumns in Authorship and all categories for low cardinality columns :\ninstID : 1060, 1010, 1000, 1040, 1050, 1030, 1020, 1070\npaperID : 201, 204, 205, 200, 206, 203, 202\nauthOrder : 1, 2, 3\n*/\n \nCREATE TABLE workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 program (\n\t\"Program_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Origin\" TEXT, \n\t\"Launch\" REAL, \n\t\"Owner\" TEXT, \n\tPRIMARY KEY (\"Program_ID\")\n)\n/*\nColumns in program and all categories for low cardinality columns :\nProgram_ID : 1, 2, 5, 4, 3\nName : Toonmax, Aniworld, Youman, Jiajia, Kaku\nOrigin : Beijing, Shanghai, Guangdong, Hunan, Jiangsu\nLaunch : 2007.0, 2005.0, 2010.0, 2004.0\nOwner : Jiangsu Broadcasting Corporation (JSBC), Shanghai Media Group (SMG), Beijing Television (BTV), Hunan Broadcasting System (HBS), Southern Media Corporation (SMC)\n*/\n \nCREATE TABLE race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 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 school (\n\t\"School_ID\" INTEGER, \n\t\"Grade\" TEXT, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 7, 4, 6, 3\nGrade : Freshman–Sophomore year, 1st-3rd grade, Kindergarten, Junior–Senior year, College, 5th-12th grade, 4th grade\nSchool : Occidental College, Noelani Elementary School, Harvard Law School, Columbia University, Punahou School, St. Francis Assisi, State Elementary School Menteng 01\nLocation : Cambridge, Massachusetts, Honolulu, Hawaii, Jakarta, Indonesia, Los Angeles, California, New York City\nType : Public, Private Catholic, Private\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 \"Authors\" (\n\t\"authID\" INTEGER, \n\tlname TEXT, \n\tfname TEXT, \n\tPRIMARY KEY (\"authID\")\n)\n/*\nColumns in Authors and 3 examples in each column for high cardinality columns :\nauthID : 53, 56, 57\nlname : Gibbons, Turon, Ueno\nfname : Daniel W. H., Tim, Ralf\n*/\n\n" }, { "role": "user", "content": "Find all the order items whose product id is 11. What are the order item ids?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: order_items.\nFrom these tables, I'll be using the following columns: order_item_id, product_id.\nThe SQL query I'll be generating is:\nSELECT order_item_id FROM order_items WHERE product_id = 11" } ]
[ { "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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 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 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 \"Has_amenity\" (\n\tdormid INTEGER, \n\tamenid INTEGER, \n\tFOREIGN KEY(amenid) REFERENCES \"Dorm_amenity\" (amenid), \n\tFOREIGN KEY(dormid) REFERENCES \"Dorm\" (dormid)\n)\n/*\nColumns in Has_amenity and 3 examples in each column for high cardinality columns :\namenid : 902, 955, 930\n*/\n/*\nColumns in Has_amenity and all categories for low cardinality columns :\ndormid : 109, 110, 100, 117, 140, 104, 160\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE medicine (\n\tid INTEGER, \n\tname TEXT, \n\t\"Trade_Name\" TEXT, \n\t\"FDA_approved\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in medicine and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Quetiapine, Carpipramine, Asenapine\nTrade_Name : Buronil, Fanapt, Nipolept\n*/\n/*\nColumns in medicine and all categories for low cardinality columns :\nFDA_approved : Yes, No\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\torder_quantity VARCHAR(80), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\norder_id : 13, 11, 5\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 13, 11, 2, 5, 4, 6, 12, 3, 15, 9\norder_quantity : 2, 5, 7, 8, 4, 3, 9, male\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 \"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 \"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 \"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 aircraft (\n\taid NUMERIC(9, 0), \n\tname TEXT(30), \n\tdistance NUMERIC(6, 0), \n\tPRIMARY KEY (aid)\n)\n/*\nColumns in aircraft and 3 examples in each column for high cardinality columns :\naid : 1, 16, 13\nname : Boeing 757-300, Lockheed L1011, Airbus A319\ndistance : 2128, 6475, 8430\n*/\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"CHECKING\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in CHECKING and all categories for low cardinality columns :\ncustid : 1, 2, 5, 7, 4, 6, 3\nbalance : 3000.0, 10000.0, 2000.0, 7.0, 7000.0, 77.0\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"SAVINGS\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in SAVINGS and all categories for low cardinality columns :\ncustid : 1, 2, 5, 4, 6, 3\nbalance : 80000.0, 230000.0, 999999999.0, 60.0, 240.0, 200000.0\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "List the name of all the distinct customers who have orders with status \"Packing\"." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id, orders.order_status, Packing.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"Packing\"" } ]
[ { "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 \"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 furniture_manufacte (\n\t\"Manufacturer_ID\" INTEGER, \n\t\"Furniture_ID\" INTEGER, \n\t\"Price_in_Dollar\" REAL, \n\tPRIMARY KEY (\"Manufacturer_ID\", \"Furniture_ID\"), \n\tFOREIGN KEY(\"Furniture_ID\") REFERENCES furniture (\"Furniture_ID\"), \n\tFOREIGN KEY(\"Manufacturer_ID\") REFERENCES manufacturer (\"Manufacturer_ID\")\n)\n/*\nColumns in furniture_manufacte and all categories for low cardinality columns :\nManufacturer_ID : 1, 7, 4, 5\nFurniture_ID : 1, 2, 7, 4, 3\nPrice_in_Dollar : 239.0, 1234.0, 443.0, 2124.0, 450.0\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 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 status (\n\tstation_id INTEGER, \n\tbikes_available INTEGER, \n\tdocks_available INTEGER, \n\ttime TEXT, \n\tFOREIGN KEY(station_id) REFERENCES station (id)\n)\n/*\nColumns in status and 3 examples in each column for high cardinality columns :\ntime : 2015-06-02 13:25:02, 2015-06-02 14:06:02, 2015-06-02 14:41:02\n*/\n/*\nColumns in status and all categories for low cardinality columns :\nstation_id : 4, 3\nbikes_available : 7, 6, 12\ndocks_available : 4, 5, 3\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE classroom (\n\tbuilding VARCHAR(15), \n\troom_number VARCHAR(7), \n\tcapacity NUMERIC(4, 0), \n\tPRIMARY KEY (building, room_number)\n)\n/*\nColumns in classroom and 3 examples in each column for high cardinality columns :\nbuilding : Power, Bronfman, Whitman\nroom_number : 261, 375, 757\ncapacity : 65, 97, 51\n*/\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 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 \"Available_Policies\" (\n\t\"Policy_ID\" INTEGER NOT NULL, \n\tpolicy_type_code CHAR(15), \n\t\"Customer_Phone\" VARCHAR(255), \n\tPRIMARY KEY (\"Policy_ID\"), \n\tUNIQUE (\"Policy_ID\")\n)\n/*\nColumns in Available_Policies and 3 examples in each column for high cardinality columns :\nPolicy_ID : 751, 300, 586\nCustomer_Phone : (777)537-7792, 991.642.6485x822, 1-797-927-3585x9321\n*/\n/*\nColumns in Available_Policies and all categories for low cardinality columns :\npolicy_type_code : Property Insurance, Mortgage Insurance, Life Insurance, Travel Insurance\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"Documents\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Document_Type_Code\" CHAR(15) NOT NULL, \n\t\"Project_ID\" INTEGER NOT NULL, \n\t\"Document_Date\" DATETIME, \n\t\"Document_Name\" VARCHAR(255), \n\t\"Document_Description\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Document_Type_Code\") REFERENCES \"Ref_Document_Types\" (\"Document_Type_Code\"), \n\tFOREIGN KEY(\"Project_ID\") REFERENCES \"Projects\" (\"Project_ID\")\n)\n/*\nColumns in Documents and 3 examples in each column for high cardinality columns :\nDocument_ID : 121, 300, 240\nDocument_Date : 2007-09-26 02:39:11, 1981-11-29 10:23:01, 1970-01-30 10:53:35\nDocument_Name : Katheryn statement, Review on UK files, Noel CV\n*/\n/*\nColumns in Documents and all categories for low cardinality columns :\nDocument_Type_Code : FM, BK, PP, CV\nProject_ID : 195, 30, 134, 105, 35\nDocument_Description : None\nOther_Details : None\n*/\n \nCREATE TABLE \"Video_Games\" (\n\t\"GameID\" INTEGER, \n\t\"GName\" VARCHAR(40), \n\t\"GType\" VARCHAR(40), \n\tPRIMARY KEY (\"GameID\")\n)\n/*\nColumns in Video_Games and all categories for low cardinality columns :\nGameID : 1, 2, 5, 4, 6, 3\nGName : Call of Destiny, Grand Term Assignment, The Vanishing of Eric Calder, Europe is the Universe, Works of Widenius, RNG Stone\nGType : Role-playing game, Collectible card game, Frist-person shooter, Walking Simulator, Grand strategy, Massively multiplayer online game\n*/\n" }, { "role": "user", "content": "Which customers have orders with status \"Packing\"? Give me the customer names." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id, orders.order_status, Packing.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"Packing\"" } ]
[ { "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 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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Catalogs\" (\n\tcatalog_id INTEGER, \n\tcatalog_name VARCHAR(50), \n\tcatalog_publisher VARCHAR(80), \n\tdate_of_publication DATETIME, \n\tdate_of_latest_revision DATETIME, \n\tPRIMARY KEY (catalog_id)\n)\n/*\nColumns in Catalogs and all categories for low cardinality columns :\ncatalog_id : 1, 2, 5, 7, 8, 4, 6, 3\ncatalog_name : Coffee Bean, Latte, Sparkling Water, Breakfast Tea, Jam, Lemonade, Chocolate, Coco powder\ncatalog_publisher : Russel-Gislason Lemon shop, Lidl, Koepp-Rutherford handmade chocolate store, Murray Coffee shop, Grady & Kautzer\ndate_of_publication : 2012-04-13 06:37:09, 2011-07-22 04:57:19, 2013-03-15 05:09:17, 2012-11-27 19:29:22\ndate_of_latest_revision : 2017-03-30 09:15:37, 2017-10-26 01:16:51, 2017-09-26 12:10:36, 2017-12-04 06:48:13\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 schedule (\n\t\"Cinema_ID\" INTEGER, \n\t\"Film_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Show_times_per_day\" INTEGER, \n\t\"Price\" FLOAT, \n\tPRIMARY KEY (\"Cinema_ID\", \"Film_ID\"), \n\tFOREIGN KEY(\"Cinema_ID\") REFERENCES cinema (\"Cinema_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\")\n)\n/*\nColumns in schedule and all categories for low cardinality columns :\nCinema_ID : 1, 2, 6, 10, 9\nFilm_ID : 1, 2, 5, 4, 3\nDate : 20 May, 2 Aug, 11 July, 21 May, 19 May, 21 Jun\nShow_times_per_day : 2, 5, 4, 3\nPrice : 9.99, 8.99, 12.99, 15.99\n*/\n \nCREATE TABLE flight (\n\tflno NUMERIC(4, 0), \n\torigin TEXT(20), \n\tdestination TEXT(20), \n\tdistance NUMERIC(6, 0), \n\tdeparture_date DATE, \n\tarrival_date DATE, \n\tprice NUMERIC(7, 2), \n\taid NUMERIC(9, 0), \n\tPRIMARY KEY (flno), \n\tFOREIGN KEY(aid) REFERENCES aircraft (aid)\n) \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Events\" (\n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Address_ID\" INTEGER, \n\t\"Channel_ID\" INTEGER NOT NULL, \n\t\"Event_Type_Code\" CHAR(15), \n\t\"Finance_ID\" INTEGER NOT NULL, \n\t\"Location_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Event_ID\"), \n\tFOREIGN KEY(\"Location_ID\") REFERENCES \"Locations\" (\"Location_ID\"), \n\tFOREIGN KEY(\"Address_ID\") REFERENCES \"Addresses\" (\"Address_ID\"), \n\tFOREIGN KEY(\"Finance_ID\") REFERENCES \"Finances\" (\"Finance_ID\"), \n\tUNIQUE (\"Event_ID\")\n)\n/*\nColumns in Events and 3 examples in each column for high cardinality columns :\nEvent_ID : 1, 13, 11\nChannel_ID : 1, 13, 11\nFinance_ID : 1, 13, 10\n*/\n/*\nColumns in Events and all categories for low cardinality columns :\nAddress_ID : 13, 10, 2, 12, 3, 14, 15, 9\nEvent_Type_Code : Press Conferenc, Seminar, Ceremonies, Conference, Trade Show\nLocation_ID : 13, 11, 10, 5, 7, 8, 6, 12, 15, 9\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 \"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 device (\n\t\"Device_ID\" INTEGER, \n\t\"Device\" TEXT, \n\t\"Carrier\" TEXT, \n\t\"Package_Version\" TEXT, \n\t\"Applications\" TEXT, \n\t\"Software_Platform\" TEXT, \n\tPRIMARY KEY (\"Device_ID\")\n)\n/*\nColumns in device and all categories for low cardinality columns :\nDevice_ID : 1, 2, 5, 4, 6, 3\nDevice : Huawei, Galaxy, Apple, Xiaomi, BlackBerry Storm 9530, Samsung\nCarrier : MTS Mobility, Bell Mobility, Telus Mobility, Vodafone AU, Verizon Wireless, Iusacell\nPackage_Version : 4.7.0.208, 5.0.0.742, 5.0.0.808, 5.0.0.328, 5.0.0.419\nApplications : 4.7.0.151, 5.0.0.451, 5.0.0.328, 5.0.0.419\nSoftware_Platform : iOS, Android\n*/\n \nCREATE TABLE rental (\n\trental_id INTEGER NOT NULL, \n\trental_date DATETIME NOT NULL, \n\tinventory_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\treturn_date DATETIME DEFAULT NULL, \n\tstaff_id INTEGER NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (rental_id), \n\tFOREIGN KEY(staff_id) REFERENCES staff (staff_id), \n\tFOREIGN KEY(inventory_id) REFERENCES inventory (inventory_id), \n\tFOREIGN KEY(customer_id) REFERENCES customer (customer_id)\n)\n/*\nColumns in rental and 3 examples in each column for high cardinality columns :\nrental_id : 87, 56, 65\nrental_date : 2005-05-25 01:48:41, 2005-05-26 04:26:06, 2005-05-25 08:53:14\ninventory_id : 3938, 815, 1689\ncustomer_id : 586, 56, 75\nreturn_date : 2005-06-02 22:11:28, 2005-05-26 04:52:23, 2005-05-28 12:13:24\n*/\n/*\nColumns in rental and all categories for low cardinality columns :\nstaff_id : 1, 2\nlast_update : 2006-02-15 21:30:53\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\n*/\n \nCREATE TABLE \"Documents\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Document_Type_Code\" CHAR(15) NOT NULL, \n\t\"Project_ID\" INTEGER NOT NULL, \n\t\"Document_Date\" DATETIME, \n\t\"Document_Name\" VARCHAR(255), \n\t\"Document_Description\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Document_Type_Code\") REFERENCES \"Ref_Document_Types\" (\"Document_Type_Code\"), \n\tFOREIGN KEY(\"Project_ID\") REFERENCES \"Projects\" (\"Project_ID\")\n)\n/*\nColumns in Documents and 3 examples in each column for high cardinality columns :\nDocument_ID : 121, 300, 240\nDocument_Date : 2007-09-26 02:39:11, 1981-11-29 10:23:01, 1970-01-30 10:53:35\nDocument_Name : Katheryn statement, Review on UK files, Noel CV\n*/\n/*\nColumns in Documents and all categories for low cardinality columns :\nDocument_Type_Code : FM, BK, PP, CV\nProject_ID : 195, 30, 134, 105, 35\nDocument_Description : None\nOther_Details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n" }, { "role": "user", "content": "Find the details of all the distinct customers who have orders with status \"On Road\"." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_details, customers.customer_id, orders.customer_id, orders.order_status, On Road.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"On Road\"" } ]
[ { "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 debate (\n\t\"Debate_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Num_of_Audience\" INTEGER, \n\tPRIMARY KEY (\"Debate_ID\")\n)\n/*\nColumns in debate and all categories for low cardinality columns :\nDebate_ID : 1, 2, 5, 4, 6, 3\nDate : October 21, 2011, December 17, 2014, August 3, 2015, January 21, 2017, October 27, 2015, January 12, 2017\nVenue : Abu Dhabi , UAE, Doha , Qatar, Dubai , UAE, Manama , Bahrain\nNum_of_Audience : 342, 159, 90, 209, 313, 134\n*/\n \nCREATE TABLE \"Video_Games\" (\n\t\"GameID\" INTEGER, \n\t\"GName\" VARCHAR(40), \n\t\"GType\" VARCHAR(40), \n\tPRIMARY KEY (\"GameID\")\n)\n/*\nColumns in Video_Games and all categories for low cardinality columns :\nGameID : 1, 2, 5, 4, 6, 3\nGName : Call of Destiny, Grand Term Assignment, The Vanishing of Eric Calder, Europe is the Universe, Works of Widenius, RNG Stone\nGType : Role-playing game, Collectible card game, Frist-person shooter, Walking Simulator, Grand strategy, Massively multiplayer online game\n*/\n \nCREATE TABLE grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE item (\n\ti_id INTEGER NOT NULL, \n\ttitle VARCHAR(20) DEFAULT NULL, \n\tPRIMARY KEY (i_id)\n)\n/*\nColumns in item and all categories for low cardinality columns :\ni_id : 1, 2, 5, 7, 4, 6, 3, 0\ntitle : pear, shampoo, blue hoodie, orange, comb, cup, avocado, apple\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 \"Customers_Policies\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Date_Opened\" DATE, \n\t\"Date_Closed\" DATE, \n\tPRIMARY KEY (\"Customer_ID\", \"Policy_ID\"), \n\tFOREIGN KEY(\"Customer_ID\") REFERENCES \"Customers\" (\"Customer_ID\"), \n\tFOREIGN KEY(\"Policy_ID\") REFERENCES \"Available_Policies\" (\"Policy_ID\")\n)\n/*\nColumns in Customers_Policies and 3 examples in each column for high cardinality columns :\nPolicy_ID : 586, 346, 630\nDate_Opened : 2016-06-24, 2016-11-18, 2016-07-07\nDate_Closed : 2018-03-08, 2018-02-20, 2018-03-19\n*/\n/*\nColumns in Customers_Policies and all categories for low cardinality columns :\nCustomer_ID : 562, 582, 892, 826, 682, 214, 996, 256, 641\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE technician (\n\ttechnician_id REAL, \n\t\"Name\" TEXT, \n\t\"Team\" TEXT, \n\t\"Starting_Year\" REAL, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (technician_id)\n)\n/*\nColumns in technician and all categories for low cardinality columns :\ntechnician_id : 3.0, 8.0, 10.0, 1.0, 7.0, 2.0, 6.0, 9.0, 4.0, 5.0\nName : Mark Sewell, John Brown, Mickey Cochrane, Joe Sewell, Tony Sewell, Joe Cochrane, Eddie Collins, Charlie Hollocher, Lou Boudreau\nTeam : CHC, NYY, CLE, PHA, CWS\nStarting_Year : 2013.0, 2016.0, 2003.0, 2006.0, 2005.0, 2002.0, 2009.0, 2012.0\nAge : 38, 37, 45, 46, 28, 36, 32, 47, 43, 35\n*/\n \nCREATE TABLE user_profiles (\n\tuid INTEGER NOT NULL, \n\tname VARCHAR(255) DEFAULT NULL, \n\temail VARCHAR(255) DEFAULT NULL, \n\tpartitionid INTEGER DEFAULT NULL, \n\tfollowers INTEGER DEFAULT NULL, \n\tPRIMARY KEY (uid)\n)\n/*\nColumns in user_profiles and all categories for low cardinality columns :\nuid : 1, 2, 5, 7, 4, 6, 3\nname : Natalie Portman, Mary, Black Widow\n, Tyler Swift, Celine Dion, Iron Man, Susan\nemail : susan@gmail.com\n, ts@superstar.com\n, cd@superstar.com, np@superstar.com, ts@richest.com, bw@superhero.com, Mary@yale.edu\npartitionid : 1, 2, 5, 23, 10\nfollowers : 23927492, 100, 94375428, 35425845, 890, 99999998, 6662425\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 \"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 \"Transactions\" (\n\ttransaction_id INTEGER, \n\tinvestor_id INTEGER NOT NULL, \n\ttransaction_type_code VARCHAR(10) NOT NULL, \n\tdate_of_transaction DATETIME, \n\tamount_of_transaction DECIMAL(19, 4), \n\tshare_count VARCHAR(40), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (transaction_id), \n\tFOREIGN KEY(transaction_type_code) REFERENCES \"Ref_Transaction_Types\" (transaction_type_code), \n\tFOREIGN KEY(investor_id) REFERENCES \"Investors\" (investor_id)\n)\n/*\nColumns in Transactions and 3 examples in each column for high cardinality columns :\ntransaction_id : 1, 13, 11\ndate_of_transaction : 1990-12-02 09:03:38, 2001-11-28 15:06:25, 2002-09-13 03:04:56\namount_of_transaction : 207484122.2796, 27.2570, 822.8030\nshare_count : , 8718572, 930\n*/\n/*\nColumns in Transactions and all categories for low cardinality columns :\ninvestor_id : 3, 20, 2, 7, 8, 17, 6, 14, 19, 18\ntransaction_type_code : PUR, SALE\nother_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Customer_Details\" VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (\"Customer_ID\")\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\nCustomer_ID : 588, 810, 858\nCustomer_Details : Miss Felicita Reichel, Selena Gerhold, Mrs. Liza Heller V\n*/\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" }, { "role": "user", "content": "What are the distinct customers who have orders with status \"On Road\"? Give me the customer details?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_details, customers.customer_id, orders.customer_id, orders.order_status, On Road.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"On Road\"" } ]
[ { "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 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 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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Claims\" (\n\t\"Claim_ID\" INTEGER NOT NULL, \n\t\"FNOL_ID\" INTEGER NOT NULL, \n\t\"Effective_Date\" DATE, \n\tPRIMARY KEY (\"Claim_ID\"), \n\tFOREIGN KEY(\"FNOL_ID\") REFERENCES \"First_Notification_of_Loss\" (\"FNOL_ID\"), \n\tUNIQUE (\"Claim_ID\")\n)\n/*\nColumns in Claims and all categories for low cardinality columns :\nClaim_ID : 428, 309, 717, 145, 228, 311, 360, 134, 641, 604\nFNOL_ID : 1611, 4226, 2543, 4525, 1722, 4323, 532\nEffective_Date : 1985-03-24, 1975-05-07, 1992-02-09, 2006-06-10, 1982-05-03, 1996-11-29, 1992-01-05, 1973-08-18, 2014-10-19, 2009-02-11\n*/\n \nCREATE TABLE \"Genre\" (\n\t\"GenreId\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(120) DEFAULT NULL, \n\tPRIMARY KEY (\"GenreId\")\n)\n/*\nColumns in Genre and 3 examples in each column for high cardinality columns :\nGenreId : 17, 21, 9\nName : Bossa Nova, Comedy, Opera\n*/\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 \"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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 item (\n\ti_id INTEGER NOT NULL, \n\ttitle VARCHAR(20) DEFAULT NULL, \n\tPRIMARY KEY (i_id)\n)\n/*\nColumns in item and all categories for low cardinality columns :\ni_id : 1, 2, 5, 7, 4, 6, 3, 0\ntitle : pear, shampoo, blue hoodie, orange, comb, cup, avocado, apple\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 \"Behavior_Incident\" (\n\tincident_id INTEGER, \n\tincident_type_code VARCHAR(10) NOT NULL, \n\tstudent_id INTEGER NOT NULL, \n\tdate_incident_start DATETIME, \n\tdate_incident_end DATETIME, \n\tincident_summary VARCHAR(255), \n\trecommendations VARCHAR(255), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (incident_id), \n\tFOREIGN KEY(student_id) REFERENCES \"Students\" (student_id), \n\tFOREIGN KEY(incident_type_code) REFERENCES \"Ref_Incident_Type\" (incident_type_code)\n)\n/*\nColumns in Behavior_Incident and 3 examples in each column for high cardinality columns :\nincident_id : 1, 13, 11\nstudent_id : 1, 13, 11\ndate_incident_start : 2018-01-31 10:51:13, 2017-08-27 03:21:30, 2017-05-02 12:52:09\ndate_incident_end : 2018-03-22 02:10:35, 2018-03-06 14:44:37, 2018-03-16 14:37:20\n*/\n/*\nColumns in Behavior_Incident and all categories for low cardinality columns :\nincident_type_code : VIOLENCE, DISTURB, NOISE\nincident_summary : None\nrecommendations : None, Transfer schools\nother_details : None\n*/\n \nCREATE TABLE storm (\n\t\"Storm_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Dates_active\" TEXT, \n\t\"Max_speed\" INTEGER, \n\t\"Damage_millions_USD\" REAL, \n\t\"Number_Deaths\" INTEGER, \n\tPRIMARY KEY (\"Storm_ID\")\n)\n/*\nColumns in storm and all categories for low cardinality columns :\nStorm_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Three, One, Five, Nine, Four, Seven, Six, Eight, 9 cyclones, Two\nDates_active : August5–August14, May19 –October26, August3–August10, September22–September28, September7–September17, May19–May25, October24–October26, August26–September2, September18–September25, October20–October24\nMax_speed : 1007, 988, 977, 961, 972, 1002, 983, 995\nDamage_millions_USD : 1.49, 10.75, 13.0, 29.3, 4.05, 0.039\nNumber_Deaths : 2, 7, 52, 3, 71, 0\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE seasons (\n\tyear INTEGER, \n\turl TEXT, \n\tPRIMARY KEY (year)\n)\n/*\nColumns in seasons and 3 examples in each column for high cardinality columns :\nyear : 1979, 2004, 1962\nurl : http://en.wikipedia.org/wiki/1993_Formula_One_season, http://en.wikipedia.org/wiki/1954_Formula_One_season, http://en.wikipedia.org/wiki/2012_Formula_One_season\n*/\n\n \nCREATE TABLE \"Mailshot_Campaigns\" (\n\tmailshot_id INTEGER, \n\tproduct_category VARCHAR(15), \n\tmailshot_name VARCHAR(80), \n\tmailshot_start_date DATETIME, \n\tmailshot_end_date DATETIME, \n\tPRIMARY KEY (mailshot_id)\n)\n/*\nColumns in Mailshot_Campaigns and 3 examples in each column for high cardinality columns :\nmailshot_id : 17, 9, 16\nmailshot_start_date : 2017-05-20 20:05:09, 2018-02-04 13:13:36, 2017-09-27 02:35:45\nmailshot_end_date : 2018-03-15 01:06:16, 2018-03-13 14:42:26, 2018-03-01 13:42:09\n*/\n/*\nColumns in Mailshot_Campaigns and all categories for low cardinality columns :\nproduct_category : food, clothes\nmailshot_name : USPS, US, AL, FED\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 bridge (\n\tarchitect_id INTEGER, \n\tid INTEGER, \n\tname TEXT, \n\tlocation TEXT, \n\tlength_meters REAL, \n\tlength_feet REAL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(architect_id) REFERENCES architect (id)\n)\n/*\nColumns in bridge and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nname : Xian Ren Qiao (Fairy Bridge), Hazarchishma Natural Bridge, Stevens Arch\nlocation : Guizhou , China, Natural Bridges National Monument , Utah , USA, Dinosaur National Monument , Colorado , USA\nlength_meters : 64.2, 69.0, 67.0\nlength_feet : 290.0, 225.0, 400.0\n*/\n/*\nColumns in bridge and all categories for low cardinality columns :\narchitect_id : 1, 2, 5, 4, 3\n*/\n" }, { "role": "user", "content": "What is the name of the customer who has the most orders?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id 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 accelerator_compatible_browser (\n\taccelerator_id INTEGER, \n\tbrowser_id INTEGER, \n\tcompatible_since_year INTEGER, \n\tPRIMARY KEY (accelerator_id, browser_id), \n\tFOREIGN KEY(browser_id) REFERENCES browser (id), \n\tFOREIGN KEY(accelerator_id) REFERENCES \"Web_client_accelerator\" (id)\n)\n/*\nColumns in accelerator_compatible_browser and all categories for low cardinality columns :\naccelerator_id : 1, 2, 4, 3, 9\nbrowser_id : 1, 2, 4, 3\ncompatible_since_year : 2009, 2005, 1995, 2008, 2000, 1996, 2010, 2007\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 swimmer (\n\t\"ID\" INTEGER, \n\tname TEXT, \n\t\"Nationality\" TEXT, \n\tmeter_100 REAL, \n\tmeter_200 TEXT, \n\tmeter_300 TEXT, \n\tmeter_400 TEXT, \n\tmeter_500 TEXT, \n\tmeter_600 TEXT, \n\tmeter_700 TEXT, \n\t\"Time\" TEXT, \n\tPRIMARY KEY (\"ID\")\n)\n/*\nColumns in swimmer and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3\nname : Przemysław Stańczyk, Grant Hackett, Federico Colbertaldo, Sébastien Rouault, Craig Stevens, Sergiy Fesenko, Oussama Mellouli, Ryan Cochrane\nNationality : Italy, Canada, Australia, Ukraine, France, Tunisia, Poland\nmeter_100 : 57.35, 57.31, 55.67, 57.84, 57.66, 57.34\nmeter_200 : 1:57.21, 1:54.40, 1:57.26, 1:57.10, 1:56.44, 1:56.34, 1:56.77\nmeter_300 : 2:56.64, 2:56.95, 2:57.10, 2:55.94, 2:53.46, 2:55.90, 2:56.02, 2:56.04\nmeter_400 : 3:55.72, 3:55.49, 3:55.36, 3:57.00, 3:52.93, 3:56.34, 3:57.12, 3:55.37\nmeter_500 : 4:54.48, 4:56.96, 4:55.08, 4:54.21, 4:54.19, 4:52.85, 4:57.03, 4:56.15\nmeter_600 : 5:54.45, 5:53.03, 5:52.92, 5:56.99, 5:56.31, 5:53.53, 5:57.10, 5:52.59\nmeter_700 : 6:55.07, 6:57.44, 6:50.91, 6:53.34, 6:52.58, 6:57.69, 6:50.80, 6:52.69\nTime : 7:55.39, 7:52.04, 7:47.91, 7:53.43, 7:46.95, 7:56.56, 7:48.67, 7:49.98\n*/\n \nCREATE TABLE department (\n\t\"Dname\" TEXT, \n\t\"Dnumber\" INTEGER, \n\t\"Mgr_ssn\" INTEGER, \n\t\"Mgr_start_date\" TEXT, \n\tPRIMARY KEY (\"Dnumber\")\n)\n/*\nColumns in department and all categories for low cardinality columns :\nDname : Headquarters, Administration, Research\nDnumber : 1, 4, 5\nMgr_ssn : 987654321, 333445555, 888665555\nMgr_start_date : 1988-05-22, 1995-01-01, 1981-06-19\n*/\n \nCREATE TABLE device (\n\t\"Device_ID\" INTEGER, \n\t\"Device\" TEXT, \n\t\"Carrier\" TEXT, \n\t\"Package_Version\" TEXT, \n\t\"Applications\" TEXT, \n\t\"Software_Platform\" TEXT, \n\tPRIMARY KEY (\"Device_ID\")\n)\n/*\nColumns in device and all categories for low cardinality columns :\nDevice_ID : 1, 2, 5, 4, 6, 3\nDevice : Huawei, Galaxy, Apple, Xiaomi, BlackBerry Storm 9530, Samsung\nCarrier : MTS Mobility, Bell Mobility, Telus Mobility, Vodafone AU, Verizon Wireless, Iusacell\nPackage_Version : 4.7.0.208, 5.0.0.742, 5.0.0.808, 5.0.0.328, 5.0.0.419\nApplications : 4.7.0.151, 5.0.0.451, 5.0.0.328, 5.0.0.419\nSoftware_Platform : iOS, Android\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 \"Council_Tax\" (\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 Council_Tax and all categories for low cardinality columns :\ncouncil_tax_id : 1, 2, 7, 8, 3, 9\ncmi_cross_ref_id : 106, 103, 102, 101, 104, 105\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE branch (\n\t\"Branch_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Open_year\" TEXT, \n\t\"Address_road\" TEXT, \n\t\"City\" TEXT, \n\tmembership_amount TEXT, \n\tPRIMARY KEY (\"Branch_ID\")\n)\n/*\nColumns in branch and all categories for low cardinality columns :\nBranch_ID : 1, 2, 5, 7, 8, 4, 6, 3\nName : Popert, Zytogorski, Alexandre, Brooke Greville, Taverner, Stanley, Saint Amant, Cochrane\nOpen_year : 2009, 2013, 2015, 2001, 2012, 2014\nAddress_road : Abbott Street, Concord Road, Brampton Road, Cecilia Avenue, Oaks Crescent, Valleys Place, Glebe Street, Abbey Rise\nCity : Oxford, London\nmembership_amount : 91, 56, 11, 1418, 7, 6, 112, 31\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Agreements\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Event_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES \"Events\" (\"Event_ID\")\n)\n/*\nColumns in Agreements and 3 examples in each column for high cardinality columns :\nDocument_ID : 1, 13, 11\n*/\n/*\nColumns in Agreements and all categories for low cardinality columns :\nEvent_ID : 13, 11, 10, 5, 8, 6, 12, 15, 9\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 \"PersonFriend\" (\n\tname VARCHAR(20), \n\tfriend VARCHAR(20), \n\tyear INTEGER, \n\tFOREIGN KEY(name) REFERENCES \"Person\" (name), \n\tFOREIGN KEY(friend) REFERENCES \"Person\" (name)\n)\n/*\nColumns in PersonFriend and all categories for low cardinality columns :\nname : Alice, Zach, Bob\nfriend : Alice, Dan, Zach, Bob\nyear : 10, 5, 6, 12\n*/\n \nCREATE TABLE \"Functional_Areas\" (\n\tfunctional_area_code VARCHAR(15), \n\tparent_functional_area_code VARCHAR(15), \n\tfunctional_area_description VARCHAR(80) NOT NULL, \n\tPRIMARY KEY (functional_area_code)\n)\n/*\nColumns in Functional_Areas and all categories for low cardinality columns :\nfunctional_area_code : 1, 8, 9\nparent_functional_area_code : 8\nfunctional_area_description : Keep blank, Signature, Acknowledgement\n*/\n \nCREATE TABLE grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\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" }, { "role": "user", "content": "Which customer made the most orders? Find the customer name." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id 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 \"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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE furniture (\n\t\"Furniture_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Num_of_Component\" INTEGER, \n\t\"Market_Rate\" REAL, \n\tPRIMARY KEY (\"Furniture_ID\")\n)\n/*\nColumns in furniture and all categories for low cardinality columns :\nFurniture_ID : 1, 2, 5, 7, 4, 6, 3\nName : Dining set, Chabudai, Billiard table, Hatstand, Bookcase, Four-poster bed, Bench\nNum_of_Component : 5, 4, 6, 14, 3, 12\nMarket_Rate : 1.0, 3.5, 52.5, 0.5, 40.0, 2.0\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 \nCREATE TABLE \"Regular_Orders\" (\n\tregular_order_id INTEGER, \n\tdistributer_id INTEGER NOT NULL, \n\tPRIMARY KEY (regular_order_id), \n\tFOREIGN KEY(distributer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Regular_Orders and 3 examples in each column for high cardinality columns :\nregular_order_id : 1, 13, 11\n*/\n/*\nColumns in Regular_Orders and all categories for low cardinality columns :\ndistributer_id : 1, 10, 2, 7, 8, 6, 12, 3, 14, 15\n*/\n \nCREATE TABLE school_performance (\n\t\"School_Id\" INTEGER, \n\t\"School_Year\" TEXT, \n\t\"Class_A\" TEXT, \n\t\"Class_AA\" TEXT, \n\tPRIMARY KEY (\"School_Id\", \"School_Year\"), \n\tFOREIGN KEY(\"School_Id\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in school_performance and 3 examples in each column for high cardinality columns :\nSchool_Year : 1998-99, 2002-03, 1994-95\nClass_A : Skidmore-Tynan, Lindsay, Anton\nClass_AA : Buffalo, Henrietta, S&S Consolidated\n*/\n/*\nColumns in school_performance and all categories for low cardinality columns :\nSchool_Id : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE \"Products\" (\n\t\"Product_ID\" VARCHAR(100) NOT NULL, \n\t\"Product_Name\" VARCHAR(255), \n\t\"Product_Price\" DECIMAL(20, 4), \n\t\"Product_Description\" VARCHAR(255), \n\t\"Other_Product_Service_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Product_ID\"), \n\tUNIQUE (\"Product_ID\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nProduct_ID : 250, 300, 233\nProduct_Price : 634660.0000, 1577.0000, 900.0000\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nProduct_Name : dinning, photo, film\nProduct_Description : None\nOther_Product_Service_Details : None\n*/\n \nCREATE TABLE channel (\n\t\"Channel_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Owner\" TEXT, \n\t\"Share_in_percent\" REAL, \n\t\"Rating_in_percent\" REAL, \n\tPRIMARY KEY (\"Channel_ID\")\n)\n/*\nColumns in channel and all categories for low cardinality columns :\nChannel_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Shandong Satellite TV, CCTV-8, Hunan Satellite TV, CCTV-3, CCTV-14, CCTV-6, CCTV-13, CCTV-1, Anhui Satellite TV, CCTV-4\nOwner : HBS, Shandong Television, CCTV, Anhui Television\nShare_in_percent : 4.9, 2.33, 1.74, 2.91, 4.81, 2.6, 2.86, 3.76, 1.78, 2.73\nRating_in_percent : 0.53, 0.41, 0.32, 0.19, 0.54, 0.3, 0.31, 0.2, 0.29, 0.26\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduct_category_code VARCHAR(20) NOT NULL, \n\tdate_product_first_available DATETIME, \n\tdate_product_discontinued DATETIME, \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tproduct_price DECIMAL(19, 4), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\nparent_product_id : 8, 4, 9, 3\nproduct_category_code : Food, Book, Hardware\ndate_product_first_available : 1988-09-29 17:54:50, 1998-06-20 15:04:11, 1994-12-18 15:13:19, 1974-06-25 12:26:47\ndate_product_discontinued : 1987-12-20 13:46:16, 1997-07-02 18:26:16, 1980-06-26 10:40:19, 1991-08-20 05:22:31\nproduct_name : Chocolate, The Great Gatsby, Mouse, Keyboard\nproduct_description : Designed for games, Handmade chocolate, American novel, Blue tooth mouse\nproduct_price : 23.3500, 2.8800, 109.9900, 35.0000\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"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 enrollments (\n\t\"Campus\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"TotalEnrollment_AY\" INTEGER, \n\t\"FTE_AY\" INTEGER, \n\tPRIMARY KEY (\"Campus\", \"Year\"), \n\tFOREIGN KEY(\"Campus\") REFERENCES \"Campuses\" (\"Id\")\n)\n/*\nColumns in enrollments and 3 examples in each column for high cardinality columns :\nYear : 1979, 2004, 1937\nTotalEnrollment_AY : 495, 5734, 9547\nFTE_AY : 3877, 14324, 12876\n*/\n/*\nColumns in enrollments and all categories for low cardinality columns :\nCampus : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"COURSE\" (\n\t\"CRS_CODE\" VARCHAR(10), \n\t\"DEPT_CODE\" VARCHAR(10), \n\t\"CRS_DESCRIPTION\" VARCHAR(35), \n\t\"CRS_CREDIT\" FLOAT, \n\tPRIMARY KEY (\"CRS_CODE\"), \n\tFOREIGN KEY(\"DEPT_CODE\") REFERENCES \"DEPARTMENT\" (\"DEPT_CODE\")\n)\n/*\nColumns in COURSE and all categories for low cardinality columns :\nCRS_CODE : ACCT-212, QM-362, QM-261, CIS-420, CIS-220, ACCT-211\nDEPT_CODE : CIS, ACCT\nCRS_DESCRIPTION : Statistical Applications, Accounting I, Accounting II, Database Design and Implementation, Intro. to Microcomputing, Intro. to Statistics\nCRS_CREDIT : 3.0, 4.0\n*/\n \nCREATE TABLE city (\n\tcity_id INTEGER NOT NULL, \n\tcity VARCHAR(50) NOT NULL, \n\tcountry_id INTEGER NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (city_id), \n\tFOREIGN KEY(country_id) REFERENCES country (country_id)\n)\n/*\nColumns in city and 3 examples in each column for high cardinality columns :\ncity_id : 87, 56, 65\ncity : Guaruj, Coacalco de Berriozbal, Almirante Brown\ncountry_id : 87, 78, 75\n*/\n/*\nColumns in city and all categories for low cardinality columns :\nlast_update : 2006-02-15 04:45:25\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" }, { "role": "user", "content": "What is the customer id of the customer who has the most orders?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_id, orders.customer_id.\nThe SQL query I'll be generating is:\nSELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id 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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Visits_Restaurant\" (\n\t\"StuID\" INTEGER, \n\t\"ResID\" INTEGER, \n\t\"Time\" TIMESTAMP, \n\t\"Spent\" FLOAT, \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"ResID\") REFERENCES \"Restaurant\" (\"ResID\")\n)\n/*\nColumns in Visits_Restaurant and all categories for low cardinality columns :\nStuID : 1001, 1032\nResID : 1, 2\nTime : 2017-10-09 18:15:00, 2017-10-08 13:00:30\nSpent : 13.2, 6.53\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 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 \"Rooms\" (\n\t\"RoomId\" TEXT, \n\t\"roomName\" TEXT, \n\tbeds INTEGER, \n\t\"bedType\" TEXT, \n\t\"maxOccupancy\" INTEGER, \n\t\"basePrice\" INTEGER, \n\tdecor TEXT, \n\tPRIMARY KEY (\"RoomId\")\n)\n/*\nColumns in Rooms and all categories for low cardinality columns :\nRoomId : IBD, IBS, RTE, CAS, FNA, HBB, AOB, MWC, TAA, RND\nroomName : Convoke and sanguine, Immutable before decorum, Abscond or bolster, Recluse and defiance, Thrift and accolade, Riddle to exculpate, Harbinger but bequest, Frugal not apropos, Interim but salutary, Mendicant with cryptic\nbeds : 1, 2\nbedType : King, Double, Queen\nmaxOccupancy : 2, 4\nbasePrice : 250, 75, 100, 150, 125, 175\ndecor : modern, rustic, traditional\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 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 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 manager (\n\t\"Manager_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Country\" TEXT, \n\t\"Working_year_starts\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Level\" INTEGER, \n\tPRIMARY KEY (\"Manager_ID\")\n)\n/*\nColumns in manager and all categories for low cardinality columns :\nManager_ID : 1, 2, 5, 7, 4, 6, 3\nName : Ben Curtis, Sandy Lyle, Todd Hamilton, David Duval, Tiger Woods, Greg Norman, Nick Faldo\nCountry : United States, Australia, Scotland, England\nWorking_year_starts : 2004, 1993, 2001, 1985, 1999, 2006, 2003\nAge : 46, 45, 55, 48, 52, 47, 51\nLevel : 11, 5, 7, 8, 12\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 takes (\n\t\"ID\" VARCHAR(5), \n\tcourse_id VARCHAR(8), \n\tsec_id VARCHAR(8), \n\tsemester VARCHAR(6), \n\tyear NUMERIC(4, 0), \n\tgrade VARCHAR(2), \n\tPRIMARY KEY (\"ID\", course_id, sec_id, semester, year), \n\tFOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year), \n\tFOREIGN KEY(\"ID\") REFERENCES student (\"ID\")\n)\n/*\nColumns in takes and 3 examples in each column for high cardinality columns :\nID : 99189, 44706, 56058\ncourse_id : 843, 400, 349\n*/\n/*\nColumns in takes and all categories for low cardinality columns :\nsec_id : 1, 2, 3\nsemester : Fall, Spring\nyear : 2004, 2009, 2001, 2005, 2008, 2006, 2003, 2002, 2010, 2007\ngrade : B-, B , C , B+, A , A-, C-, C+, A+\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE city (\n\t\"City_ID\" INTEGER, \n\t\"County_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"White\" REAL, \n\t\"Black\" REAL, \n\t\"Amerindian\" REAL, \n\t\"Asian\" REAL, \n\t\"Multiracial\" REAL, \n\t\"Hispanic\" REAL, \n\tPRIMARY KEY (\"City_ID\"), \n\tFOREIGN KEY(\"County_ID\") REFERENCES county_public_safety (\"County_ID\")\n)\n/*\nColumns in city and 3 examples in each column for high cardinality columns :\nCity_ID : 1, 16, 13\nName : Aguadilla, Barranquitas, Bayamón\nWhite : 70.7, 78.3, 93.1\nBlack : 4.1, 22.8, 7.2\nMultiracial : 10.7, 12.1, 11.7\n*/\n/*\nColumns in city and all categories for low cardinality columns :\nCounty_ID : 1, 2, 5, 4, 6, 3\nAmerindian : 0.4, 0.6, 1.0, 0.3, 0.2, 0.9\nAsian : 0.1, 0.4, 0.3, 0.0, 0.2\nHispanic : 99.6, 98.5, 99.1, 99.5, 99.2, 99.4, 98.6, 98.9, 99.0, 99.3\n*/\n \nCREATE TABLE user_profiles (\n\tuid INTEGER NOT NULL, \n\tname VARCHAR(255) DEFAULT NULL, \n\temail VARCHAR(255) DEFAULT NULL, \n\tpartitionid INTEGER DEFAULT NULL, \n\tfollowers INTEGER DEFAULT NULL, \n\tPRIMARY KEY (uid)\n)\n/*\nColumns in user_profiles and all categories for low cardinality columns :\nuid : 1, 2, 5, 7, 4, 6, 3\nname : Natalie Portman, Mary, Black Widow\n, Tyler Swift, Celine Dion, Iron Man, Susan\nemail : susan@gmail.com\n, ts@superstar.com\n, cd@superstar.com, np@superstar.com, ts@richest.com, bw@superhero.com, Mary@yale.edu\npartitionid : 1, 2, 5, 23, 10\nfollowers : 23927492, 100, 94375428, 35425845, 890, 99999998, 6662425\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n" }, { "role": "user", "content": "Find the id of the customer who made the most orders." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_id, orders.customer_id.\nThe SQL query I'll be generating is:\nSELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id 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 \"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 \"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 \"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 \"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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Date_of_Birth\" TEXT, \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\nName : Fabrizio Buonocore, Goran Fiorentini, Francesco Postiglione, Alberto Angelini, Leonardo Binchi, Marco Gerini, Roberto Calcaterra, Maurizio Felugo\nHeight : 1.9, 1.86, 1.72, 1.75, 1.95, 1.78, 1.82, 1.83\nWeight : 45.0, 89.0, 67.0, 58.0, 57.0, 75.0, 76.0, 80.0\nDate_of_Birth : 1975-08-27, 1971-08-05, 1972-04-29, 1977-04-28, 1981-03-04, 1972-02-06, 1981-11-21, 1974-09-28\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Height\" REAL, \n\t\"Weight\" REAL, \n\t\"Date_of_Birth\" TEXT, \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\nName : Fabrizio Buonocore, Goran Fiorentini, Francesco Postiglione, Alberto Angelini, Leonardo Binchi, Marco Gerini, Roberto Calcaterra, Maurizio Felugo\nHeight : 1.9, 1.86, 1.72, 1.75, 1.95, 1.78, 1.82, 1.83\nWeight : 45.0, 89.0, 67.0, 58.0, 57.0, 75.0, 76.0, 80.0\nDate_of_Birth : 1975-08-27, 1971-08-05, 1972-04-29, 1977-04-28, 1981-03-04, 1972-02-06, 1981-11-21, 1974-09-28\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" }, { "role": "user", "content": "Give me a list of id and status of orders which belong to the customer named \"Jeramie\"." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: orders.order_id, orders.order_status, customers.customer_id, orders.customer_id, customers.customer_name, Jeramie.\nThe SQL query I'll be generating is:\nSELECT T2.order_id , T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = \"Jeramie\"" } ]
[ { "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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 circuits (\n\t\"circuitId\" INTEGER, \n\t\"circuitRef\" TEXT, \n\tname TEXT, \n\tlocation TEXT, \n\tcountry TEXT, \n\tlat REAL, \n\tlng REAL, \n\talt TEXT, \n\turl TEXT, \n\tPRIMARY KEY (\"circuitId\")\n)\n/*\nColumns in circuits and 3 examples in each column for high cardinality columns :\ncircuitId : 53, 56, 65\ncircuitRef : brands_hatch, valencia, kyalami\nname : N_rburgring, Circuito da Boavista, Reims-Gueux\nlocation : Yeongam County, Shanghai, Lisbon\ncountry : Sweden, Turkey, Australia\nlat : 42.475, 47.95, 40.3725\nlng : 39.9578, 1.00458, -74.6099\nurl : http://en.wikipedia.org/wiki/Riverside_International_Raceway, http://en.wikipedia.org/wiki/Charade_Circuit, http://en.wikipedia.org/wiki/Dijon-Prenois\n*/\n/*\nColumns in circuits and all categories for low cardinality columns :\nalt : , 10\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 operate_company (\n\tid INTEGER, \n\tname TEXT, \n\t\"Type\" TEXT, \n\t\"Principal_activities\" TEXT, \n\t\"Incorporated_in\" TEXT, \n\t\"Group_Equity_Shareholding\" REAL, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in operate_company and 3 examples in each column for high cardinality columns :\nid : 1, 13, 11\nname : China Pacific Laundry Services, Cathay Pacific Holidays, CLS Catering Services Limited\n*/\n/*\nColumns in operate_company and all categories for low cardinality columns :\nType : Joint Venture, Subsidiary, Corporate\nPrincipal_activities : Laundry, Airline, Catering services, Travel agency, Ground handling, Cargo, Cargo airline\nIncorporated_in : Canada, China, Hong Kong, Vietnam, Taiwan\nGroup_Equity_Shareholding : 45.0, 60.0, 30.0, 49.0, 100.0, 40.0, 18.77\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"PersonFriend\" (\n\tname VARCHAR(20), \n\tfriend VARCHAR(20), \n\tyear INTEGER, \n\tFOREIGN KEY(name) REFERENCES \"Person\" (name), \n\tFOREIGN KEY(friend) REFERENCES \"Person\" (name)\n)\n/*\nColumns in PersonFriend and all categories for low cardinality columns :\nname : Alice, Zach, Bob\nfriend : Alice, Dan, Zach, Bob\nyear : 10, 5, 6, 12\n*/\n \nCREATE TABLE \"Institution\" (\n\t\"Institution_id\" TEXT, \n\t\"Institution\" TEXT, \n\t\"Location\" TEXT, \n\t\"Founded\" REAL, \n\t\"Type\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"Team\" TEXT, \n\t\"Primary_Conference\" TEXT, \n\tbuilding_id TEXT, \n\tPRIMARY KEY (\"Institution_id\"), \n\tFOREIGN KEY(building_id) REFERENCES building (building_id)\n)\n/*\nColumns in Institution and 3 examples in each column for high cardinality columns :\nInstitution_id : 1, 2, 5\nInstitution : Ave Maria University, Lindenwood University–Belleville, Point University\nLocation : Mayville, North Dakota, Jacksonville, Florida, Babson Park, Florida\nEnrollment : 967, 616, 3102\nTeam : Gyrenes, Comets, Warriors\n*/\n/*\nColumns in Institution and all categories for low cardinality columns :\nFounded : 1937.0, 1881.0, 1927.0, 2003.0, 1883.0, 1866.0, 1998.0, 1884.0, 1889.0, 1890.0\nType : Public, Tribal, Private\nPrimary_Conference : MCAC, CalPac, Gulf Coast (GCAC), AAC, none, The Sun\nbuilding_id : 1, 2, 5, 7, 4, 3, 0\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 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 host (\n\t\"Host_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Age\" TEXT, \n\tPRIMARY KEY (\"Host_ID\")\n)\n/*\nColumns in host and all categories for low cardinality columns :\nHost_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Lloyd Daniels, Kornel David, Antonio Davis, Carlos Delfino, DeMar DeRozan, Ed Davis, Austin Daye, Derrick Dial, Justin Dentmon, Hubert Davis\nNationality : United States, Argentina, Hungary\nAge : 26, 45, 37, 40, 30, 60, 47, 43, 31\n*/\n \nCREATE TABLE endowment (\n\tendowment_id INTEGER, \n\t\"School_id\" INTEGER, \n\tdonator_name TEXT, \n\tamount REAL, \n\tPRIMARY KEY (endowment_id), \n\tFOREIGN KEY(\"School_id\") REFERENCES \"School\" (\"School_id\")\n)\n/*\nColumns in endowment and 3 examples in each column for high cardinality columns :\nendowment_id : 1, 11, 2\ndonator_name : Santo Domingo Este, Duarte, San Cristóbal\namount : 9.05, 8.82, 8.85\n*/\n/*\nColumns in endowment and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 7, 8, 4, 6, 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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "Which orders are made by the customer named \"Jeramie\"? Give me the order ids and status." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: orders.order_id, orders.order_status, customers.customer_id, orders.customer_id, customers.customer_name, Jeramie.\nThe SQL query I'll be generating is:\nSELECT T2.order_id , T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = \"Jeramie\"" } ]
[ { "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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduction_type_code VARCHAR(15) NOT NULL, \n\tunit_price DECIMAL(19, 4), \n\tproduct_name VARCHAR(80), \n\tproduct_color VARCHAR(20), \n\tproduct_size VARCHAR(20), \n\tPRIMARY KEY (product_id), \n\tFOREIGN KEY(production_type_code) REFERENCES \"Product_Categories\" (production_type_code)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nunit_price : 49.6200, 563.5800, 729.0900\nproduct_name : Coffee Bean, Art History, Beer Menus\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nparent_product_id : 1, 2, 5, 7, 8, 4, 6, 9\nproduction_type_code : Food, Books, Electronics, DVDs\nproduct_color : Red, Yellow, Black\nproduct_size : Small, Medium, Large\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 \"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 \"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 \"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 \"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 furniture (\n\t\"Furniture_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Num_of_Component\" INTEGER, \n\t\"Market_Rate\" REAL, \n\tPRIMARY KEY (\"Furniture_ID\")\n)\n/*\nColumns in furniture and all categories for low cardinality columns :\nFurniture_ID : 1, 2, 5, 7, 4, 6, 3\nName : Dining set, Chabudai, Billiard table, Hatstand, Bookcase, Four-poster bed, Bench\nNum_of_Component : 5, 4, 6, 14, 3, 12\nMarket_Rate : 1.0, 3.5, 52.5, 0.5, 40.0, 2.0\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 \"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 grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\n*/\n \nCREATE TABLE artist (\n\t\"Artist_ID\" INTEGER, \n\t\"Artist\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Famous_Title\" TEXT, \n\t\"Famous_Release_date\" TEXT, \n\tPRIMARY KEY (\"Artist_ID\")\n)\n/*\nColumns in artist and all categories for low cardinality columns :\nArtist_ID : 1, 2, 5, 7, 4, 6, 3\nArtist : Gorgoroth, Tangorodrim, Triumfall, Black Flame, Ophiolatry\nAge : 49, 34, 18, 27, 22, 35\nFamous_Title : Unholy Metal Way (re-release), Antievangelistical Process (re-release), Imperivm, Those Who Unleashed (re-release), Antithesis of All Flesh, Bergen 1996, Transmutation\nFamous_Release_date : November 2007, 2009, June 15, 2009, January 21, 2008, June 23, 2008\n*/\n \nCREATE TABLE school_bus (\n\t\"School_ID\" INTEGER, \n\t\"Driver_ID\" INTEGER, \n\t\"Years_Working\" INTEGER, \n\t\"If_full_time\" BOOLEAN, \n\tPRIMARY KEY (\"School_ID\", \"Driver_ID\"), \n\tFOREIGN KEY(\"Driver_ID\") REFERENCES driver (\"Driver_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in school_bus and all categories for low cardinality columns :\nSchool_ID : 1, 5, 7, 4, 3\nDriver_ID : 7, 4, 3, 10, 9\nYears_Working : 2, 8, 6, 3, 10\nIf_full_time : True\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE exhibition_record (\n\t\"Exhibition_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Exhibition_ID\", \"Date\"), \n\tFOREIGN KEY(\"Exhibition_ID\") REFERENCES exhibition (\"Exhibition_ID\")\n)\n/*\nColumns in exhibition_record and 3 examples in each column for high cardinality columns :\nDate : February 25, February 19, December 2\nAttendance : 1313, 24808, 1233\n*/\n/*\nColumns in exhibition_record and all categories for low cardinality columns :\nExhibition_ID : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE shop (\n\t\"Shop_ID\" INTEGER, \n\t\"Shop_Name\" TEXT, \n\t\"Location\" TEXT, \n\t\"Open_Date\" TEXT, \n\t\"Open_Year\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\")\n)\n/*\nColumns in shop and 3 examples in each column for high cardinality columns :\nShop_ID : 1, 11, 2\nShop_Name : Pentre store, Best Buy, Apple\nOpen_Date : 24 February, 18 February, 1 January\n*/\n/*\nColumns in shop and all categories for low cardinality columns :\nLocation : Maerdy, Porth, Blaenllechau, Pentre, Penygraig, Gelli, Dinas, Wattstown, Cymmer\nOpen_Year : 2009, 2013, 2015, 2017, 2006, 2011, 2014, 2010, 2007\n*/\n \nCREATE TABLE \"Product_Characteristics\" (\n\tproduct_id INTEGER NOT NULL, \n\tcharacteristic_id INTEGER NOT NULL, \n\tproduct_characteristic_value VARCHAR(50), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(characteristic_id) REFERENCES \"Characteristics\" (characteristic_id)\n)\n/*\nColumns in Product_Characteristics and all categories for low cardinality columns :\nproduct_id : 1, 13, 11, 5, 7, 8, 6, 12, 14\ncharacteristic_id : 13, 10, 11, 2, 4, 6, 12, 3, 15\nproduct_characteristic_value : high, low, medium\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "Find the dates of orders which belong to the customer named \"Jeramie\"." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: orders.date_order_placed, customers.customer_id, orders.customer_id, customers.customer_name, Jeramie.\nThe SQL query I'll be generating is:\nSELECT T2.date_order_placed FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = \"Jeramie\"" } ]
[ { "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 \"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 \"Team\" (\n\tid INTEGER, \n\tteam_api_id INTEGER, \n\tteam_fifa_api_id INTEGER, \n\tteam_long_name TEXT, \n\tteam_short_name TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Team and 3 examples in each column for high cardinality columns :\nid : 9553, 14876, 9547\nteam_api_id : 9761, 9875, 9847\nteam_fifa_api_id : 65, 1907, 1926\nteam_long_name : Lecce, AS Saint-Étienne, Stade Rennais FC\nteam_short_name : SIE, NIC, BAS\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"All_Documents\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Date_Stored\" DATETIME, \n\t\"Document_Type_Code\" CHAR(15) NOT NULL, \n\t\"Document_Name\" CHAR(255), \n\t\"Document_Description\" CHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Document_Type_Code\") REFERENCES \"Ref_Document_Types\" (\"Document_Type_Code\"), \n\tFOREIGN KEY(\"Date_Stored\") REFERENCES \"Ref_Calendar\" (\"Calendar_Date\")\n)\n/*\nColumns in All_Documents and 3 examples in each column for high cardinality columns :\nDocument_ID : 120, 230, 11\nDocument_Name : Cats and me, Alan CV, Hua Mulan\n*/\n/*\nColumns in All_Documents and all categories for low cardinality columns :\nDate_Stored : 2009-08-18 03:29:08, 2012-07-03 09:48:46, 1987-11-05 06:11:22, 1986-10-14 17:53:39, 1976-06-15 03:40:06, 1997-03-10 15:24:00, 1995-01-01 03:52:11, 2008-06-08 12:45:38\nDocument_Type_Code : RV, BK, PR, CV\nDocument_Description : None\nOther_Details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE hosting_city (\n\t\"Year\" INTEGER, \n\t\"Match_ID\" INTEGER, \n\t\"Host_City\" TEXT, \n\tPRIMARY KEY (\"Year\"), \n\tFOREIGN KEY(\"Match_ID\") REFERENCES \"match\" (\"Match_ID\"), \n\tFOREIGN KEY(\"Host_City\") REFERENCES city (\"City_ID\")\n)\n/*\nColumns in hosting_city and all categories for low cardinality columns :\nYear : 2009, 2013, 2012, 2008, 2011, 2010\nMatch_ID : 1, 2, 5, 4, 6, 3\nHost_City : 1, 11, 2, 6, 12\n*/\n \nCREATE TABLE film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"STUDENT\" (\n\t\"STU_NUM\" INTEGER, \n\t\"STU_LNAME\" VARCHAR(15), \n\t\"STU_FNAME\" VARCHAR(15), \n\t\"STU_INIT\" VARCHAR(1), \n\t\"STU_DOB\" DATETIME, \n\t\"STU_HRS\" INTEGER, \n\t\"STU_CLASS\" VARCHAR(2), \n\t\"STU_GPA\" FLOAT, \n\t\"STU_TRANSFER\" NUMERIC, \n\t\"DEPT_CODE\" VARCHAR(18), \n\t\"STU_PHONE\" VARCHAR(4), \n\t\"PROF_NUM\" INTEGER, \n\tPRIMARY KEY (\"STU_NUM\"), \n\tFOREIGN KEY(\"DEPT_CODE\") REFERENCES \"DEPARTMENT\" (\"DEPT_CODE\")\n) \nCREATE TABLE member (\n\t\"Member_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Membership_card\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Time_of_purchase\" INTEGER, \n\t\"Level_of_membership\" INTEGER, \n\t\"Address\" TEXT, \n\tPRIMARY KEY (\"Member_ID\")\n)\n/*\nColumns in member and all categories for low cardinality columns :\nMember_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Peeler, Russell, Rizzo, Todd, Campbell, Jessie, Breton, Robert, Komisarjevsky, Joshua, Webb, Daniel, Ashby, Lazale, Hayes, Steven, Reynolds, Richard, Cobb, Sedrick\nMembership_card : White, Black\nAge : 67, 45, 33, 50, 34, 42, 29, 51, 35\nTime_of_purchase : 26, 20, 44, 24, 18, 27, 41\nLevel_of_membership : 1, 2, 5, 4, 6, 3, 22\nAddress : Hartford, Bridgeport, Cheshire, Waterbury\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 \"Services\" (\n\t\"Service_ID\" INTEGER NOT NULL, \n\t\"Service_Type_Code\" CHAR(15) NOT NULL, \n\tPRIMARY KEY (\"Service_ID\")\n)\n/*\nColumns in Services and all categories for low cardinality columns :\nService_ID : 8, 2, 5, 6\nService_Type_Code : Marriage, Birth Proof, Death Proof, Property Change\n*/\n \nCREATE TABLE \"Office_locations\" (\n\tbuilding_id INTEGER, \n\tcompany_id INTEGER, \n\tmove_in_year INTEGER, \n\tPRIMARY KEY (building_id, company_id), \n\tFOREIGN KEY(building_id) REFERENCES buildings (id), \n\tFOREIGN KEY(company_id) REFERENCES \"Companies\" (id)\n)\n/*\nColumns in Office_locations and 3 examples in each column for high cardinality columns :\nbuilding_id : 1, 11, 2\nmove_in_year : 2023, 2020, 2022\n*/\n/*\nColumns in Office_locations and all categories for low cardinality columns :\ncompany_id : 1, 11, 2, 5, 19, 7, 4, 3, 10, 9\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 \"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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "What are the dates of the orders made by the customer named \"Jeramie\"?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: orders.date_order_placed, customers.customer_id, orders.customer_id, customers.customer_name, Jeramie.\nThe SQL query I'll be generating is:\nSELECT T2.date_order_placed FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = \"Jeramie\"" } ]
[ { "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 \"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 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 \"Services\" (\n\tservice_id INTEGER, \n\tservice_type_code VARCHAR(15) NOT NULL, \n\tservice_name VARCHAR(80), \n\tservice_descriptio VARCHAR(255), \n\tPRIMARY KEY (service_id)\n)\n/*\nColumns in Services and 3 examples in each column for high cardinality columns :\nservice_id : 1, 13, 11\n*/\n/*\nColumns in Services and all categories for low cardinality columns :\nservice_type_code : Welfare, Health, Education\nservice_name : Welfare, Health, Education\nservice_descriptio : Welfare, Health, Education\n*/\n \nCREATE TABLE \"Scientists\" (\n\t\"SSN\" INTEGER, \n\t\"Name\" CHAR(30) NOT NULL, \n\tPRIMARY KEY (\"SSN\")\n)\n/*\nColumns in Scientists and 3 examples in each column for high cardinality columns :\nSSN : 546523478, 332569843, 845657246\nName : Kumar Swamy, John Doe, David Smith\n*/\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Courses\" (\n\tcourse_id VARCHAR(100) NOT NULL, \n\tcourse_name VARCHAR(120), \n\tcourse_description VARCHAR(255), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (course_id)\n)\n/*\nColumns in Courses and all categories for low cardinality columns :\ncourse_id : 303, 305, 304, 306, 302, 301\ncourse_name : data structure, English, French, statistics, database, Art history\ncourse_description : data structure, English, French, statistics, database, Art history\nother_details : None\n*/\n \nCREATE TABLE instructor (\n\t\"ID\" VARCHAR(5), \n\tname VARCHAR(20) NOT NULL, \n\tdept_name VARCHAR(20), \n\tsalary NUMERIC(8, 2), \n\tPRIMARY KEY (\"ID\"), \n\tFOREIGN KEY(dept_name) REFERENCES department (dept_name), \n\tCHECK (salary > 29000)\n)\n/*\nColumns in instructor and 3 examples in each column for high cardinality columns :\nID : 99052, 6569, 79081\nname : McKinnon, Sarkar, Vicentino\ndept_name : Marketing, Comp. Sci., Statistics\nsalary : 43770.36, 35023.18, 117836.50\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduct_category_code VARCHAR(20) NOT NULL, \n\tdate_product_first_available DATETIME, \n\tdate_product_discontinued DATETIME, \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tproduct_price DECIMAL(19, 4), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\nparent_product_id : 8, 4, 9, 3\nproduct_category_code : Food, Book, Hardware\ndate_product_first_available : 1988-09-29 17:54:50, 1998-06-20 15:04:11, 1994-12-18 15:13:19, 1974-06-25 12:26:47\ndate_product_discontinued : 1987-12-20 13:46:16, 1997-07-02 18:26:16, 1980-06-26 10:40:19, 1991-08-20 05:22:31\nproduct_name : Chocolate, The Great Gatsby, Mouse, Keyboard\nproduct_description : Designed for games, Handmade chocolate, American novel, Blue tooth mouse\nproduct_price : 23.3500, 2.8800, 109.9900, 35.0000\n*/\n \nCREATE TABLE player_coach (\n\t\"Player_ID\" INTEGER, \n\t\"Coach_ID\" INTEGER, \n\t\"Starting_year\" INTEGER, \n\tPRIMARY KEY (\"Player_ID\", \"Coach_ID\"), \n\tFOREIGN KEY(\"Coach_ID\") REFERENCES coach (\"Coach_ID\"), \n\tFOREIGN KEY(\"Player_ID\") REFERENCES player (\"Player_ID\")\n)\n/*\nColumns in player_coach and all categories for low cardinality columns :\nPlayer_ID : 1, 2, 4, 6, 14, 3, 10\nCoach_ID : 1, 2, 5, 3\nStarting_year : 2012, 2010, 2011, 2013\n*/\n \nCREATE TABLE instructor (\n\t\"ID\" VARCHAR(5), \n\tname VARCHAR(20) NOT NULL, \n\tdept_name VARCHAR(20), \n\tsalary NUMERIC(8, 2), \n\tPRIMARY KEY (\"ID\"), \n\tFOREIGN KEY(dept_name) REFERENCES department (dept_name), \n\tCHECK (salary > 29000)\n)\n/*\nColumns in instructor and 3 examples in each column for high cardinality columns :\nID : 99052, 6569, 79081\nname : McKinnon, Sarkar, Vicentino\ndept_name : Marketing, Comp. Sci., Statistics\nsalary : 43770.36, 35023.18, 117836.50\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"CMI_Cross_References\" (\n\tcmi_cross_ref_id INTEGER NOT NULL, \n\tmaster_customer_id INTEGER NOT NULL, \n\tsource_system_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (cmi_cross_ref_id), \n\tFOREIGN KEY(master_customer_id) REFERENCES \"Customer_Master_Index\" (master_customer_id)\n)\n/*\nColumns in CMI_Cross_References and 3 examples in each column for high cardinality columns :\ncmi_cross_ref_id : 65, 75, 102\n*/\n/*\nColumns in CMI_Cross_References and all categories for low cardinality columns :\nmaster_customer_id : 1, 2, 5, 4, 3, 9\nsource_system_code : Rent, Electoral, Business, Parking, Tax, Benefits\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE tweets (\n\tid BIGINT NOT NULL, \n\tuid INTEGER NOT NULL, \n\ttext CHAR(140) NOT NULL, \n\tcreatedate DATETIME DEFAULT CURRENT_TIMESTAMP, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(uid) REFERENCES user_profiles (uid)\n)\n/*\nColumns in tweets and all categories for low cardinality columns :\nid : 1, 2, 5, 7, 8, 4, 6, 9\nuid : 1, 5, 4, 6, 3\ntext : Today I have went shopping at Laffayette., Let’s celebrate women, fight for equality and support each other, not just today, but everyday!, Oh, I only have a few fans., I love my new boyfriend., I feel tired and don't want to write SQLs., My company is hiring interns., Hello I'm Tony Stark., I had a pretty rough time during the last couple of weeks\ncreatedate : 2018-03-09 20:00:14, 2018-03-12 02:30:30, 2018-03-09 20:01:02\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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" }, { "role": "user", "content": "Give me the names of customers who have placed orders between 2009-01-01 and 2010-01-01." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id, orders.date_order_placed, 2009-01-01, 2010-01-01.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= \"2009-01-01\" AND T2.date_order_placed <= \"2010-01-01\"" } ]
[ { "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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduction_type_code VARCHAR(15) NOT NULL, \n\tunit_price DECIMAL(19, 4), \n\tproduct_name VARCHAR(80), \n\tproduct_color VARCHAR(20), \n\tproduct_size VARCHAR(20), \n\tPRIMARY KEY (product_id), \n\tFOREIGN KEY(production_type_code) REFERENCES \"Product_Categories\" (production_type_code)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nunit_price : 49.6200, 563.5800, 729.0900\nproduct_name : Coffee Bean, Art History, Beer Menus\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nparent_product_id : 1, 2, 5, 7, 8, 4, 6, 9\nproduction_type_code : Food, Books, Electronics, DVDs\nproduct_color : Red, Yellow, Black\nproduct_size : Small, Medium, Large\n*/\n \nCREATE TABLE grapes (\n\t\"ID\" INTEGER, \n\t\"Grape\" TEXT, \n\t\"Color\" TEXT, \n\tPRIMARY KEY (\"ID\"), \n\tUNIQUE (\"Grape\")\n)\n/*\nColumns in grapes and 3 examples in each column for high cardinality columns :\nID : 17, 9, 16\nGrape : Marsanne, Tempranillo, Malbec\n*/\n/*\nColumns in grapes and all categories for low cardinality columns :\nColor : Red, White\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE railway_manage (\n\t\"Railway_ID\" INTEGER, \n\t\"Manager_ID\" INTEGER, \n\t\"From_Year\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\", \"Manager_ID\"), \n\tFOREIGN KEY(\"Manager_ID\") REFERENCES manager (\"Manager_ID\"), \n\tFOREIGN KEY(\"Railway_ID\") REFERENCES railway (\"Railway_ID\")\n)\n/*\nColumns in railway_manage and all categories for low cardinality columns :\nRailway_ID : 7, 8, 2, 9\nManager_ID : 1, 2, 4, 3\nFrom_Year : 2012, 2010, 2011, 2013\n*/\n \nCREATE TABLE people (\n\t\"People_ID\" INTEGER, \n\t\"District\" TEXT, \n\t\"Name\" TEXT, \n\t\"Party\" TEXT, \n\t\"Age\" INTEGER, \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, 10, 9\nDistrict : New York 7, New York 1, New York 8, New York 4, New York 3, New York 9, New York 6, New York 2, New York 5, New York 10\nName : Daniel Sickles, George Briggs, James Humphrey, Luther C. Carter, John B. Haskin, William B. Maclay, John Cochrane, Charles Van Wyck, Thomas J. Barr, Horace F. Clark\nParty : Anti-Lecompton Democrat, Democratic, Independent Democrat, Republican\nAge : 38, 46, 45, 48, 43, 36, 42, 35\n*/\n \nCREATE TABLE appellations (\n\t\"No\" INTEGER, \n\t\"Appelation\" TEXT, \n\t\"County\" TEXT, \n\t\"State\" TEXT, \n\t\"Area\" TEXT, \n\t\"isAVA\" TEXT, \n\tPRIMARY KEY (\"No\"), \n\tUNIQUE (\"Appelation\")\n)\n/*\nColumns in appellations and 3 examples in each column for high cardinality columns :\nNo : 53, 56, 49\nAppelation : Anderson Valley, Fiddletown, Mendocino County\nCounty : Monterey, Solano, Santa Barbara\n*/\n/*\nColumns in appellations and all categories for low cardinality columns :\nState : California\nArea : Sierra Foothills, Central Valley, North Coast, Central Coast, N/A, California, Santa Cruz Mountains\nisAVA : Yes, No\n*/\n \nCREATE TABLE \"Products_in_Events\" (\n\t\"Product_in_Event_ID\" INTEGER NOT NULL, \n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Product_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Product_in_Event_ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES \"Events\" (\"Event_ID\"), \n\tFOREIGN KEY(\"Product_ID\") REFERENCES \"Products\" (\"Product_ID\")\n)\n/*\nColumns in Products_in_Events and 3 examples in each column for high cardinality columns :\nProduct_in_Event_ID : 79, 69, 13\n*/\n/*\nColumns in Products_in_Events and all categories for low cardinality columns :\nEvent_ID : 1, 10, 5, 7, 8, 4, 6, 14, 15\nProduct_ID : 26, 45, 20, 11, 18, 34, 6, 3, 10, 29\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 film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\n*/\n \nCREATE TABLE \"Staff\" (\n\tstaff_id INTEGER, \n\tgender VARCHAR(1), \n\tfirst_name VARCHAR(80), \n\tlast_name VARCHAR(80), \n\temail_address VARCHAR(255), \n\tphone_number VARCHAR(80), \n\tPRIMARY KEY (staff_id)\n)\n/*\nColumns in Staff and all categories for low cardinality columns :\nstaff_id : 120, 114, 116, 117, 115, 119, 118\ngender : 1, 0\nfirst_name : Dorian, Austin, Bradly, Ward, Dagmar, Mikel, Lucie\nlast_name : Zieme, Hahn, Oberbrunner, Lynch, Erdman, Boehm, Lowe\nemail_address : ohintz@example.org, brett99@example.net, glen.borer@example.com, reichel.armani@example.org, wrau@example.com, marcelle.ritchie@example.com, richard.gutkowski@example.com\nphone_number : 345-656-5571, 1-132-839-9409x288, 751-262-8424x575, (379)551-0838x146, 142-311-6503x206, (383)553-1035x20399, 155-811-6153\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE team (\n\t\"Team_id\" INTEGER, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Team_id\")\n)\n/*\nColumns in team and all categories for low cardinality columns :\nTeam_id : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Enrique Osinski, Berneice Hand, Columbus Crew, Evalyn Feil, D.C. United, Anais VonRueden, Ryley Goldner, Miami Fusion, Los Angeles Galaxy, Brown Erdman\n*/\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 workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\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 \"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" }, { "role": "user", "content": "Which customers made orders between 2009-01-01 and 2010-01-01? Find their names." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id, orders.date_order_placed, 2009-01-01, 2010-01-01.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= \"2009-01-01\" AND T2.date_order_placed <= \"2010-01-01\"" } ]
[ { "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 \"Document_Sections\" (\n\tsection_id INTEGER, \n\tdocument_code VARCHAR(15) NOT NULL, \n\tsection_sequence INTEGER, \n\tsection_code VARCHAR(20), \n\tsection_title VARCHAR(80), \n\tPRIMARY KEY (section_id), \n\tFOREIGN KEY(document_code) REFERENCES \"Documents\" (document_code)\n)\n/*\nColumns in Document_Sections and 3 examples in each column for high cardinality columns :\nsection_id : 89, 62, 38\ndocument_code : 714, 217, 566\nsection_sequence : 5552, 4433, 8805\nsection_code : 91, 16, 38\n*/\n/*\nColumns in Document_Sections and all categories for low cardinality columns :\nsection_title : after, before\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Scientists\" (\n\t\"SSN\" INTEGER, \n\t\"Name\" CHAR(30) NOT NULL, \n\tPRIMARY KEY (\"SSN\")\n)\n/*\nColumns in Scientists and 3 examples in each column for high cardinality columns :\nSSN : 546523478, 332569843, 845657246\nName : Kumar Swamy, John Doe, David Smith\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\torder_quantity VARCHAR(80), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\norder_id : 13, 11, 5\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 13, 11, 2, 5, 4, 6, 12, 3, 15, 9\norder_quantity : 2, 5, 7, 8, 4, 3, 9, male\n*/\n \nCREATE TABLE routes (\n\trid INTEGER, \n\tdst_apid INTEGER, \n\tdst_ap VARCHAR(4), \n\tsrc_apid BIGINT, \n\tsrc_ap VARCHAR(4), \n\talid BIGINT, \n\tairline VARCHAR(4), \n\tcodeshare TEXT, \n\tPRIMARY KEY (rid), \n\tFOREIGN KEY(dst_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(src_apid) REFERENCES airports (apid), \n\tFOREIGN KEY(alid) REFERENCES airlines (alid)\n)\n/*\nColumns in routes and 3 examples in each column for high cardinality columns :\nrid : 87, 56, 65\ndst_apid : 7165, 8076, 1044\ndst_ap : SYB, JKG, IKT\nsrc_apid : 8076, 1044, 2990\nsrc_ap : SYB, JKG, IKT\n*/\n/*\nColumns in routes and all categories for low cardinality columns :\nalid : 146, 8359, 470, 1338, 410, 3652, 897, 1654, 2750\nairline : 2G, 2P, 2, 2J, 2O, 2I, 2B, 2K\ncodeshare : None, Y\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 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 \"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 game (\n\tstadium_id INTEGER, \n\tid INTEGER, \n\t\"Season\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Home_team\" TEXT, \n\t\"Away_team\" TEXT, \n\t\"Score\" TEXT, \n\t\"Competition\" TEXT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(stadium_id) REFERENCES stadium (id)\n)\n/*\nColumns in game and 3 examples in each column for high cardinality columns :\nstadium_id : 1, 11, 2\nid : 17, 9, 16\nDate : 30 June 2013, 18 May 2007, 8 August 2009\nScore : 0–0 (7:6), –, 1–3\n*/\n/*\nColumns in game and all categories for low cardinality columns :\nSeason : 2009, 2013, 2008, 2012, 2011, 2010, 2007\nHome_team : Pakhtakor, Bunyodkor, Quruvchi\nAway_team : Pakhtakor, Bunyodkor, Quruvchi\nCompetition : League, Supercup, Cup\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 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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n" }, { "role": "user", "content": "Give me a list of distinct product ids from orders placed between 1975-01-01 and 1976-01-01?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items.\nFrom these tables, I'll be using the following columns: order_items.product_id, orders.order_id, order_items.order_id, orders.date_order_placed, 1975-01-01, 1976-01-01.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= \"1975-01-01\" AND T1.date_order_placed <= \"1976-01-01\"" } ]
[ { "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 book_club (\n\tbook_club_id INTEGER, \n\t\"Year\" INTEGER, \n\t\"Author_or_Editor\" TEXT, \n\t\"Book_Title\" TEXT, \n\t\"Publisher\" TEXT, \n\t\"Category\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (book_club_id)\n)\n/*\nColumns in book_club and 3 examples in each column for high cardinality columns :\nbook_club_id : 1, 11, 2\nAuthor_or_Editor : Dolores Klaich, Antoinette Azolakov, Sandy Bayer\nBook_Title : Lessons In Murder, Somewhere in the Night, Mundaneӳ World\n*/\n/*\nColumns in book_club and all categories for low cardinality columns :\nYear : 1989, 1990\nPublisher : International Polygonics, William Morrow, St. Martin's Press, Crossing Press, Alyson, Naiad Press, Banned Books, Mysterious Press\nCategory : Lesb. M/SF, Gay SF/F, Gay M/SF\nResult : Nom, Won [B ], Won, Won [A ]\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE medicine (\n\tid INTEGER, \n\tname TEXT, \n\t\"Trade_Name\" TEXT, \n\t\"FDA_approved\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in medicine and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Quetiapine, Carpipramine, Asenapine\nTrade_Name : Buronil, Fanapt, Nipolept\n*/\n/*\nColumns in medicine and all categories for low cardinality columns :\nFDA_approved : Yes, No\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 workshop (\n\t\"Workshop_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Venue\" TEXT, \n\t\"Name\" TEXT, \n\tPRIMARY KEY (\"Workshop_ID\")\n)\n/*\nColumns in workshop and all categories for low cardinality columns :\nWorkshop_ID : 1, 2, 5, 4, 6, 3\nDate : July 5, 2011, August 21, 2007, October 8, 2007, January 14, 2008, August 25, 2007, August 18, 2007\nVenue : London UK, New York USA, Istanbul Turkey, New Jersey USA\nName : Workshop 2007, 2008 qualification, Anual Workshop 2011, ABC 2007, 2007 qualification, Conference 2007\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 film (\n\t\"Film_ID\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Studio\" TEXT, \n\t\"Director\" TEXT, \n\t\"Gross_in_dollar\" INTEGER, \n\tPRIMARY KEY (\"Film_ID\")\n)\n/*\nColumns in film and 3 examples in each column for high cardinality columns :\nFilm_ID : 1, 13, 11\nTitle : Annie, Rocky III, Tootsie\nDirector : Richard Attenborough, Nicholas Meyer, Ted Kotcheff\nGross_in_dollar : 53977250, 76606280, 125049125\n*/\n/*\nColumns in film and all categories for low cardinality columns :\nStudio : MGM, United Artists, Universal, 20th Century Fox, Columbia, Paramount, Columbia / Rastar, Paramount / Lorimar, Orion / Carolco, Universal / RKO\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 technician (\n\ttechnician_id REAL, \n\t\"Name\" TEXT, \n\t\"Team\" TEXT, \n\t\"Starting_Year\" REAL, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (technician_id)\n)\n/*\nColumns in technician and all categories for low cardinality columns :\ntechnician_id : 3.0, 8.0, 10.0, 1.0, 7.0, 2.0, 6.0, 9.0, 4.0, 5.0\nName : Mark Sewell, John Brown, Mickey Cochrane, Joe Sewell, Tony Sewell, Joe Cochrane, Eddie Collins, Charlie Hollocher, Lou Boudreau\nTeam : CHC, NYY, CLE, PHA, CWS\nStarting_Year : 2013.0, 2016.0, 2003.0, 2006.0, 2005.0, 2002.0, 2009.0, 2012.0\nAge : 38, 37, 45, 46, 28, 36, 32, 47, 43, 35\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE country (\n\t\"Country_id\" INTEGER, \n\t\"Country_name\" TEXT, \n\t\"Capital\" TEXT, \n\t\"Official_native_language\" TEXT, \n\tPRIMARY KEY (\"Country_id\")\n)\n/*\nColumns in country and all categories for low cardinality columns :\nCountry_id : 1, 2, 5, 4, 6, 3\nCountry_name : Isle of Man, Iran, United States, Indonesia, Iraq, Ireland\nCapital : Jakarta, Baghdad, Dublin, Tehran, Douglas, Washington\nOfficial_native_language : Arabic ( Arabic script ) Kurdish, English Manx, Persian ( Arabic script ), English, Bahasa Indonesia, Irish English\n*/\n \nCREATE TABLE \"Product_Characteristics\" (\n\tproduct_id INTEGER NOT NULL, \n\tcharacteristic_id INTEGER NOT NULL, \n\tproduct_characteristic_value VARCHAR(50), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(characteristic_id) REFERENCES \"Characteristics\" (characteristic_id)\n)\n/*\nColumns in Product_Characteristics and all categories for low cardinality columns :\nproduct_id : 1, 13, 11, 5, 7, 8, 6, 12, 14\ncharacteristic_id : 13, 10, 11, 2, 4, 6, 12, 3, 15\nproduct_characteristic_value : high, low, medium\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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" }, { "role": "user", "content": "What are the distinct ids of products ordered between 1975-01-01 and 1976-01-01??" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items.\nFrom these tables, I'll be using the following columns: order_items.product_id, orders.order_id, order_items.order_id, orders.date_order_placed, 1975-01-01, 1976-01-01.\nThe SQL query I'll be generating is:\nSELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= \"1975-01-01\" AND T1.date_order_placed <= \"1976-01-01\"" } ]
[ { "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 \"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 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 \"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 mountain (\n\tid INTEGER, \n\tname TEXT, \n\t\"Height\" REAL, \n\t\"Prominence\" REAL, \n\t\"Range\" TEXT, \n\t\"Country\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in mountain and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Kaka / Kecha / Chiqe, Aksouâl, Ioll / Yoll\nHeight : 4167.0, 4120.0, 4071.0\nProminence : 1540.0, 3931.0, 610.0\nRange : Toubkal Atlas, Aberdare Range, Semien Mountains\n*/\n/*\nColumns in mountain and all categories for low cardinality columns :\nCountry : Cameroon, Morocco, Kenya, Rwanda Uganda, Ethiopia\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 \nCREATE TABLE \"Companies\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value_billion\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Companies and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : PetroChina, Berkshire Hathaway, Petrobras\nSales_billion : 69.2, 189.6, 421.8\nProfits_billion : 16.4, 19.9, 17.4\nAssets_billion : 2467.9, 192.8, 1913.9\nMarket_Value_billion : 239.5, 186.5, 224.8\n*/\n/*\nColumns in Companies and all categories for low cardinality columns :\nHeadquarters : Spain, UK, China, Brazil, France, Russia, USA, Netherlands\nIndustry : Retailing, Conglomerate, Oil and gas, Telecommunications, Banking\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 happy_hour_member (\n\t\"HH_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Total_amount\" REAL, \n\tPRIMARY KEY (\"HH_ID\", \"Member_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in happy_hour_member and all categories for low cardinality columns :\nHH_ID : 1, 2, 5, 7, 8, 4\nMember_ID : 5, 9, 3\nTotal_amount : 4.9, 4.2, 20.9, 16.9, 16.92, 20.92\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 nomination (\n\t\"Artwork_ID\" INTEGER, \n\t\"Festival_ID\" INTEGER, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"Artwork_ID\", \"Festival_ID\"), \n\tFOREIGN KEY(\"Festival_ID\") REFERENCES festival_detail (\"Festival_ID\"), \n\tFOREIGN KEY(\"Artwork_ID\") REFERENCES artwork (\"Artwork_ID\")\n)\n/*\nColumns in nomination and all categories for low cardinality columns :\nArtwork_ID : 1, 2, 8, 4, 3, 9\nFestival_ID : 1, 2, 5\nResult : Nominated, Won\n*/\n \nCREATE TABLE \"Apartment_Facilities\" (\n\tapt_id INTEGER NOT NULL, \n\tfacility_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (apt_id, facility_code), \n\tFOREIGN KEY(apt_id) REFERENCES \"Apartments\" (apt_id)\n)\n/*\nColumns in Apartment_Facilities and all categories for low cardinality columns :\napt_id : 1, 2, 5, 6, 3, 15, 9\nfacility_code : Gym, Swimming Pool, Boardband, Cable TV\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE furniture (\n\t\"Furniture_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Num_of_Component\" INTEGER, \n\t\"Market_Rate\" REAL, \n\tPRIMARY KEY (\"Furniture_ID\")\n)\n/*\nColumns in furniture and all categories for low cardinality columns :\nFurniture_ID : 1, 2, 5, 7, 4, 6, 3\nName : Dining set, Chabudai, Billiard table, Hatstand, Bookcase, Four-poster bed, Bench\nNum_of_Component : 5, 4, 6, 14, 3, 12\nMarket_Rate : 1.0, 3.5, 52.5, 0.5, 40.0, 2.0\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"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 stadium (\n\t\"ID\" INTEGER, \n\tname TEXT, \n\t\"Capacity\" INTEGER, \n\t\"City\" TEXT, \n\t\"Country\" TEXT, \n\t\"Opening_year\" INTEGER, \n\tPRIMARY KEY (\"ID\")\n)\n/*\nColumns in stadium and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Northumberland Development Project, Fisht Olympic Stadium, Ferenc Puskás Stadion, Nou Mestalla, Yubileyniy Stadium, Estadio La Peineta, Baku Olympic Stadium, Arena Baltika, Stade des Lumières, Gazprom Arena\nCapacity : 61556, 69501, 56250, 68000, 47659, 45015, 67500, 75000, 65000\nCity : London, Sochi, Budapest, Saint Petersburg, Baku, Kaliningrad, Madrid, Valencia, Lyon, Saransk\nCountry : Spain, France, England, Russia, Azerbaijan, Hungary\nOpening_year : 2004, 2005, 2007, 2006\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"CHECKING\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in CHECKING and all categories for low cardinality columns :\ncustid : 1, 2, 5, 7, 4, 6, 3\nbalance : 3000.0, 10000.0, 2000.0, 7.0, 7000.0, 77.0\n*/\n" }, { "role": "user", "content": "Find the names of the customers who have order status both \"On Road\" and \"Shipped\"." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id, orders.order_status, On Road, Shipped.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"On Road\" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"Shipped\"" } ]
[ { "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 film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\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 \"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 \"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 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 \"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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Invoice\" (\n\t\"InvoiceId\" INTEGER NOT NULL, \n\t\"CustomerId\" INTEGER NOT NULL, \n\t\"InvoiceDate\" DATETIME NOT NULL, \n\t\"BillingAddress\" VARCHAR(70) DEFAULT NULL, \n\t\"BillingCity\" VARCHAR(40) DEFAULT NULL, \n\t\"BillingState\" VARCHAR(40) DEFAULT NULL, \n\t\"BillingCountry\" VARCHAR(40) DEFAULT NULL, \n\t\"BillingPostalCode\" VARCHAR(10) DEFAULT NULL, \n\t\"Total\" DECIMAL(10, 2) NOT NULL, \n\tPRIMARY KEY (\"InvoiceId\"), \n\tFOREIGN KEY(\"CustomerId\") REFERENCES \"Customer\" (\"CustomerId\")\n)\n/*\nColumns in Invoice and 3 examples in each column for high cardinality columns :\nInvoiceId : 87, 56, 65\nCustomerId : 53, 56, 49\nInvoiceDate : 2009-06-10 00:00:00, 2010-05-30 00:00:00, 2011-02-16 00:00:00\nBillingAddress : 696 Osborne Street, 796 Dundas Street West, Grétrystraat 63\nBillingCity : Oslo, Lisbon, Mountain View\nBillingState : AZ, NSW, Dublin\nBillingCountry : Sweden, Australia, India\nBillingPostalCode : B3S 1C5, 85719, 1106\nTotal : 3.96, 17.91, 15.86\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Trained_In\" (\n\t\"Physician\" INTEGER NOT NULL, \n\t\"Treatment\" INTEGER NOT NULL, \n\t\"CertificationDate\" DATETIME NOT NULL, \n\t\"CertificationExpires\" DATETIME NOT NULL, \n\tPRIMARY KEY (\"Physician\", \"Treatment\"), \n\tCONSTRAINT \"fk_Trained_In_Physician_EmployeeID\" FOREIGN KEY(\"Physician\") REFERENCES \"Physician\" (\"EmployeeID\"), \n\tCONSTRAINT \"fk_Trained_In_Procedures_Code\" FOREIGN KEY(\"Treatment\") REFERENCES \"Procedures\" (\"Code\")\n)\n/*\nColumns in Trained_In and all categories for low cardinality columns :\nPhysician : 7, 6, 3\nTreatment : 1, 2, 5, 7, 4, 6, 3\nCertificationDate : 2008-01-01 00:00:00, 2007-01-01 00:00:00\nCertificationExpires : 2007-12-31 00:00:00, 2008-12-31 00:00:00\n*/\n \nCREATE TABLE news_report (\n\t\"journalist_ID\" INTEGER, \n\t\"Event_ID\" INTEGER, \n\t\"Work_Type\" TEXT, \n\tPRIMARY KEY (\"journalist_ID\", \"Event_ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES event (\"Event_ID\"), \n\tFOREIGN KEY(\"journalist_ID\") REFERENCES journalist (\"journalist_ID\")\n)\n/*\nColumns in news_report and all categories for low cardinality columns :\njournalist_ID : 1, 11, 7, 8, 4, 6\nEvent_ID : 1, 2, 5, 4, 3\nWork_Type : Screening, Host, Music\n*/\n" }, { "role": "user", "content": "Which customers have both \"On Road\" and \"Shipped\" as order status? List the customer names." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id, orders.order_status, On Road, Shipped.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"On Road\" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"Shipped\"" } ]
[ { "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 \"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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE election (\n\t\"Election_ID\" INTEGER, \n\t\"Representative_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Votes\" REAL, \n\t\"Vote_Percent\" REAL, \n\t\"Seats\" REAL, \n\t\"Place\" REAL, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"Representative_ID\") REFERENCES representative (\"Representative_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 4, 3\nRepresentative_ID : 1, 2, 5, 7, 4\nDate : 1946, 1949, July 1942, October 1942, 1953\nVotes : 11059.0, 9423.0, 13049.0, 12422.0, 14077.0\nVote_Percent : 16.0, 19.5, 16.2, 18.5\nSeats : 10.0, 6.0, 7.0, 9.0\nPlace : 3.0, 1.0, 2.0\n*/\n \nCREATE TABLE \"Restaurant\" (\n\t\"ResID\" INTEGER, \n\t\"ResName\" VARCHAR(100), \n\t\"Address\" VARCHAR(100), \n\t\"Rating\" INTEGER, \n\tPRIMARY KEY (\"ResID\")\n)\n/*\nColumns in Restaurant and all categories for low cardinality columns :\nResID : 1, 2\nResName : Subway, Honeygrow\nAddress : 3212 St Paul St, Baltimore, MD 21218, 3233 St Paul St, Baltimore, MD 21218\nRating : 4, 3\n*/\n \nCREATE TABLE \"Institution\" (\n\t\"Institution_id\" TEXT, \n\t\"Institution\" TEXT, \n\t\"Location\" TEXT, \n\t\"Founded\" REAL, \n\t\"Type\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"Team\" TEXT, \n\t\"Primary_Conference\" TEXT, \n\tbuilding_id TEXT, \n\tPRIMARY KEY (\"Institution_id\"), \n\tFOREIGN KEY(building_id) REFERENCES building (building_id)\n)\n/*\nColumns in Institution and 3 examples in each column for high cardinality columns :\nInstitution_id : 1, 2, 5\nInstitution : Ave Maria University, Lindenwood University–Belleville, Point University\nLocation : Mayville, North Dakota, Jacksonville, Florida, Babson Park, Florida\nEnrollment : 967, 616, 3102\nTeam : Gyrenes, Comets, Warriors\n*/\n/*\nColumns in Institution and all categories for low cardinality columns :\nFounded : 1937.0, 1881.0, 1927.0, 2003.0, 1883.0, 1866.0, 1998.0, 1884.0, 1889.0, 1890.0\nType : Public, Tribal, Private\nPrimary_Conference : MCAC, CalPac, Gulf Coast (GCAC), AAC, none, The Sun\nbuilding_id : 1, 2, 5, 7, 4, 3, 0\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 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 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 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 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 \"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 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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE phone (\n\t\"Name\" TEXT, \n\t\"Phone_ID\" INTEGER, \n\t\"Memory_in_G\" INTEGER, \n\t\"Carrier\" TEXT, \n\t\"Price\" REAL, \n\tPRIMARY KEY (\"Phone_ID\")\n)\n/*\nColumns in phone and all categories for low cardinality columns :\nName : IPhone 6s, IPhone 7, IPhone X, IPhone 6, IPhone 5s\nPhone_ID : 1, 2, 5, 4, 3\nMemory_in_G : 128, 32, 16, 64\nCarrier : Sprint, TMobile\nPrice : 320.0, 1000.0, 480.0, 899.0, 699.0\n*/\n" }, { "role": "user", "content": "Find the id of the customers who have order status both \"On Road\" and \"Shipped\"." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_id, orders.customer_id, orders.order_status, On Road, Shipped.\nThe SQL query I'll be generating is:\nSELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"On Road\" INTERSECT SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"Shipped\"" } ]
[ { "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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"PROFESSOR\" (\n\t\"EMP_NUM\" INTEGER, \n\t\"DEPT_CODE\" VARCHAR(10), \n\t\"PROF_OFFICE\" VARCHAR(50), \n\t\"PROF_EXTENSION\" VARCHAR(4), \n\t\"PROF_HIGH_DEGREE\" VARCHAR(5), \n\tFOREIGN KEY(\"EMP_NUM\") REFERENCES \"EMPLOYEE\" (\"EMP_NUM\"), \n\tFOREIGN KEY(\"DEPT_CODE\") REFERENCES \"DEPARTMENT\" (\"DEPT_CODE\")\n)\n/*\nColumns in PROFESSOR and 3 examples in each column for high cardinality columns :\nEMP_NUM : 387, 301, 155\nDEPT_CODE : ECON/FIN, ART, HIST\nPROF_OFFICE : KLR 203E, BBG 208, AAK 230\nPROF_EXTENSION : 2248, 2851, 4436\n*/\n/*\nColumns in PROFESSOR and all categories for low cardinality columns :\nPROF_HIGH_DEGREE : Ph.D., MBA, MA, DBA\n*/\n \nCREATE TABLE \"Addresses\" (\n\taddress_id INTEGER, \n\tline_1 VARCHAR(120), \n\tline_2 VARCHAR(120), \n\tline_3 VARCHAR(120), \n\tcity VARCHAR(80), \n\tzip_postcode VARCHAR(20), \n\tstate_province_county VARCHAR(50), \n\tcountry VARCHAR(50), \n\tother_address_details VARCHAR(255), \n\tPRIMARY KEY (address_id)\n)\n/*\nColumns in Addresses and 3 examples in each column for high cardinality columns :\naddress_id : 17, 9, 16\nline_1 : 056 Murphy Stravenue Apt. 600, 39834 Anne Mission Apt. 956, 18327 Jaime Terrace Suite 343\ncity : North Jayceton, Elinoreport, Hegmannborough\nzip_postcode : 937, 002, 607\nstate_province_county : Hawaii, Tennessee, NewYork\n*/\n/*\nColumns in Addresses and all categories for low cardinality columns :\nline_2 : None\nline_3 : None\ncountry : USA\nother_address_details : None\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 \"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 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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Ref_Product_Categories\" (\n\tproduct_category_code VARCHAR(15), \n\tproduct_category_description VARCHAR(80), \n\tunit_of_measure VARCHAR(20), \n\tPRIMARY KEY (product_category_code)\n)\n/*\nColumns in Ref_Product_Categories and all categories for low cardinality columns :\nproduct_category_code : Spices, Seeds, Herbs\nproduct_category_description : Spices, Seeds, Herbs\nunit_of_measure : Weight - pound,kilo., Handful \n*/\n \nCREATE TABLE election (\n\t\"Election_ID\" INTEGER, \n\t\"Representative_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Votes\" REAL, \n\t\"Vote_Percent\" REAL, \n\t\"Seats\" REAL, \n\t\"Place\" REAL, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"Representative_ID\") REFERENCES representative (\"Representative_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 4, 3\nRepresentative_ID : 1, 2, 5, 7, 4\nDate : 1946, 1949, July 1942, October 1942, 1953\nVotes : 11059.0, 9423.0, 13049.0, 12422.0, 14077.0\nVote_Percent : 16.0, 19.5, 16.2, 18.5\nSeats : 10.0, 6.0, 7.0, 9.0\nPlace : 3.0, 1.0, 2.0\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"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 \"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 \"Residents_Services\" (\n\tresident_id INTEGER NOT NULL, \n\tservice_id INTEGER NOT NULL, \n\tdate_moved_in DATETIME, \n\tproperty_id INTEGER, \n\tdate_requested DATETIME, \n\tdate_provided DATETIME, \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (resident_id, service_id), \n\tFOREIGN KEY(service_id) REFERENCES \"Services\" (service_id), \n\tFOREIGN KEY(resident_id, property_id, date_moved_in) REFERENCES \"Residents\" (resident_id, property_id, date_moved_in)\n)\n/*\nColumns in Residents_Services and 3 examples in each column for high cardinality columns :\nresident_id : 87, 67, 45\ndate_requested : 2017-07-14 19:03:47, 2016-07-25 01:32:23, 2016-06-18 20:09:24\ndate_provided : 2017-10-17 03:30:08, 2017-10-28 12:36:43, 2017-08-08 11:24:50\n*/\n/*\nColumns in Residents_Services and all categories for low cardinality columns :\nservice_id : 87, 65, 11, 49, 36, 10, 29, 41\ndate_moved_in : 2016-09-27 12:00:00, 2017-06-17 15:43:33, 2015-03-27 12:00:00\nproperty_id : 954, 120, 108, 629, 373, 748, 669, 445, 879, 107\nother_details : Satisfied, Unsatisfied\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 player (\n\t\"Player_ID\" INTEGER, \n\t\"Player\" TEXT, \n\t\"Team\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Position\" TEXT, \n\t\"School_ID\" INTEGER, \n\tPRIMARY KEY (\"Player_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in player and 3 examples in each column for high cardinality columns :\nPlayer_ID : 17, 21, 9\nPlayer : Buster Posey, Brett Wallace, Timothy Beckham\nTeam : Los Angeles Dodgers, San Diego Padres, Toronto Blue Jays\n*/\n/*\nColumns in player and all categories for low cardinality columns :\nAge : 16, 18, 17, 14, 15\nPosition : Second baseman, Outfielder, Left-handed pitcher, Shortstop, Third baseman, First baseman, First Baseman, Catcher, Right-handed pitcher\nSchool_ID : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\nproduct_id : 13, 11, 2\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\norder_id : 1, 13, 5, 7, 8, 6, 14, 12, 15, 9\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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" }, { "role": "user", "content": "Which customers have both \"On Road\" and \"Shipped\" as order status? List the customer ids." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_id, orders.customer_id, orders.order_status, On Road, Shipped.\nThe SQL query I'll be generating is:\nSELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"On Road\" INTERSECT SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = \"Shipped\"" } ]
[ { "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 employees (\n\t\"EMPLOYEE_ID\" DECIMAL(6, 0) DEFAULT '0' NOT NULL, \n\t\"FIRST_NAME\" VARCHAR(20) DEFAULT NULL, \n\t\"LAST_NAME\" VARCHAR(25) NOT NULL, \n\t\"EMAIL\" VARCHAR(25) NOT NULL, \n\t\"PHONE_NUMBER\" VARCHAR(20) DEFAULT NULL, \n\t\"HIRE_DATE\" DATE NOT NULL, \n\t\"JOB_ID\" VARCHAR(10) NOT NULL, \n\t\"SALARY\" DECIMAL(8, 2) DEFAULT NULL, \n\t\"COMMISSION_PCT\" DECIMAL(2, 2) DEFAULT NULL, \n\t\"MANAGER_ID\" DECIMAL(6, 0) DEFAULT NULL, \n\t\"DEPARTMENT_ID\" DECIMAL(4, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"EMPLOYEE_ID\"), \n\tFOREIGN KEY(\"DEPARTMENT_ID\") REFERENCES departments (\"DEPARTMENT_ID\"), \n\tFOREIGN KEY(\"JOB_ID\") REFERENCES jobs (\"JOB_ID\")\n)\n/*\nColumns in employees and 3 examples in each column for high cardinality columns :\nEMPLOYEE_ID : 135, 187, 194\nFIRST_NAME : Randall, Adam, Susan\nLAST_NAME : Mourgos, Baida, Ande\nEMAIL : SSTILES, SMAVRIS, GHIMURO\nPHONE_NUMBER : 515.123.8080, 515.127.4563, 011.44.1346.629268\nHIRE_DATE : 1987-07-25, 1987-07-09, 1987-06-29\nJOB_ID : HR_REP, ST_MAN, AD_PRES\nSALARY : 2500.00, 8000.00, 8600.00\nMANAGER_ID : 102, 147, 122\nDEPARTMENT_ID : 110, 100, 20\n*/\n/*\nColumns in employees and all categories for low cardinality columns :\nCOMMISSION_PCT : 0.00, 0.35, 0.25, 0.10, 0.15, 0.20, 0.30, 0.40\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 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 \"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 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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE school (\n\t\"School_ID\" INTEGER, \n\t\"Grade\" TEXT, \n\t\"School\" TEXT, \n\t\"Location\" TEXT, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"School_ID\")\n)\n/*\nColumns in school and all categories for low cardinality columns :\nSchool_ID : 1, 2, 5, 7, 4, 6, 3\nGrade : Freshman–Sophomore year, 1st-3rd grade, Kindergarten, Junior–Senior year, College, 5th-12th grade, 4th grade\nSchool : Occidental College, Noelani Elementary School, Harvard Law School, Columbia University, Punahou School, St. Francis Assisi, State Elementary School Menteng 01\nLocation : Cambridge, Massachusetts, Honolulu, Hawaii, Jakarta, Indonesia, Los Angeles, California, New York City\nType : Public, Private Catholic, Private\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 pilot_record (\n\t\"Record_ID\" INTEGER, \n\t\"Pilot_ID\" INTEGER, \n\t\"Aircraft_ID\" INTEGER, \n\t\"Date\" TEXT, \n\tPRIMARY KEY (\"Pilot_ID\", \"Aircraft_ID\", \"Date\"), \n\tFOREIGN KEY(\"Aircraft_ID\") REFERENCES aircraft (\"Aircraft_ID\"), \n\tFOREIGN KEY(\"Pilot_ID\") REFERENCES pilot (\"Pilot_ID\")\n)\n/*\nColumns in pilot_record and all categories for low cardinality columns :\nRecord_ID : 1, 2, 5, 4, 6, 3\nPilot_ID : 1, 2, 4, 3\nAircraft_ID : 1, 2, 5, 4, 6\nDate : 2006/01/04, 2005/01/04, 2008/01/04, 2004/01/04, 2007/01/04, 2003/01/04\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 \"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 \"EMPLOYEE\" (\n\t\"EMP_NUM\" INTEGER, \n\t\"EMP_LNAME\" VARCHAR(15), \n\t\"EMP_FNAME\" VARCHAR(12), \n\t\"EMP_INITIAL\" VARCHAR(1), \n\t\"EMP_JOBCODE\" VARCHAR(5), \n\t\"EMP_HIREDATE\" DATETIME, \n\t\"EMP_DOB\" DATETIME, \n\tPRIMARY KEY (\"EMP_NUM\")\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 \"Accounts\" (\n\taccount_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tdate_account_opened DATETIME, \n\taccount_name VARCHAR(50), \n\tother_account_details VARCHAR(255), \n\tPRIMARY KEY (account_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Accounts and 3 examples in each column for high cardinality columns :\naccount_id : 1, 13, 11\ndate_account_opened : 2016-07-30 22:22:24, 2016-04-25 21:49:17, 2017-05-29 16:45:17\naccount_name : 601, 398, 900\n*/\n/*\nColumns in Accounts and all categories for low cardinality columns :\ncustomer_id : 13, 8, 6, 12, 3, 15, 9\nother_account_details : VIP, Regular\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "When was the order placed whose shipment tracking number is 3452? Give me the date." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, shipments.\nFrom these tables, I'll be using the following columns: orders.date_order_placed, orders.order_id, shipments.order_id, shipments.shipment_tracking_number.\nThe SQL query I'll be generating is:\nSELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452" } ]
[ { "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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"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 \"Club\" (\n\t\"ClubID\" INTEGER, \n\t\"ClubName\" VARCHAR(40), \n\t\"ClubDesc\" VARCHAR(1024), \n\t\"ClubLocation\" VARCHAR(40), \n\tPRIMARY KEY (\"ClubID\")\n)\n/*\nColumns in Club and all categories for low cardinality columns :\nClubID : 1, 2, 4, 3\nClubName : Bootup Baltimore, Pen and Paper Gaming, Tennis Club, Hopkins Student Enterprises\nClubDesc : Venture capital fund for student business., A competitive tennis club., Refurbish computers; teach kids and adults about computer basics., Play pen and paper games on campus.\nClubLocation : HHH, AKW\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 church (\n\t\"Church_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Organized_by\" TEXT, \n\t\"Open_Date\" INTEGER, \n\t\"Continuation_of\" TEXT, \n\tPRIMARY KEY (\"Church_ID\")\n)\n/*\nColumns in church and all categories for low cardinality columns :\nChurch_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Pure Church of Christ, True Church of Jesus Christ of Latter Day Saints, Alston Church, Church of Christ, Church of Jesus Christ, the Bride, the Lamb's Wife, Church of Christ (Parrishite), Independent Church\nOrganized_by : Hiram Page, George M. Hinkle, Isaac Russell, Wycam Clark, Ezra Booth, William Chubby, William Law, – Hoton, Warren Parrish\nOpen_Date : 1840, 1839, 1836, 1832, 1837, 1844, 1831, 1830, 1842\nContinuation_of : Church of Jesus Christ of Latter Day Saints, Church of Christ, Church of the Latter Day Saints\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 \"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 host (\n\t\"Host_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Age\" TEXT, \n\tPRIMARY KEY (\"Host_ID\")\n)\n/*\nColumns in host and all categories for low cardinality columns :\nHost_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Lloyd Daniels, Kornel David, Antonio Davis, Carlos Delfino, DeMar DeRozan, Ed Davis, Austin Daye, Derrick Dial, Justin Dentmon, Hubert Davis\nNationality : United States, Argentina, Hungary\nAge : 26, 45, 37, 40, 30, 60, 47, 43, 31\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE endowment (\n\tendowment_id INTEGER, \n\t\"School_id\" INTEGER, \n\tdonator_name TEXT, \n\tamount REAL, \n\tPRIMARY KEY (endowment_id), \n\tFOREIGN KEY(\"School_id\") REFERENCES \"School\" (\"School_id\")\n)\n/*\nColumns in endowment and 3 examples in each column for high cardinality columns :\nendowment_id : 1, 11, 2\ndonator_name : Santo Domingo Este, Duarte, San Cristóbal\namount : 9.05, 8.82, 8.85\n*/\n/*\nColumns in endowment and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 7, 8, 4, 6, 3\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Product_Suppliers\" (\n\tproduct_id INTEGER NOT NULL, \n\tsupplier_id INTEGER NOT NULL, \n\tdate_supplied_from DATETIME NOT NULL, \n\tdate_supplied_to DATETIME, \n\ttotal_amount_purchased VARCHAR(80), \n\ttotal_value_purchased DECIMAL(19, 4), \n\tPRIMARY KEY (product_id, supplier_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(supplier_id) REFERENCES \"Suppliers\" (supplier_id)\n)\n/*\nColumns in Product_Suppliers and 3 examples in each column for high cardinality columns :\ndate_supplied_from : 2017-09-19 02:14:02, 2017-08-22 00:58:42, 2017-06-25 14:59:40\ndate_supplied_to : 2018-03-24 19:29:18, 2018-03-23 19:21:12, 2018-03-24 12:35:08\ntotal_amount_purchased : 25318.21, 32881.38, 20447.99\ntotal_value_purchased : 98086.8000, 36014.6000, 36274.5600\n*/\n/*\nColumns in Product_Suppliers and all categories for low cardinality columns :\nproduct_id : 11, 5, 7, 8, 4, 6, 14, 3, 15\nsupplier_id : 1, 2, 4, 3\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE member (\n\t\"Member_ID\" TEXT, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Role\" TEXT, \n\tPRIMARY KEY (\"Member_ID\")\n)\n/*\nColumns in member and 3 examples in each column for high cardinality columns :\nMember_ID : 1, 11, 2\n*/\n/*\nColumns in member and all categories for low cardinality columns :\nName : Andrew Moten, Juan Espil, Luis González, Corey Allen, John Eubanks, Charlie Burke, Joseph Bunn, Héctor Campana, Joshua Pittman, Wilfredo Ruiz\nNationality : United States, Uruguay, Argentina\nRole : Cello, Viola, Bass, Prime Violin, Violin\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" }, { "role": "user", "content": "On which day was the order placed whose shipment tracking number is 3452?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, shipments.\nFrom these tables, I'll be using the following columns: orders.date_order_placed, orders.order_id, shipments.order_id, shipments.shipment_tracking_number.\nThe SQL query I'll be generating is:\nSELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452" } ]
[ { "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 \"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 volume (\n\t\"Volume_ID\" INTEGER, \n\t\"Volume_Issue\" TEXT, \n\t\"Issue_Date\" TEXT, \n\t\"Weeks_on_Top\" REAL, \n\t\"Song\" TEXT, \n\t\"Artist_ID\" INTEGER, \n\tPRIMARY KEY (\"Volume_ID\"), \n\tFOREIGN KEY(\"Artist_ID\") REFERENCES artist (\"Artist_ID\")\n)\n/*\nColumns in volume and all categories for low cardinality columns :\nVolume_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nVolume_Issue : 46:5, 46:16, 46:14-15, 45:15, 45:21-22, 45:16, 46:6-8, 45:14 §, 46:10, 46:9\nIssue_Date : 16 May - 30 May, 6 June, 27 December 1986 - 10 January, 28 February - 7 March, 13 June, 24 January, 9 May, 17 January, 11 July - 18 July, 25 July\nWeeks_on_Top : 3.0, 1.0, 2.0\nSong : Head to Toe , Always , With or Without You , Looking for a New Love, La Isla Bonita , The Way, Everybody Have Fun Tonight , Touch Me (I Want Your Body) , (I Just) Died in Your Arms , Walk Like an Egyptian \nArtist_ID : 1, 2, 5, 4, 6\n*/\n \nCREATE TABLE \"Lots\" (\n\tlot_id INTEGER, \n\tinvestor_id INTEGER NOT NULL, \n\tlot_details VARCHAR(255), \n\tPRIMARY KEY (lot_id), \n\tFOREIGN KEY(investor_id) REFERENCES \"Investors\" (investor_id)\n)\n/*\nColumns in Lots and 3 examples in each column for high cardinality columns :\nlot_id : 1, 13, 11\n*/\n/*\nColumns in Lots and all categories for low cardinality columns :\ninvestor_id : 1, 16, 13, 20, 7, 6, 19, 10, 9\nlot_details : d, m, q, s, r, h, x, z\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 \"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 party (\n\t\"Party_ID\" INTEGER, \n\t\"Party_Theme\" TEXT, \n\t\"Location\" TEXT, \n\t\"First_year\" TEXT, \n\t\"Last_year\" TEXT, \n\t\"Number_of_hosts\" INTEGER, \n\tPRIMARY KEY (\"Party_ID\")\n)\n/*\nColumns in party and all categories for low cardinality columns :\nParty_ID : 1, 2, 5, 7, 8, 4, 6, 3\nParty_Theme : Qlubtempo, In Qontrol, Club Q-BASE, QrimeTime, Teqnology, Houseqlassics, Hardcore Resurrection, Spring\nLocation : Various locations, RAI Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam\nFirst_year : 2004, 2001, 1999, 2000, 2002\nLast_year : 2004, 2001, 2002, 2003, 2010, 2007\nNumber_of_hosts : 5, 7, 23, 4, 6, 18, 31\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Faculty\" (\n\t\"FacID\" INTEGER, \n\t\"Lname\" VARCHAR(15), \n\t\"Fname\" VARCHAR(15), \n\t\"Rank\" VARCHAR(15), \n\t\"Sex\" VARCHAR(1), \n\t\"Phone\" INTEGER, \n\t\"Room\" VARCHAR(5), \n\t\"Building\" VARCHAR(13), \n\tPRIMARY KEY (\"FacID\")\n)\n/*\nColumns in Faculty and 3 examples in each column for high cardinality columns :\nFacID : 6112, 9199, 7134\nLname : Glaser, Han, James\nFname : Rao, Brenda, James\nPhone : 2105, 3593, 1035\nRoom : 288, 218, 219\n*/\n/*\nColumns in Faculty and all categories for low cardinality columns :\nRank : AssocProf, AsstProf, Professor, Instructor\nSex : F, M\nBuilding : Krieger, NEB, Barton\n*/\n \nCREATE TABLE round (\n\t\"Round_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Decoration_Theme\" TEXT, \n\t\"Rank_in_Round\" INTEGER, \n\tPRIMARY KEY (\"Member_ID\", \"Round_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in round and all categories for low cardinality columns :\nRound_ID : 1, 2\nMember_ID : 1, 2, 4, 6, 10, 9\nDecoration_Theme : Dark Nights, Summer, Walk on the Moon, Sweetie, Soft Dream, Happiness\nRank_in_Round : 1, 2, 4, 3\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE stadium (\n\t\"ID\" INTEGER, \n\tname TEXT, \n\t\"Capacity\" INTEGER, \n\t\"City\" TEXT, \n\t\"Country\" TEXT, \n\t\"Opening_year\" INTEGER, \n\tPRIMARY KEY (\"ID\")\n)\n/*\nColumns in stadium and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Northumberland Development Project, Fisht Olympic Stadium, Ferenc Puskás Stadion, Nou Mestalla, Yubileyniy Stadium, Estadio La Peineta, Baku Olympic Stadium, Arena Baltika, Stade des Lumières, Gazprom Arena\nCapacity : 61556, 69501, 56250, 68000, 47659, 45015, 67500, 75000, 65000\nCity : London, Sochi, Budapest, Saint Petersburg, Baku, Kaliningrad, Madrid, Valencia, Lyon, Saransk\nCountry : Spain, France, England, Russia, Azerbaijan, Hungary\nOpening_year : 2004, 2005, 2007, 2006\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Product_Characteristics\" (\n\tproduct_id INTEGER NOT NULL, \n\tcharacteristic_id INTEGER NOT NULL, \n\tproduct_characteristic_value VARCHAR(50), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(characteristic_id) REFERENCES \"Characteristics\" (characteristic_id)\n)\n/*\nColumns in Product_Characteristics and all categories for low cardinality columns :\nproduct_id : 1, 13, 11, 5, 7, 8, 6, 12, 14\ncharacteristic_id : 13, 10, 11, 2, 4, 6, 12, 3, 15\nproduct_characteristic_value : high, low, medium\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE genre (\n\tg_name TEXT(20) NOT NULL, \n\trating TEXT(10), \n\tmost_popular_in TEXT(50), \n\tPRIMARY KEY (g_name)\n)\n/*\nColumns in genre and all categories for low cardinality columns :\ng_name : tagore, folk, modern, nazrul, blues, pop\nrating : 7, 8, 9\nmost_popular_in : America, Canada, Sylhet,Chittagong,Kustia, Bangladesh\n*/\n" }, { "role": "user", "content": "What is the placement date of the order whose invoice number is 10?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, shipments.\nFrom these tables, I'll be using the following columns: orders.date_order_placed, orders.order_id, shipments.order_id, shipments.invoice_number.\nThe SQL query I'll be generating is:\nSELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10" } ]
[ { "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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 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 book_club (\n\tbook_club_id INTEGER, \n\t\"Year\" INTEGER, \n\t\"Author_or_Editor\" TEXT, \n\t\"Book_Title\" TEXT, \n\t\"Publisher\" TEXT, \n\t\"Category\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (book_club_id)\n)\n/*\nColumns in book_club and 3 examples in each column for high cardinality columns :\nbook_club_id : 1, 11, 2\nAuthor_or_Editor : Dolores Klaich, Antoinette Azolakov, Sandy Bayer\nBook_Title : Lessons In Murder, Somewhere in the Night, Mundaneӳ World\n*/\n/*\nColumns in book_club and all categories for low cardinality columns :\nYear : 1989, 1990\nPublisher : International Polygonics, William Morrow, St. Martin's Press, Crossing Press, Alyson, Naiad Press, Banned Books, Mysterious Press\nCategory : Lesb. M/SF, Gay SF/F, Gay M/SF\nResult : Nom, Won [B ], Won, Won [A ]\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 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 \"Vocals\" (\n\t\"SongId\" INTEGER, \n\t\"Bandmate\" INTEGER, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"SongId\", \"Bandmate\"), \n\tFOREIGN KEY(\"SongId\") REFERENCES \"Songs\" (\"SongId\"), \n\tFOREIGN KEY(\"Bandmate\") REFERENCES \"Band\" (\"Id\")\n)\n/*\nColumns in Vocals and all categories for low cardinality columns :\nSongId : \nBandmate : \nType : \n*/\n \nCREATE TABLE film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"CLASS\" (\n\t\"CLASS_CODE\" VARCHAR(5), \n\t\"CRS_CODE\" VARCHAR(10), \n\t\"CLASS_SECTION\" VARCHAR(2), \n\t\"CLASS_TIME\" VARCHAR(20), \n\t\"CLASS_ROOM\" VARCHAR(8), \n\t\"PROF_NUM\" INTEGER, \n\tPRIMARY KEY (\"CLASS_CODE\"), \n\tFOREIGN KEY(\"CRS_CODE\") REFERENCES \"COURSE\" (\"CRS_CODE\"), \n\tFOREIGN KEY(\"PROF_NUM\") REFERENCES \"EMPLOYEE\" (\"EMP_NUM\")\n)\n/*\nColumns in CLASS and 3 examples in each column for high cardinality columns :\nCLASS_CODE : 10013, 10024, 10016\n*/\n/*\nColumns in CLASS and all categories for low cardinality columns :\nCRS_CODE : ACCT-212, QM-362, QM-261, CIS-420, CIS-220, ACCT-211\nCLASS_SECTION : 1, 2, 3\nCLASS_TIME : TTh 2:30-3:45 p.m., MWF 10:00-10:50 a.m., MWF 9:00-9:50 a.m., MWF 8:00-8:50 a.m., W 6:00-8:40 p.m., Th 6:00-8:40 p.m., TTh 1:00-2:15 p.m., MWF 11:00-11:50 a.m.\nCLASS_ROOM : KLR209, KLR211, BUS252, BUS311, KLR200, BUS200\nPROF_NUM : 114, 342, 301, 228, 105, 162\n*/\n" }, { "role": "user", "content": "On what day was the order with invoice number 10 placed?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, shipments.\nFrom these tables, I'll be using the following columns: orders.date_order_placed, orders.order_id, shipments.order_id, shipments.invoice_number.\nThe SQL query I'll be generating is:\nSELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10" } ]
[ { "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 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 \"Companies\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value_billion\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Companies and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : PetroChina, Berkshire Hathaway, Petrobras\nSales_billion : 69.2, 189.6, 421.8\nProfits_billion : 16.4, 19.9, 17.4\nAssets_billion : 2467.9, 192.8, 1913.9\nMarket_Value_billion : 239.5, 186.5, 224.8\n*/\n/*\nColumns in Companies and all categories for low cardinality columns :\nHeadquarters : Spain, UK, China, Brazil, France, Russia, USA, Netherlands\nIndustry : Retailing, Conglomerate, Oil and gas, Telecommunications, Banking\n*/\n \nCREATE TABLE stadium (\n\t\"ID\" INTEGER, \n\tname TEXT, \n\t\"Capacity\" INTEGER, \n\t\"City\" TEXT, \n\t\"Country\" TEXT, \n\t\"Opening_year\" INTEGER, \n\tPRIMARY KEY (\"ID\")\n)\n/*\nColumns in stadium and all categories for low cardinality columns :\nID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nname : Northumberland Development Project, Fisht Olympic Stadium, Ferenc Puskás Stadion, Nou Mestalla, Yubileyniy Stadium, Estadio La Peineta, Baku Olympic Stadium, Arena Baltika, Stade des Lumières, Gazprom Arena\nCapacity : 61556, 69501, 56250, 68000, 47659, 45015, 67500, 75000, 65000\nCity : London, Sochi, Budapest, Saint Petersburg, Baku, Kaliningrad, Madrid, Valencia, Lyon, Saransk\nCountry : Spain, France, England, Russia, Azerbaijan, Hungary\nOpening_year : 2004, 2005, 2007, 2006\n*/\n \nCREATE TABLE \"Parking_Fines\" (\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 Parking_Fines and all categories for low cardinality columns :\ncouncil_tax_id : 10, 9\ncmi_cross_ref_id : 4, 81\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE user_profiles (\n\tuid INTEGER NOT NULL, \n\tname VARCHAR(255) DEFAULT NULL, \n\temail VARCHAR(255) DEFAULT NULL, \n\tpartitionid INTEGER DEFAULT NULL, \n\tfollowers INTEGER DEFAULT NULL, \n\tPRIMARY KEY (uid)\n)\n/*\nColumns in user_profiles and all categories for low cardinality columns :\nuid : 1, 2, 5, 7, 4, 6, 3\nname : Natalie Portman, Mary, Black Widow\n, Tyler Swift, Celine Dion, Iron Man, Susan\nemail : susan@gmail.com\n, ts@superstar.com\n, cd@superstar.com, np@superstar.com, ts@richest.com, bw@superhero.com, Mary@yale.edu\npartitionid : 1, 2, 5, 23, 10\nfollowers : 23927492, 100, 94375428, 35425845, 890, 99999998, 6662425\n*/\n \nCREATE TABLE \"Faculty\" (\n\t\"FacID\" INTEGER, \n\t\"Lname\" VARCHAR(15), \n\t\"Fname\" VARCHAR(15), \n\t\"Rank\" VARCHAR(15), \n\t\"Sex\" VARCHAR(1), \n\t\"Phone\" INTEGER, \n\t\"Room\" VARCHAR(5), \n\t\"Building\" VARCHAR(13), \n\tPRIMARY KEY (\"FacID\")\n)\n/*\nColumns in Faculty and 3 examples in each column for high cardinality columns :\nFacID : 6112, 9199, 7134\nLname : Glaser, Han, James\nFname : Rao, Brenda, James\nPhone : 2105, 3593, 1035\nRoom : 288, 218, 219\n*/\n/*\nColumns in Faculty and all categories for low cardinality columns :\nRank : AssocProf, AsstProf, Professor, Instructor\nSex : F, M\nBuilding : Krieger, NEB, Barton\n*/\n \nCREATE TABLE \"Order_Items\" (\n\t\"Order_Item_ID\" INTEGER NOT NULL, \n\t\"Order_ID\" INTEGER NOT NULL, \n\t\"Product_ID\" INTEGER NOT NULL, \n\t\"Order_Quantity\" VARCHAR(288), \n\t\"Other_Item_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Order_Item_ID\"), \n\tFOREIGN KEY(\"Order_ID\") REFERENCES \"Customer_Orders\" (\"Order_ID\"), \n\tFOREIGN KEY(\"Product_ID\") REFERENCES \"Products\" (\"Product_ID\")\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\nOrder_Item_ID : 1, 13, 11\nOrder_ID : 1, 10, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nProduct_ID : 300, 233, 46, 156, 83, 179, 216, 81, 273\nOrder_Quantity : 1, 2\nOther_Item_Details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Staff\" (\n\tstaff_id INTEGER, \n\tstaff_first_name VARCHAR(80), \n\tstaff_last_name VARCHAR(80), \n\tother_staff_details VARCHAR(255), \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_first_name : Junius, Israel, Kenyatta\nstaff_last_name : Mante, Treutel, Weber\n*/\n/*\nColumns in Staff and all categories for low cardinality columns :\nother_staff_details : d, m, q, b, i, e, w, j, p, x\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" }, { "role": "user", "content": "List the count and id of each product in all the orders." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items, products.\nFrom these tables, I'll be using the following columns: products.product_id, orders.order_id, order_items.order_id, order_items.product_id.\nThe SQL query I'll be generating is:\nSELECT count(*) , T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id" } ]
[ { "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 \"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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Playlist\" (\n\t\"PlaylistId\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(120) DEFAULT NULL, \n\tPRIMARY KEY (\"PlaylistId\")\n)\n/*\nColumns in Playlist and 3 examples in each column for high cardinality columns :\nPlaylistId : 1, 16, 13\nName : Heavy Metal Classic, 90’s Music, Classical 101 - Deep Cuts\n*/\n\n \nCREATE TABLE \"Payments\" (\n\t\"Payment_ID\" INTEGER NOT NULL, \n\t\"Settlement_ID\" INTEGER NOT NULL, \n\t\"Payment_Method_Code\" VARCHAR(255), \n\t\"Date_Payment_Made\" DATE, \n\t\"Amount_Payment\" INTEGER, \n\tPRIMARY KEY (\"Payment_ID\"), \n\tFOREIGN KEY(\"Settlement_ID\") REFERENCES \"Settlements\" (\"Settlement_ID\")\n)\n/*\nColumns in Payments and 3 examples in each column for high cardinality columns :\nPayment_ID : 754, 739, 542\nDate_Payment_Made : 2017-06-24, 2017-08-06, 2017-12-16\nAmount_Payment : 423154, 155654, 71246\n*/\n/*\nColumns in Payments and all categories for low cardinality columns :\nSettlement_ID : 527, 476, 564, 983, 682, 648, 597, 512, 516\nPayment_Method_Code : Visa, Discover Card, American Express, MasterCard\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 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 dependent (\n\t\"Essn\" INTEGER, \n\t\"Dependent_name\" TEXT, \n\t\"Sex\" TEXT, \n\t\"Bdate\" TEXT, \n\t\"Relationship\" TEXT, \n\tPRIMARY KEY (\"Essn\", \"Dependent_name\")\n)\n/*\nColumns in dependent and all categories for low cardinality columns :\nEssn : 333445555, 123456789, 987654321\nDependent_name : Alice, Michael, Theodore, Abner, Joy, Elizabeth\nSex : F, M\nBdate : 1986-04-05, 1988-01-04, 1967-05-05, 1983-10-25, 1958-05-03, 1942-02-28, 1988-12-30\nRelationship : Daughter, Son, Spouse\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 railway_manage (\n\t\"Railway_ID\" INTEGER, \n\t\"Manager_ID\" INTEGER, \n\t\"From_Year\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\", \"Manager_ID\"), \n\tFOREIGN KEY(\"Manager_ID\") REFERENCES manager (\"Manager_ID\"), \n\tFOREIGN KEY(\"Railway_ID\") REFERENCES railway (\"Railway_ID\")\n)\n/*\nColumns in railway_manage and all categories for low cardinality columns :\nRailway_ID : 7, 8, 2, 9\nManager_ID : 1, 2, 4, 3\nFrom_Year : 2012, 2010, 2011, 2013\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Claims\" (\n\t\"Claim_ID\" INTEGER NOT NULL, \n\t\"Policy_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\tPRIMARY KEY (\"Claim_ID\"), \n\tFOREIGN KEY(\"Policy_ID\") REFERENCES \"Customer_Policies\" (\"Policy_ID\")\n)\n/*\nColumns in Claims and 3 examples in each column for high cardinality columns :\nClaim_ID : 843, 143, 563\nDate_Claim_Made : 2018-11-08, 2016-08-12, 2016-08-02\nDate_Claim_Settled : 2017-12-20, 2018-02-20, 2017-09-04\nAmount_Claimed : 49743, 70088, 46479\nAmount_Settled : 1372, 1652, 1528\n*/\n/*\nColumns in Claims and all categories for low cardinality columns :\nPolicy_ID : 858, 143, 141, 744, 473, 352, 119, 738, 552\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 airport_aircraft (\n\t\"ID\" INTEGER, \n\t\"Airport_ID\" INTEGER, \n\t\"Aircraft_ID\" INTEGER, \n\tPRIMARY KEY (\"Airport_ID\", \"Aircraft_ID\"), \n\tFOREIGN KEY(\"Aircraft_ID\") REFERENCES aircraft (\"Aircraft_ID\"), \n\tFOREIGN KEY(\"Airport_ID\") REFERENCES airport (\"Airport_ID\")\n)\n/*\nColumns in airport_aircraft and all categories for low cardinality columns :\nID : 1, 2, 4, 3\nAirport_ID : 1, 9, 2, 6\nAircraft_ID : 1, 2, 5, 3\n*/\n" }, { "role": "user", "content": "For each product, return its id and the number of times it was ordered." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items, products.\nFrom these tables, I'll be using the following columns: products.product_id, orders.order_id, order_items.order_id, order_items.product_id.\nThe SQL query I'll be generating is:\nSELECT count(*) , T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id" } ]
[ { "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 \"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 \"Product_Categories\" (\n\tproduction_type_code VARCHAR(15), \n\tproduct_type_description VARCHAR(80), \n\tvat_rating DECIMAL(19, 4), \n\tPRIMARY KEY (production_type_code)\n)\n/*\nColumns in Product_Categories and all categories for low cardinality columns :\nproduction_type_code : Food, Books, DVDs, Electronics\nproduct_type_description : Food, Books, Dvd products, Electrical devices\nvat_rating : 15.8400, 11.4000, 13.9500, 17.9000\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Tourist_Attractions\" (\n\t\"Tourist_Attraction_ID\" INTEGER NOT NULL, \n\t\"Attraction_Type_Code\" CHAR(15) NOT NULL, \n\t\"Location_ID\" INTEGER NOT NULL, \n\t\"How_to_Get_There\" VARCHAR(255), \n\t\"Name\" VARCHAR(255), \n\t\"Description\" VARCHAR(255), \n\t\"Opening_Hours\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Tourist_Attraction_ID\"), \n\tFOREIGN KEY(\"Location_ID\") REFERENCES \"Locations\" (\"Location_ID\"), \n\tFOREIGN KEY(\"Attraction_Type_Code\") REFERENCES \"Ref_Attraction_Types\" (\"Attraction_Type_Code\")\n)\n/*\nColumns in Tourist_Attractions and 3 examples in each column for high cardinality columns :\nTourist_Attraction_ID : 5076, 6653, 8429\nName : film festival, flying elephant, fun shops\n*/\n/*\nColumns in Tourist_Attractions and all categories for low cardinality columns :\nAttraction_Type_Code : 2, 5, 6, 3, 9\nLocation_ID : 867, 858, 759, 603, 417, 661, 655, 579, 868\nHow_to_Get_There : shuttle, bus, walk\nDescription : None\nOpening_Hours : None\nOther_Details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE editor (\n\t\"Editor_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Age\" REAL, \n\tPRIMARY KEY (\"Editor_ID\")\n)\n/*\nColumns in editor and all categories for low cardinality columns :\nEditor_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Maria Góralczyk, Władysław Grzywna, Grażyna Wolszczak, Szymon Wydra, Piotr Pręgowski, Kamila Porczyk, Marek Siudym, Anna Powierza, Mariusz Zalejski\nAge : 43.0, 24.0, 25.0, 34.0, 38.0, 54.0, 35.0, 21.0, 20.0\n*/\n \nCREATE TABLE \"Products\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Price\" DECIMAL NOT NULL, \n\t\"Manufacturer\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Manufacturer\") REFERENCES \"Manufacturers\" (\"Code\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nCode : 1, 11, 2\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nName : Printer, Floppy disk, Memory, Monitor, Toner cartridge, CD drive, DVD burner, Hard drive, ZIP drive, DVD drive\nPrice : 150.0000000000, 120.0000000000, 90.0000000000, 5.0000000000, 270.0000000000, 180.0000000000, 66.0000000000, 240.0000000000\nManufacturer : 1, 2, 5, 4, 6, 3\n*/\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 \"Course_Authors_and_Tutors\" (\n\tauthor_id INTEGER, \n\t\"author_tutor_ATB\" VARCHAR(3), \n\tlogin_name VARCHAR(40), \n\tpassword VARCHAR(40), \n\tpersonal_name VARCHAR(80), \n\tmiddle_name VARCHAR(80), \n\tfamily_name VARCHAR(80), \n\tgender_mf VARCHAR(1), \n\taddress_line_1 VARCHAR(80), \n\tPRIMARY KEY (author_id)\n)\n/*\nColumns in Course_Authors_and_Tutors and 3 examples in each column for high cardinality columns :\nauthor_id : 1, 13, 11\nauthor_tutor_ATB : 388, 782, 159\nlogin_name : heidenreich.ara, qking, fiona77\npassword : 2c196efe8aee23a1b9a7e752fe63029c5879af6f, cdaf6c3483f19e2253659a40a3aab786a3390f78, 120ac8a5744f5b710ecaebbd8dd1633e3e33886e\npersonal_name : Dusty, Cathrine, Shakira\nmiddle_name : Kennith, Ruthie, Joyce\nfamily_name : Treutel, Zboncak, Rowe\naddress_line_1 : 644 Montana Hill Suite 489\nDaijamouth, CA 19587-4254, 139 O'Conner Circles\nVirginieland, KS 23365, 92220 Hellen Skyway Apt. 635\nRennerview, MS 81036\n*/\n/*\nColumns in Course_Authors_and_Tutors and all categories for low cardinality columns :\ngender_mf : 1, 0\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Projects\" (\n\t\"Project_ID\" INTEGER NOT NULL, \n\t\"Project_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Project_ID\")\n)\n/*\nColumns in Projects and all categories for low cardinality columns :\nProject_ID : 35, 30, 134, 105, 195\nProject_Details : Graph Database project, Internet of Things project, Population Research project, Society Research project, Human Resource project\n*/\n \nCREATE TABLE \"Parties_in_Events\" (\n\t\"Party_ID\" INTEGER NOT NULL, \n\t\"Event_ID\" INTEGER NOT NULL, \n\t\"Role_Code\" CHAR(15), \n\tPRIMARY KEY (\"Party_ID\", \"Event_ID\"), \n\tFOREIGN KEY(\"Party_ID\") REFERENCES \"Parties\" (\"Party_ID\"), \n\tFOREIGN KEY(\"Event_ID\") REFERENCES \"Events\" (\"Event_ID\")\n)\n/*\nColumns in Parties_in_Events and 3 examples in each column for high cardinality columns :\nEvent_ID : 1, 13, 15\n*/\n/*\nColumns in Parties_in_Events and all categories for low cardinality columns :\nParty_ID : 5, 4, 6, 3, 9\nRole_Code : Organizer, Participant\n*/\n \nCREATE TABLE \"Apartment_Facilities\" (\n\tapt_id INTEGER NOT NULL, \n\tfacility_code CHAR(15) NOT NULL, \n\tPRIMARY KEY (apt_id, facility_code), \n\tFOREIGN KEY(apt_id) REFERENCES \"Apartments\" (apt_id)\n)\n/*\nColumns in Apartment_Facilities and all categories for low cardinality columns :\napt_id : 1, 2, 5, 6, 3, 15, 9\nfacility_code : Gym, Swimming Pool, Boardband, Cable TV\n*/\n \nCREATE TABLE debate_people (\n\t\"Debate_ID\" INTEGER, \n\t\"Affirmative\" INTEGER, \n\t\"Negative\" INTEGER, \n\t\"If_Affirmative_Win\" BOOLEAN, \n\tPRIMARY KEY (\"Debate_ID\", \"Affirmative\", \"Negative\"), \n\tFOREIGN KEY(\"Negative\") REFERENCES people (\"People_ID\"), \n\tFOREIGN KEY(\"Affirmative\") REFERENCES people (\"People_ID\"), \n\tFOREIGN KEY(\"Debate_ID\") REFERENCES debate (\"Debate_ID\")\n)\n/*\nColumns in debate_people and all categories for low cardinality columns :\nDebate_ID : 1, 5, 4, 6, 3\nAffirmative : 1, 2, 4, 5\nNegative : 7, 10, 8, 6\nIf_Affirmative_Win : True\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "List the name and count of each product in all orders." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items, products.\nFrom these tables, I'll be using the following columns: products.product_name, orders.order_id, order_items.order_id, order_items.product_id, products.product_id.\nThe SQL query I'll be generating is:\nSELECT T3.product_name , count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id" } ]
[ { "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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Player\" (\n\tid INTEGER, \n\tplayer_api_id INTEGER, \n\tplayer_name TEXT, \n\tplayer_fifa_api_id INTEGER, \n\tbirthday TEXT, \n\theight INTEGER, \n\tweight INTEGER, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Player and 3 examples in each column for high cardinality columns :\nid : 87, 56, 65\nplayer_api_id : 148827, 38423, 176301\nplayer_name : Adam Ounas, Abdelmalek Cherrad, Adrian\nplayer_fifa_api_id : 197081, 211185, 184410\nbirthday : 1988-08-25 00:00:00, 1986-12-02 00:00:00, 1978-12-22 00:00:00\nheight : 172.72, 175.26, 187.96\nweight : 185, 187, 163\n*/\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 \"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 \"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 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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Ref_Characteristic_Types\" (\n\tcharacteristic_type_code VARCHAR(15), \n\tcharacteristic_type_description VARCHAR(80), \n\tPRIMARY KEY (characteristic_type_code)\n)\n/*\nColumns in Ref_Characteristic_Types and all categories for low cardinality columns :\ncharacteristic_type_code : Grade, Purity\ncharacteristic_type_description : Grade, Purity\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 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 \nCREATE TABLE branch (\n\t\"Branch_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Open_year\" TEXT, \n\t\"Address_road\" TEXT, \n\t\"City\" TEXT, \n\tmembership_amount TEXT, \n\tPRIMARY KEY (\"Branch_ID\")\n)\n/*\nColumns in branch and all categories for low cardinality columns :\nBranch_ID : 1, 2, 5, 7, 8, 4, 6, 3\nName : Popert, Zytogorski, Alexandre, Brooke Greville, Taverner, Stanley, Saint Amant, Cochrane\nOpen_year : 2009, 2013, 2015, 2001, 2012, 2014\nAddress_road : Abbott Street, Concord Road, Brampton Road, Cecilia Avenue, Oaks Crescent, Valleys Place, Glebe Street, Abbey Rise\nCity : Oxford, London\nmembership_amount : 91, 56, 11, 1418, 7, 6, 112, 31\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Documents\" (\n\t\"Document_ID\" INTEGER NOT NULL, \n\t\"Document_Type_Code\" CHAR(15) NOT NULL, \n\t\"Project_ID\" INTEGER NOT NULL, \n\t\"Document_Date\" DATETIME, \n\t\"Document_Name\" VARCHAR(255), \n\t\"Document_Description\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Document_ID\"), \n\tFOREIGN KEY(\"Document_Type_Code\") REFERENCES \"Ref_Document_Types\" (\"Document_Type_Code\"), \n\tFOREIGN KEY(\"Project_ID\") REFERENCES \"Projects\" (\"Project_ID\")\n)\n/*\nColumns in Documents and 3 examples in each column for high cardinality columns :\nDocument_ID : 121, 300, 240\nDocument_Date : 2007-09-26 02:39:11, 1981-11-29 10:23:01, 1970-01-30 10:53:35\nDocument_Name : Katheryn statement, Review on UK files, Noel CV\n*/\n/*\nColumns in Documents and all categories for low cardinality columns :\nDocument_Type_Code : FM, BK, PP, CV\nProject_ID : 195, 30, 134, 105, 35\nDocument_Description : None\nOther_Details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "For each product, show its name and the number of times it was ordered." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items, products.\nFrom these tables, I'll be using the following columns: products.product_name, orders.order_id, order_items.order_id, order_items.product_id, products.product_id.\nThe SQL query I'll be generating is:\nSELECT T3.product_name , count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id" } ]
[ { "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 roller_coaster (\n\t\"Roller_Coaster_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Park\" TEXT, \n\t\"Country_ID\" INTEGER, \n\t\"Length\" REAL, \n\t\"Height\" REAL, \n\t\"Speed\" TEXT, \n\t\"Opened\" TEXT, \n\t\"Status\" TEXT, \n\tPRIMARY KEY (\"Roller_Coaster_ID\"), \n\tFOREIGN KEY(\"Country_ID\") REFERENCES country (\"Country_ID\")\n)\n/*\nColumns in roller_coaster and all categories for low cardinality columns :\nRoller_Coaster_ID : 1, 2, 5, 4, 6, 3\nName : The Voyage, Twister, Boardwalk Bullet, Hades 360, Dauling Dragon, Ravine Flyer II\nPark : Waldameer, Happy Valley, Mt. Olympus, Gröna Lund, Kemah Boardwalk, Holiday World\nCountry_ID : 1, 2, 3\nLength : 6442.0, 4726.0, 3236.0, 1574.0, 2900.0, 3914.0\nHeight : 96.0, 105.0, 136.0, 50.0, 120.0, 163.0\nSpeed : 67, 55, 37.9, 70, 57, 51\nOpened : May 14, 2005, 2012, August 31, 2007, 2011, May 6, 2006, May 17, 2008\nStatus : Operating\n*/\n \nCREATE TABLE \"Student_Course_Registrations\" (\n\tstudent_id INTEGER NOT NULL, \n\tcourse_id INTEGER NOT NULL, \n\tregistration_date DATETIME NOT NULL, \n\tPRIMARY KEY (student_id, course_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_Registrations and all categories for low cardinality columns :\nstudent_id : 151, 141, 131, 171, 111, 161, 121\ncourse_id : 302, 303, 301, 305\nregistration_date : 2008-11-08 10:35:13, 2008-11-07 10:35:13, 2008-11-05 10:35:13, 2008-11-04 10:35:13, 2008-11-14 10:35:13, 2008-11-06 10:35:13, 2008-10-04 10:35:13\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Faculty_Participates_in\" (\n\t\"FacID\" INTEGER, \n\tactid INTEGER, \n\tFOREIGN KEY(\"FacID\") REFERENCES \"Faculty\" (\"FacID\"), \n\tFOREIGN KEY(actid) REFERENCES \"Activity\" (actid)\n)\n/*\nColumns in Faculty_Participates_in and 3 examples in each column for high cardinality columns :\nFacID : 7723, 6112, 3457\nactid : 771, 782, 770\n*/\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 \"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 \"Ref_Document_Status\" (\n\tdocument_status_code CHAR(15) NOT NULL, \n\tdocument_status_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (document_status_code)\n)\n/*\nColumns in Ref_Document_Status and all categories for low cardinality columns :\ndocument_status_code : done, overdue, working\ndocument_status_description : mailed late, mailed, currently working on\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 \"Lots\" (\n\tlot_id INTEGER, \n\tinvestor_id INTEGER NOT NULL, \n\tlot_details VARCHAR(255), \n\tPRIMARY KEY (lot_id), \n\tFOREIGN KEY(investor_id) REFERENCES \"Investors\" (investor_id)\n)\n/*\nColumns in Lots and 3 examples in each column for high cardinality columns :\nlot_id : 1, 13, 11\n*/\n/*\nColumns in Lots and all categories for low cardinality columns :\ninvestor_id : 1, 16, 13, 20, 7, 6, 19, 10, 9\nlot_details : d, m, q, s, r, h, x, z\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 \"Staff\" (\n\tstaff_id INTEGER, \n\tstaff_first_name VARCHAR(80), \n\tstaff_last_name VARCHAR(80), \n\tother_staff_details VARCHAR(255), \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_first_name : Junius, Israel, Kenyatta\nstaff_last_name : Mante, Treutel, Weber\n*/\n/*\nColumns in Staff and all categories for low cardinality columns :\nother_staff_details : d, m, q, b, i, e, w, j, p, x\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE manager (\n\t\"Manager_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Country\" TEXT, \n\t\"Working_year_starts\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Level\" INTEGER, \n\tPRIMARY KEY (\"Manager_ID\")\n)\n/*\nColumns in manager and all categories for low cardinality columns :\nManager_ID : 1, 2, 5, 7, 4, 6, 3\nName : Ben Curtis, Sandy Lyle, Todd Hamilton, David Duval, Tiger Woods, Greg Norman, Nick Faldo\nCountry : United States, Australia, Scotland, England\nWorking_year_starts : 2004, 1993, 2001, 1985, 1999, 2006, 2003\nAge : 46, 45, 55, 48, 52, 47, 51\nLevel : 11, 5, 7, 8, 12\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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_first_name VARCHAR(50), \n\tcustomer_middle_initial VARCHAR(1), \n\tcustomer_last_name VARCHAR(50), \n\tgender VARCHAR(1), \n\temail_address VARCHAR(255), \n\tlogin_name VARCHAR(80), \n\tlogin_password VARCHAR(20), \n\tphone_number VARCHAR(255), \n\ttown_city VARCHAR(50), \n\tstate_county_province VARCHAR(50), \n\tcountry VARCHAR(50), \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 : Devin, Ruby, Joesph\ncustomer_last_name : Muller, Weimann, Glover\nemail_address : roosevelt.collier@example.org, pyundt@example.org, anastacio45@example.org\nlogin_name : zdeckow, rubye.padberg, feeney.lauriane\nlogin_password : 180a37476c537e78d3de, 035f2ba1e2a675c4f426, d4ade599672bccdabeee\nphone_number : 241.796.1219x37862, (791)562-7792x45732, (193)465-6674x4952\ntown_city : North Nellie, Kenshire, West Khaliltown\nstate_county_province : Louisiana, SouthDakota, Kansas\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\ncustomer_middle_initial : E, K, H, A, G, L, V, M, B\ngender : 1, 0\ncountry : USA\n*/\n" }, { "role": "user", "content": "Find the ids of orders which are shipped after 2000-01-01." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: shipments.\nFrom these tables, I'll be using the following columns: order_id, shipment_date, 2000-01-01.\nThe SQL query I'll be generating is:\nSELECT order_id FROM shipments WHERE shipment_date > \"2000-01-01\"" } ]
[ { "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 \"Reviewer\" (\n\t\"rID\" INTEGER, \n\tname TEXT, \n\tPRIMARY KEY (\"rID\")\n)\n/*\nColumns in Reviewer and all categories for low cardinality columns :\nrID : 201, 204, 205, 207, 206, 203, 208, 202\nname : Chris Jackson, Sarah Martinez, Mike Anderson, James Cameron, Elizabeth Thomas, Brittany Harris, Daniel Lewis, Ashley White\n*/\n \nCREATE TABLE \"Authorship\" (\n\t\"authID\" INTEGER, \n\t\"instID\" INTEGER, \n\t\"paperID\" INTEGER, \n\t\"authOrder\" INTEGER, \n\tPRIMARY KEY (\"authID\", \"instID\", \"paperID\"), \n\tFOREIGN KEY(\"authID\") REFERENCES \"Authors\" (\"authID\"), \n\tFOREIGN KEY(\"instID\") REFERENCES \"Inst\" (\"instID\"), \n\tFOREIGN KEY(\"paperID\") REFERENCES \"Papers\" (\"paperID\")\n)\n/*\nColumns in Authorship and 3 examples in each column for high cardinality columns :\nauthID : 53, 56, 57\n*/\n/*\nColumns in Authorship and all categories for low cardinality columns :\ninstID : 1060, 1010, 1000, 1040, 1050, 1030, 1020, 1070\npaperID : 201, 204, 205, 200, 206, 203, 202\nauthOrder : 1, 2, 3\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 : 7089 Mueller Forks, 535 Ariel Brook, 3904 Stroman Passage\ncity : Buckridgehaven, South Eugene, Elviebury\nzip_postcode : 22194, 99903, 14445\nstate_province_county : Louisiana, Kentucky, Ohio\n*/\n/*\nColumns in Addresses and all categories for low cardinality columns :\ncountry : USA\n*/\n \nCREATE TABLE culture_company (\n\t\"Company_name\" TEXT, \n\t\"Type\" TEXT, \n\t\"Incorporated_in\" TEXT, \n\t\"Group_Equity_Shareholding\" REAL, \n\tbook_club_id TEXT, \n\tmovie_id TEXT, \n\tPRIMARY KEY (\"Company_name\"), \n\tFOREIGN KEY(book_club_id) REFERENCES book_club (book_club_id), \n\tFOREIGN KEY(movie_id) REFERENCES movie (movie_id)\n)\n/*\nColumns in culture_company and all categories for low cardinality columns :\nCompany_name : Cathay Pacific Culture, Culture China Cargo, Culture Hong Kong, Cathay Pacific Culture Services (HK) Limited, Culture China, Dragonair\nType : Joint Venture, Subsidiary, Corporate\nIncorporated_in : Hong Kong, China\nGroup_Equity_Shareholding : 49.0, 60.0, 18.77, 100.0\nbook_club_id : 1, 2, 5, 6, 3\nmovie_id : 2, 5, 7, 4, 6, 3\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 \"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 \"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 endowment (\n\tendowment_id INTEGER, \n\t\"School_id\" INTEGER, \n\tdonator_name TEXT, \n\tamount REAL, \n\tPRIMARY KEY (endowment_id), \n\tFOREIGN KEY(\"School_id\") REFERENCES \"School\" (\"School_id\")\n)\n/*\nColumns in endowment and 3 examples in each column for high cardinality columns :\nendowment_id : 1, 11, 2\ndonator_name : Santo Domingo Este, Duarte, San Cristóbal\namount : 9.05, 8.82, 8.85\n*/\n/*\nColumns in endowment and all categories for low cardinality columns :\nSchool_id : 1, 2, 5, 7, 8, 4, 6, 3\n*/\n \nCREATE TABLE \"Ref_Document_Types\" (\n\t\"Document_Type_Code\" CHAR(15) NOT NULL, \n\t\"Document_Type_Name\" VARCHAR(255) NOT NULL, \n\t\"Document_Type_Description\" VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (\"Document_Type_Code\")\n)\n/*\nColumns in Ref_Document_Types and all categories for low cardinality columns :\nDocument_Type_Code : RV, BK, PR, CV\nDocument_Type_Name : Book, Review, CV, Paper\nDocument_Type_Description : \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 \"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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE railway (\n\t\"Railway_ID\" INTEGER, \n\t\"Railway\" TEXT, \n\t\"Builder\" TEXT, \n\t\"Built\" TEXT, \n\t\"Wheels\" TEXT, \n\t\"Location\" TEXT, \n\t\"ObjectNumber\" TEXT, \n\tPRIMARY KEY (\"Railway_ID\")\n)\n/*\nColumns in railway and all categories for low cardinality columns :\nRailway_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nRailway : Longmoor, LTSR, GWRWk, GERSt, GWRSn, GERHt, MR, SECR, GWRS, GNRD\nBuilder : GNR Doncaster, Stephenson, Swindon Works, GWR Swindon, GER Stratford, MR Derby, GER Hartford, SECR Ashford, Avonside\nBuilt : 1902 Midland Railway 1000 was rebuilt in 1914., 1902, 1901, 1905, 1907, 1903, 1904, 1909, 1910\nWheels : 4-4-0, 4-6-0, 0-6-0T, 4-4-2, 4-4-2T, 2-8-0, 0-6-0, 0-6-0ST\nLocation : Shildon, Swindon, Basingstoke, York, Toddington, Barrow Hill, Bressingham, Bo'ness\nObjectNumber : 1975-7005, 1978-7028, 1978-7025, 1975-7003, 1978-7026, 2008-7159, 1975-7006, 1978-7027, 1975-7018, 1976-7001\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE medicine (\n\tid INTEGER, \n\tname TEXT, \n\t\"Trade_Name\" TEXT, \n\t\"FDA_approved\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in medicine and 3 examples in each column for high cardinality columns :\nid : 17, 21, 9\nname : Quetiapine, Carpipramine, Asenapine\nTrade_Name : Buronil, Fanapt, Nipolept\n*/\n/*\nColumns in medicine and all categories for low cardinality columns :\nFDA_approved : Yes, No\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Vocals\" (\n\t\"SongId\" INTEGER, \n\t\"Bandmate\" INTEGER, \n\t\"Type\" TEXT, \n\tPRIMARY KEY (\"SongId\", \"Bandmate\"), \n\tFOREIGN KEY(\"SongId\") REFERENCES \"Songs\" (\"SongId\"), \n\tFOREIGN KEY(\"Bandmate\") REFERENCES \"Band\" (\"Id\")\n)\n/*\nColumns in Vocals and all categories for low cardinality columns :\nSongId : \nBandmate : \nType : \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 \"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" }, { "role": "user", "content": "Which orders have shipment after 2000-01-01? Give me the order ids." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: shipments.\nFrom these tables, I'll be using the following columns: order_id, shipment_date, 2000-01-01.\nThe SQL query I'll be generating is:\nSELECT order_id FROM shipments WHERE shipment_date > \"2000-01-01\"" } ]
[ { "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 \"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 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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Project_Outcomes\" (\n\tproject_id INTEGER NOT NULL, \n\toutcome_code VARCHAR(10) NOT NULL, \n\toutcome_details VARCHAR(255), \n\tFOREIGN KEY(outcome_code) REFERENCES \"Research_Outcomes\" (outcome_code), \n\tFOREIGN KEY(project_id) REFERENCES \"Projects\" (project_id)\n)\n/*\nColumns in Project_Outcomes and all categories for low cardinality columns :\nproject_id : 13, 11, 5, 7, 4, 6, 14, 3, 12, 9\noutcome_code : Patent, Paper\noutcome_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Price\" DECIMAL NOT NULL, \n\t\"Manufacturer\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Manufacturer\") REFERENCES \"Manufacturers\" (\"Code\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nCode : 1, 11, 2\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nName : Printer, Floppy disk, Memory, Monitor, Toner cartridge, CD drive, DVD burner, Hard drive, ZIP drive, DVD drive\nPrice : 150.0000000000, 120.0000000000, 90.0000000000, 5.0000000000, 270.0000000000, 180.0000000000, 66.0000000000, 240.0000000000\nManufacturer : 1, 2, 5, 4, 6, 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 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 \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"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 \"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 \"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 actor (\n\t\"Actor_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Musical_ID\" INTEGER, \n\t\"Character\" TEXT, \n\t\"Duration\" TEXT, \n\tage INTEGER, \n\tPRIMARY KEY (\"Actor_ID\"), \n\tFOREIGN KEY(\"Musical_ID\") REFERENCES actor (\"Actor_ID\")\n)\n/*\nColumns in actor and all categories for low cardinality columns :\nActor_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Ray Meagher, Lynne McGranger, Ian Smith, Tom Oliver, Kate Ritchie, Ryan Moloney, Alan Fletcher, Stefan Dennis, Jackie Woodburne\nMusical_ID : 1, 2, 4, 6\nCharacter : Harold Bishop, Susan Kennedy, Karl Kennedy, Alf Stewart, Toadfish Rebecchi, Sally Fletcher, Paul Robinson, Lou Carpenter, Irene Roberts\nDuration : 1988—, 1985–1992, 1993, 2004—, 1993—, 1988, 1992—, 1995, 1996—, 1987–1991, 1996–2009, 2011, 1994—, 1988–2008, 2013\nage : 26, 20, 17, 21, 18, 22\n*/\n \nCREATE TABLE farm (\n\t\"Farm_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"Total_Horses\" REAL, \n\t\"Working_Horses\" REAL, \n\t\"Total_Cattle\" REAL, \n\t\"Oxen\" REAL, \n\t\"Bulls\" REAL, \n\t\"Cows\" REAL, \n\t\"Pigs\" REAL, \n\t\"Sheep_and_Goats\" REAL, \n\tPRIMARY KEY (\"Farm_ID\")\n)\n/*\nColumns in farm and all categories for low cardinality columns :\nFarm_ID : 1, 2, 5, 7, 8, 4, 6, 3\nYear : 1932, 1928, 1930, 1931, 1927, 1934, 1929, 1933\nTotal_Horses : 3658.9, 5056.5, 2546.9, 5607.5, 4781.3, 5308.2, 5486.9, 2604.8\nWorking_Horses : 3721.6, 3711.2, 3900.1, 3711.6, 4090.5, 4198.8, 2197.3, 3593.7\nTotal_Cattle : 6274.1, 4446.3, 6189.5, 8374.5, 5277.5, 7611.0, 5006.7, 8604.8\nOxen : 805.5, 895.3, 156.5, 593.7, 116.9, 113.8, 254.8, 105.2\nBulls : 49.6, 71.6, 40.0, 26.9, 32.8, 31.6, 37.6, 46.7\nCows : 3852.1, 2739.5, 2518.0, 2407.2, 3377.0, 3987.0, 3873.0, 3471.6\nPigs : 3171.8, 4236.7, 4161.2, 2089.2, 4412.4, 3373.3, 6962.9, 2623.7\nSheep_and_Goats : 7956.3, 7030.8, 2197.1, 2004.7, 3364.8, 4533.4, 2109.5, 8112.2\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n" }, { "role": "user", "content": "Find the id of the order which is shipped most recently." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: shipments.\nFrom these tables, I'll be using the following columns: order_id, shipment_date.\nThe SQL query I'll be generating is:\nSELECT order_id FROM shipments WHERE shipment_date = (SELECT max(shipment_date) FROM shipments)" } ]
[ { "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 \"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 \"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 \"Order_Items\" (\n\torder_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\torder_quantity VARCHAR(15), \n\tFOREIGN KEY(order_id) REFERENCES \"Customer_Orders\" (order_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id)\n)\n/*\nColumns in Order_Items and all categories for low cardinality columns :\norder_id : 13, 11, 2, 5, 7, 8, 14, 10\nproduct_id : 1, 2, 3\norder_quantity : 1, 2, 5, 7, 8, 6, 9\n*/\n \nCREATE TABLE performance (\n\t\"Performance_ID\" REAL, \n\t\"Date\" TEXT, \n\t\"Host\" TEXT, \n\t\"Location\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Performance_ID\")\n)\n/*\nColumns in performance and all categories for low cardinality columns :\nPerformance_ID : 3.0, 1.0, 2.0, 6.0, 4.0, 5.0\nDate : February 7, February 4, February 2, February 5, February 10, February 11\nHost : Ottawa Senators, New York Rangers, Pittsburgh Penguins, Atlanta Thrashers, Montreal Canadiens, Boston Bruins\nLocation : Madison Square Garden, Scotiabank Place, Verizon Center, TD Garden, Bell Centre\nAttendance : 2173, 1878, 1877, 1820, 1982, 165\n*/\n \nCREATE TABLE \"Lessons\" (\n\tlesson_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tlesson_status_code VARCHAR(15) NOT NULL, \n\tstaff_id INTEGER, \n\tvehicle_id INTEGER NOT NULL, \n\tlesson_date DATETIME, \n\tlesson_time VARCHAR(10), \n\tprice DOUBLE, \n\tPRIMARY KEY (lesson_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id), \n\tFOREIGN KEY(vehicle_id) REFERENCES \"Vehicles\" (vehicle_id)\n)\n/*\nColumns in Lessons and 3 examples in each column for high cardinality columns :\nlesson_id : 1, 13, 11\nlesson_date : 2018-03-03 15:10:16, 2018-03-07 16:12:36, 2018-03-08 16:05:05\nprice : 306.0, 492.0, 446.0\n*/\n/*\nColumns in Lessons and all categories for low cardinality columns :\ncustomer_id : 13, 11, 2, 5, 8, 6, 3, 10, 9\nlesson_status_code : Completed, Cancelled\nstaff_id : 1, 11, 5, 8, 4, 14, 3, 12, 15\nvehicle_id : 1, 2, 3\nlesson_time : 2, 5, 4, 6, 3, 9\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"CHECKING\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in CHECKING and all categories for low cardinality columns :\ncustid : 1, 2, 5, 7, 4, 6, 3\nbalance : 3000.0, 10000.0, 2000.0, 7.0, 7000.0, 77.0\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 player (\n\t\"Player_ID\" INTEGER, \n\t\"Player\" TEXT, \n\t\"Team\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Position\" TEXT, \n\t\"School_ID\" INTEGER, \n\tPRIMARY KEY (\"Player_ID\"), \n\tFOREIGN KEY(\"School_ID\") REFERENCES school (\"School_ID\")\n)\n/*\nColumns in player and 3 examples in each column for high cardinality columns :\nPlayer_ID : 17, 21, 9\nPlayer : Buster Posey, Brett Wallace, Timothy Beckham\nTeam : Los Angeles Dodgers, San Diego Padres, Toronto Blue Jays\n*/\n/*\nColumns in player and all categories for low cardinality columns :\nAge : 16, 18, 17, 14, 15\nPosition : Second baseman, Outfielder, Left-handed pitcher, Shortstop, Third baseman, First baseman, First Baseman, Catcher, Right-handed pitcher\nSchool_ID : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"Users\" (\n\tuser_id INTEGER, \n\trole_code VARCHAR(15) NOT NULL, \n\tuser_name VARCHAR(40), \n\tuser_login VARCHAR(40), \n\tpassword VARCHAR(40), \n\tPRIMARY KEY (user_id), \n\tFOREIGN KEY(role_code) REFERENCES \"Roles\" (role_code)\n)\n/*\nColumns in Users and 3 examples in each column for high cardinality columns :\nuser_id : 1, 13, 11\nuser_name : glenna.simonis, jacklyn.schmitt, larson.vesta\npassword : 20241478f890508ac47870cfba472e1db04a71ca, 90db8f51449e6c39e2a01f0b649d5a92fe76bbbb, 27cca8f94136f0e8971b5ca555a21ff756871b27\n*/\n/*\nColumns in Users and all categories for low cardinality columns :\nrole_code : PROJ-MGR, DBA\nuser_login : 1, 0\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"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 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 \"Staff_Roles\" (\n\trole_code VARCHAR(10), \n\trole_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (role_code)\n)\n/*\nColumns in Staff_Roles and all categories for low cardinality columns :\nrole_code : researcher, leader\nrole_description : Project Researcher, Project Leader\n*/\n \nCREATE TABLE constructors (\n\t\"constructorId\" INTEGER, \n\t\"constructorRef\" TEXT, \n\tname TEXT, \n\tnationality TEXT, \n\turl TEXT, \n\tPRIMARY KEY (\"constructorId\")\n)\n/*\nColumns in constructors and 3 examples in each column for high cardinality columns :\nconstructorId : 87, 56, 65\nconstructorRef : mf1, prost, lambo\nname : McLaren, Protos, Eagle-Climax\nnationality : Mexican, Russian, British\nurl : http://en.wikipedia.org/wiki/Minardi, http://en.wikipedia.org/wiki/Officine_Specializate_Costruzione_Automobili, http://en.wikipedia.org/wiki/Scirocco-Powell\n*/\n\n \nCREATE TABLE countries (\n\t\"COUNTRY_ID\" VARCHAR(2) NOT NULL, \n\t\"COUNTRY_NAME\" VARCHAR(40) DEFAULT NULL, \n\t\"REGION_ID\" DECIMAL(10, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"COUNTRY_ID\"), \n\tFOREIGN KEY(\"REGION_ID\") REFERENCES regions (\"REGION_ID\")\n)\n/*\nColumns in countries and 3 examples in each column for high cardinality columns :\nCOUNTRY_ID : AR, JP, DE\nCOUNTRY_NAME : Israel, Australia, India\n*/\n/*\nColumns in countries and all categories for low cardinality columns :\nREGION_ID : 1, 2, 4, 3\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 \"Product_Characteristics\" (\n\tproduct_id INTEGER NOT NULL, \n\tcharacteristic_id INTEGER NOT NULL, \n\tproduct_characteristic_value VARCHAR(50), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(characteristic_id) REFERENCES \"Characteristics\" (characteristic_id)\n)\n/*\nColumns in Product_Characteristics and all categories for low cardinality columns :\nproduct_id : 1, 13, 11, 5, 7, 8, 6, 12, 14\ncharacteristic_id : 13, 10, 11, 2, 4, 6, 12, 3, 15\nproduct_characteristic_value : high, low, medium\n*/\n" }, { "role": "user", "content": "Which order has the most recent shipment? Give me the order id." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: shipments.\nFrom these tables, I'll be using the following columns: order_id, shipment_date.\nThe SQL query I'll be generating is:\nSELECT order_id FROM shipments WHERE shipment_date = (SELECT max(shipment_date) FROM shipments)" } ]
[ { "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 (\n\t\"Party_ID\" INTEGER, \n\t\"Party_Theme\" TEXT, \n\t\"Location\" TEXT, \n\t\"First_year\" TEXT, \n\t\"Last_year\" TEXT, \n\t\"Number_of_hosts\" INTEGER, \n\tPRIMARY KEY (\"Party_ID\")\n)\n/*\nColumns in party and all categories for low cardinality columns :\nParty_ID : 1, 2, 5, 7, 8, 4, 6, 3\nParty_Theme : Qlubtempo, In Qontrol, Club Q-BASE, QrimeTime, Teqnology, Houseqlassics, Hardcore Resurrection, Spring\nLocation : Various locations, RAI Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam, Hemkade 48 Zaandam, Heineken Music Hall Amsterdam\nFirst_year : 2004, 2001, 1999, 2000, 2002\nLast_year : 2004, 2001, 2002, 2003, 2010, 2007\nNumber_of_hosts : 5, 7, 23, 4, 6, 18, 31\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Services\" (\n\t\"Service_ID\" INTEGER NOT NULL, \n\t\"Service_name\" VARCHAR(40), \n\tPRIMARY KEY (\"Service_ID\")\n)\n/*\nColumns in Services and all categories for low cardinality columns :\nService_ID : 1, 9, 4, 6\nService_name : Upgrade a policy, New policy application, Close a policy, Change a policy\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tpayment_method VARCHAR(15) NOT NULL, \n\tcustomer_name VARCHAR(80), \n\tdate_became_customer DATETIME, \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_name : Alexane Kilback, Salvatore Tillman, Eunice Morar\ndate_became_customer : 2018-03-01 23:20:10, 2018-03-09 17:41:58, 2018-03-07 18:05:11\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\npayment_method : Cheque, Credit Card, Cash\nother_customer_details : None, VIP\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_first_name VARCHAR(50), \n\tcustomer_middle_initial VARCHAR(1), \n\tcustomer_last_name VARCHAR(50), \n\tgender VARCHAR(1), \n\temail_address VARCHAR(255), \n\tlogin_name VARCHAR(80), \n\tlogin_password VARCHAR(20), \n\tphone_number VARCHAR(255), \n\ttown_city VARCHAR(50), \n\tstate_county_province VARCHAR(50), \n\tcountry VARCHAR(50), \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 : Devin, Ruby, Joesph\ncustomer_last_name : Muller, Weimann, Glover\nemail_address : roosevelt.collier@example.org, pyundt@example.org, anastacio45@example.org\nlogin_name : zdeckow, rubye.padberg, feeney.lauriane\nlogin_password : 180a37476c537e78d3de, 035f2ba1e2a675c4f426, d4ade599672bccdabeee\nphone_number : 241.796.1219x37862, (791)562-7792x45732, (193)465-6674x4952\ntown_city : North Nellie, Kenshire, West Khaliltown\nstate_county_province : Louisiana, SouthDakota, Kansas\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\ncustomer_middle_initial : E, K, H, A, G, L, V, M, B\ngender : 1, 0\ncountry : USA\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 host (\n\t\"Host_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Nationality\" TEXT, \n\t\"Age\" TEXT, \n\tPRIMARY KEY (\"Host_ID\")\n)\n/*\nColumns in host and all categories for low cardinality columns :\nHost_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nName : Lloyd Daniels, Kornel David, Antonio Davis, Carlos Delfino, DeMar DeRozan, Ed Davis, Austin Daye, Derrick Dial, Justin Dentmon, Hubert Davis\nNationality : United States, Argentina, Hungary\nAge : 26, 45, 37, 40, 30, 60, 47, 43, 31\n*/\n \nCREATE TABLE \"Visits_Restaurant\" (\n\t\"StuID\" INTEGER, \n\t\"ResID\" INTEGER, \n\t\"Time\" TIMESTAMP, \n\t\"Spent\" FLOAT, \n\tFOREIGN KEY(\"StuID\") REFERENCES \"Student\" (\"StuID\"), \n\tFOREIGN KEY(\"ResID\") REFERENCES \"Restaurant\" (\"ResID\")\n)\n/*\nColumns in Visits_Restaurant and all categories for low cardinality columns :\nStuID : 1001, 1032\nResID : 1, 2\nTime : 2017-10-09 18:15:00, 2017-10-08 13:00:30\nSpent : 13.2, 6.53\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 device (\n\t\"Device_ID\" INTEGER, \n\t\"Device\" TEXT, \n\t\"Carrier\" TEXT, \n\t\"Package_Version\" TEXT, \n\t\"Applications\" TEXT, \n\t\"Software_Platform\" TEXT, \n\tPRIMARY KEY (\"Device_ID\")\n)\n/*\nColumns in device and all categories for low cardinality columns :\nDevice_ID : 1, 2, 5, 4, 6, 3\nDevice : Huawei, Galaxy, Apple, Xiaomi, BlackBerry Storm 9530, Samsung\nCarrier : MTS Mobility, Bell Mobility, Telus Mobility, Vodafone AU, Verizon Wireless, Iusacell\nPackage_Version : 4.7.0.208, 5.0.0.742, 5.0.0.808, 5.0.0.328, 5.0.0.419\nApplications : 4.7.0.151, 5.0.0.451, 5.0.0.328, 5.0.0.419\nSoftware_Platform : iOS, Android\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 train (\n\tid INTEGER, \n\ttrain_number INTEGER, \n\tname TEXT, \n\torigin TEXT, \n\tdestination TEXT, \n\ttime TEXT, \n\tinterval TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in train and 3 examples in each column for high cardinality columns :\nid : 1, 11, 2\ntrain_number : 16526, 56700, 56701\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\norigin : Quilon, Mumbai, Bangalore, Madurai, Nagercoil, Chennai, Guruvayur, Kanniyakumari, Trivandrum\ndestination : Mumbai, Mangalore, Bangalore, Madurai, Quilon Junction, Chennai, Guruvayur, Kanniyakumari, Trivandrum\ninterval : Daily\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"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 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 \"Rooms\" (\n\t\"RoomId\" TEXT, \n\t\"roomName\" TEXT, \n\tbeds INTEGER, \n\t\"bedType\" TEXT, \n\t\"maxOccupancy\" INTEGER, \n\t\"basePrice\" INTEGER, \n\tdecor TEXT, \n\tPRIMARY KEY (\"RoomId\")\n)\n/*\nColumns in Rooms and all categories for low cardinality columns :\nRoomId : IBD, IBS, RTE, CAS, FNA, HBB, AOB, MWC, TAA, RND\nroomName : Convoke and sanguine, Immutable before decorum, Abscond or bolster, Recluse and defiance, Thrift and accolade, Riddle to exculpate, Harbinger but bequest, Frugal not apropos, Interim but salutary, Mendicant with cryptic\nbeds : 1, 2\nbedType : King, Double, Queen\nmaxOccupancy : 2, 4\nbasePrice : 250, 75, 100, 150, 125, 175\ndecor : modern, rustic, traditional\n*/\n" }, { "role": "user", "content": "List the names of all distinct products in alphabetical order." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: products.\nFrom these tables, I'll be using the following columns: product_name.\nThe SQL query I'll be generating is:\nSELECT DISTINCT product_name FROM products ORDER BY product_name" } ]
[ { "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 \"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 \"Delivery_Routes\" (\n\troute_id INTEGER, \n\troute_name VARCHAR(50), \n\tother_route_details VARCHAR(255), \n\tPRIMARY KEY (route_id)\n)\n/*\nColumns in Delivery_Routes and 3 examples in each column for high cardinality columns :\nroute_id : 1, 13, 11\nroute_name : Huel, Armstrong and Senger, Brekke, Powlowski and Fritsch, Heidenreich Group\nother_route_details : 534 Lubowitz Terrace\nLake Tomfort, LA 52697-4998, 941 Ritchie Plains Suite 833\nNorth Jerry, LA 32804-7405, 36578 Kirsten Terrace\nKrajcikside, NH 29063\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Club\" (\n\t\"ClubID\" INTEGER, \n\t\"ClubName\" VARCHAR(40), \n\t\"ClubDesc\" VARCHAR(1024), \n\t\"ClubLocation\" VARCHAR(40), \n\tPRIMARY KEY (\"ClubID\")\n)\n/*\nColumns in Club and all categories for low cardinality columns :\nClubID : 1, 2, 4, 3\nClubName : Bootup Baltimore, Pen and Paper Gaming, Tennis Club, Hopkins Student Enterprises\nClubDesc : Venture capital fund for student business., A competitive tennis club., Refurbish computers; teach kids and adults about computer basics., Play pen and paper games on campus.\nClubLocation : HHH, AKW\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"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 : 7089 Mueller Forks, 535 Ariel Brook, 3904 Stroman Passage\ncity : Buckridgehaven, South Eugene, Elviebury\nzip_postcode : 22194, 99903, 14445\nstate_province_county : Louisiana, Kentucky, Ohio\n*/\n/*\nColumns in Addresses and all categories for low cardinality columns :\ncountry : USA\n*/\n \nCREATE TABLE device (\n\t\"Device_ID\" INTEGER, \n\t\"Device\" TEXT, \n\t\"Carrier\" TEXT, \n\t\"Package_Version\" TEXT, \n\t\"Applications\" TEXT, \n\t\"Software_Platform\" TEXT, \n\tPRIMARY KEY (\"Device_ID\")\n)\n/*\nColumns in device and all categories for low cardinality columns :\nDevice_ID : 1, 2, 5, 4, 6, 3\nDevice : Huawei, Galaxy, Apple, Xiaomi, BlackBerry Storm 9530, Samsung\nCarrier : MTS Mobility, Bell Mobility, Telus Mobility, Vodafone AU, Verizon Wireless, Iusacell\nPackage_Version : 4.7.0.208, 5.0.0.742, 5.0.0.808, 5.0.0.328, 5.0.0.419\nApplications : 4.7.0.151, 5.0.0.451, 5.0.0.328, 5.0.0.419\nSoftware_Platform : iOS, Android\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Web_client_accelerator\" (\n\tid INTEGER, \n\tname TEXT, \n\t\"Operating_system\" TEXT, \n\t\"Client\" TEXT, \n\t\"Connection\" TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in Web_client_accelerator and 3 examples in each column for high cardinality columns :\nid : 17, 9, 16\nname : Freewire, Toonel, Fasterfox\nOperating_system : Unix (Linux, *BSD, Mac OS X, others), Windows, Windows, Mac and Mobile devices, Windows, Mac, Mobile devices\n*/\n/*\nColumns in Web_client_accelerator and all categories for low cardinality columns :\nClient : End User, ISP, End user, ISP, user/Google server, user/Opera server, user/ISP, ISP, All, user\nConnection : up to 756kbit/s, Broadband, Any, Broadband, Satellite, Wireless, Fiber, DSL, Dial, DSL, ISDN, Satellite, wireless, Dial-up, Broadband, DSL, ISDN, Satellite, Wireless, Dialup, Wireless, Broadband, DSL, Dial-up\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 \"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 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" }, { "role": "user", "content": "Sort all the distinct products in alphabetical order." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: products.\nFrom these tables, I'll be using the following columns: product_name.\nThe SQL query I'll be generating is:\nSELECT DISTINCT product_name FROM products ORDER BY product_name" } ]
[ { "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 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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Price\" DECIMAL NOT NULL, \n\t\"Manufacturer\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Manufacturer\") REFERENCES \"Manufacturers\" (\"Code\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nCode : 1, 11, 2\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nName : Printer, Floppy disk, Memory, Monitor, Toner cartridge, CD drive, DVD burner, Hard drive, ZIP drive, DVD drive\nPrice : 150.0000000000, 120.0000000000, 90.0000000000, 5.0000000000, 270.0000000000, 180.0000000000, 66.0000000000, 240.0000000000\nManufacturer : 1, 2, 5, 4, 6, 3\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE book_club (\n\tbook_club_id INTEGER, \n\t\"Year\" INTEGER, \n\t\"Author_or_Editor\" TEXT, \n\t\"Book_Title\" TEXT, \n\t\"Publisher\" TEXT, \n\t\"Category\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (book_club_id)\n)\n/*\nColumns in book_club and 3 examples in each column for high cardinality columns :\nbook_club_id : 1, 11, 2\nAuthor_or_Editor : Dolores Klaich, Antoinette Azolakov, Sandy Bayer\nBook_Title : Lessons In Murder, Somewhere in the Night, Mundaneӳ World\n*/\n/*\nColumns in book_club and all categories for low cardinality columns :\nYear : 1989, 1990\nPublisher : International Polygonics, William Morrow, St. Martin's Press, Crossing Press, Alyson, Naiad Press, Banned Books, Mysterious Press\nCategory : Lesb. M/SF, Gay SF/F, Gay M/SF\nResult : Nom, Won [B ], Won, Won [A ]\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Institution\" (\n\t\"Institution_id\" TEXT, \n\t\"Institution\" TEXT, \n\t\"Location\" TEXT, \n\t\"Founded\" REAL, \n\t\"Type\" TEXT, \n\t\"Enrollment\" INTEGER, \n\t\"Team\" TEXT, \n\t\"Primary_Conference\" TEXT, \n\tbuilding_id TEXT, \n\tPRIMARY KEY (\"Institution_id\"), \n\tFOREIGN KEY(building_id) REFERENCES building (building_id)\n)\n/*\nColumns in Institution and 3 examples in each column for high cardinality columns :\nInstitution_id : 1, 2, 5\nInstitution : Ave Maria University, Lindenwood University–Belleville, Point University\nLocation : Mayville, North Dakota, Jacksonville, Florida, Babson Park, Florida\nEnrollment : 967, 616, 3102\nTeam : Gyrenes, Comets, Warriors\n*/\n/*\nColumns in Institution and all categories for low cardinality columns :\nFounded : 1937.0, 1881.0, 1927.0, 2003.0, 1883.0, 1866.0, 1998.0, 1884.0, 1889.0, 1890.0\nType : Public, Tribal, Private\nPrimary_Conference : MCAC, CalPac, Gulf Coast (GCAC), AAC, none, The Sun\nbuilding_id : 1, 2, 5, 7, 4, 3, 0\n*/\n \nCREATE TABLE \"Procedures\" (\n\t\"Code\" INTEGER NOT NULL, \n\t\"Name\" VARCHAR(30) NOT NULL, \n\t\"Cost\" REAL NOT NULL, \n\tPRIMARY KEY (\"Code\")\n)\n/*\nColumns in Procedures and all categories for low cardinality columns :\nCode : 1, 2, 5, 7, 4, 6, 3\nName : Obfuscated Dermogastrotomy, Obtuse Pyloric Recombobulation, Follicular Demiectomy, Reverse Rhinopodoplasty, Folded Demiophtalmectomy, Complete Walletectomy, Reversible Pancreomyoplasty\nCost : 5600.0, 1500.0, 10000.0, 25.0, 4500.0, 3750.0, 4899.0\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"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 \"Complaints\" (\n\tcomplaint_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\tcomplaint_outcome_code VARCHAR(20) NOT NULL, \n\tcomplaint_status_code VARCHAR(20) NOT NULL, \n\tcomplaint_type_code VARCHAR(20) NOT NULL, \n\tdate_complaint_raised DATETIME, \n\tdate_complaint_closed DATETIME, \n\tstaff_id INTEGER NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Complaints and 3 examples in each column for high cardinality columns :\ncomplaint_id : 1, 11, 2\n*/\n/*\nColumns in Complaints and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\ncustomer_id : 120, 114, 113, 116, 117, 115, 118\ncomplaint_outcome_code : OK\ncomplaint_status_code : Open, Closed, New\ncomplaint_type_code : Product Failure, Product Unusable\ndate_complaint_raised : 2006-10-29 07:08:46, 2002-07-18 10:59:35, 1977-08-06 00:31:19, 1987-07-11 14:40:30, 1973-02-10 22:55:56, 2007-10-14 21:50:43\ndate_complaint_closed : 2013-09-14 02:59:10, 1975-10-11 05:54:30, 1970-10-14 00:57:25, 1976-04-19 11:03:06, 1995-09-11 14:48:46, 2000-08-17 17:02:48\nstaff_id : 120, 114, 116, 117, 115, 118\n*/\n \nCREATE TABLE \"Songs\" (\n\t\"SongId\" INTEGER, \n\t\"Title\" TEXT, \n\tPRIMARY KEY (\"SongId\")\n)\n/*\nColumns in Songs and all categories for low cardinality columns :\nSongId : \nTitle : \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 follows (\n\tf1 INTEGER NOT NULL, \n\tf2 INTEGER NOT NULL, \n\tPRIMARY KEY (f1, f2), \n\tFOREIGN KEY(f2) REFERENCES user_profiles (uid), \n\tFOREIGN KEY(f1) REFERENCES user_profiles (uid)\n)\n/*\nColumns in follows and all categories for low cardinality columns :\nf1 : 1, 2, 5, 7, 3\nf2 : 1, 2, 5, 4, 6, 3\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" }, { "role": "user", "content": "List the ids of all distinct orders ordered by placed date." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders.\nFrom these tables, I'll be using the following columns: order_id, date_order_placed.\nThe SQL query I'll be generating is:\nSELECT DISTINCT order_id FROM orders ORDER BY date_order_placed" } ]
[ { "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 \"Characteristics\" (\n\tcharacteristic_id INTEGER, \n\tcharacteristic_type_code VARCHAR(15) NOT NULL, \n\tcharacteristic_data_type VARCHAR(10), \n\tcharacteristic_name VARCHAR(80), \n\tother_characteristic_details VARCHAR(255), \n\tPRIMARY KEY (characteristic_id), \n\tFOREIGN KEY(characteristic_type_code) REFERENCES \"Ref_Characteristic_Types\" (characteristic_type_code)\n)\n/*\nColumns in Characteristics and 3 examples in each column for high cardinality columns :\ncharacteristic_id : 1, 13, 11\ncharacteristic_data_type : placeat, dolores, mollitia\n*/\n/*\nColumns in Characteristics and all categories for low cardinality columns :\ncharacteristic_type_code : Grade, Purity\ncharacteristic_name : hot, error, cool, fast, warm, slow\nother_characteristic_details : None\n*/\n \nCREATE TABLE race (\n\t\"Race_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Class\" TEXT, \n\t\"Date\" TEXT, \n\t\"Track_ID\" TEXT, \n\tPRIMARY KEY (\"Race_ID\"), \n\tFOREIGN KEY(\"Track_ID\") REFERENCES track (\"Track_ID\")\n)\n/*\nColumns in race and all categories for low cardinality columns :\nRace_ID : 1, 2, 5, 7, 4, 6, 3\nName : Bosch Engineering 250 at VIR, RumBum.com 250, Sahlen's Six Hours of the Glen, Lime Rock GT Classic 250, Gainsco Grand Prix of Miami, Mexico City 250, Rolex 24 At Daytona\nClass : GT, DP/GT\nDate : January 26 January 27, June 7, April 19, May 26, May 17, April 27, March 29\nTrack_ID : 1, 2, 5, 7, 4, 6\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 schedule (\n\t\"Cinema_ID\" INTEGER, \n\t\"Film_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Show_times_per_day\" INTEGER, \n\t\"Price\" FLOAT, \n\tPRIMARY KEY (\"Cinema_ID\", \"Film_ID\"), \n\tFOREIGN KEY(\"Cinema_ID\") REFERENCES cinema (\"Cinema_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\")\n)\n/*\nColumns in schedule and all categories for low cardinality columns :\nCinema_ID : 1, 2, 6, 10, 9\nFilm_ID : 1, 2, 5, 4, 3\nDate : 20 May, 2 Aug, 11 July, 21 May, 19 May, 21 Jun\nShow_times_per_day : 2, 5, 4, 3\nPrice : 9.99, 8.99, 12.99, 15.99\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Services\" (\n\tservice_id INTEGER NOT NULL, \n\torganization_id INTEGER NOT NULL, \n\tservice_type_code CHAR(15) NOT NULL, \n\tservice_details VARCHAR(255), \n\tPRIMARY KEY (service_id), \n\tFOREIGN KEY(organization_id) REFERENCES \"Organizations\" (organization_id)\n)\n/*\nColumns in Services and 3 examples in each column for high cardinality columns :\nservice_id : 87, 41, 65\n*/\n/*\nColumns in Services and all categories for low cardinality columns :\norganization_id : 7, 10, 8\nservice_type_code : Cleanning, Moving Out, Check, Pay bills\nservice_details : Satisfied, Unsatisfied\n*/\n \nCREATE TABLE shop (\n\t\"Shop_ID\" INTEGER, \n\t\"Shop_Name\" TEXT, \n\t\"Location\" TEXT, \n\t\"Open_Date\" TEXT, \n\t\"Open_Year\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\")\n)\n/*\nColumns in shop and 3 examples in each column for high cardinality columns :\nShop_ID : 1, 11, 2\nShop_Name : Pentre store, Best Buy, Apple\nOpen_Date : 24 February, 18 February, 1 January\n*/\n/*\nColumns in shop and all categories for low cardinality columns :\nLocation : Maerdy, Porth, Blaenllechau, Pentre, Penygraig, Gelli, Dinas, Wattstown, Cymmer\nOpen_Year : 2009, 2013, 2015, 2017, 2006, 2011, 2014, 2010, 2007\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 \"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 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_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tparent_product_id INTEGER, \n\tproduct_category_code VARCHAR(20) NOT NULL, \n\tdate_product_first_available DATETIME, \n\tdate_product_discontinued DATETIME, \n\tproduct_name VARCHAR(80), \n\tproduct_description VARCHAR(255), \n\tproduct_price DECIMAL(19, 4), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\nparent_product_id : 8, 4, 9, 3\nproduct_category_code : Food, Book, Hardware\ndate_product_first_available : 1988-09-29 17:54:50, 1998-06-20 15:04:11, 1994-12-18 15:13:19, 1974-06-25 12:26:47\ndate_product_discontinued : 1987-12-20 13:46:16, 1997-07-02 18:26:16, 1980-06-26 10:40:19, 1991-08-20 05:22:31\nproduct_name : Chocolate, The Great Gatsby, Mouse, Keyboard\nproduct_description : Designed for games, Handmade chocolate, American novel, Blue tooth mouse\nproduct_price : 23.3500, 2.8800, 109.9900, 35.0000\n*/\n \nCREATE TABLE \"Complaints\" (\n\tcomplaint_id INTEGER NOT NULL, \n\tproduct_id INTEGER NOT NULL, \n\tcustomer_id INTEGER NOT NULL, \n\tcomplaint_outcome_code VARCHAR(20) NOT NULL, \n\tcomplaint_status_code VARCHAR(20) NOT NULL, \n\tcomplaint_type_code VARCHAR(20) NOT NULL, \n\tdate_complaint_raised DATETIME, \n\tdate_complaint_closed DATETIME, \n\tstaff_id INTEGER NOT NULL, \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id)\n)\n/*\nColumns in Complaints and 3 examples in each column for high cardinality columns :\ncomplaint_id : 1, 11, 2\n*/\n/*\nColumns in Complaints and all categories for low cardinality columns :\nproduct_id : 120, 119, 117, 118\ncustomer_id : 120, 114, 113, 116, 117, 115, 118\ncomplaint_outcome_code : OK\ncomplaint_status_code : Open, Closed, New\ncomplaint_type_code : Product Failure, Product Unusable\ndate_complaint_raised : 2006-10-29 07:08:46, 2002-07-18 10:59:35, 1977-08-06 00:31:19, 1987-07-11 14:40:30, 1973-02-10 22:55:56, 2007-10-14 21:50:43\ndate_complaint_closed : 2013-09-14 02:59:10, 1975-10-11 05:54:30, 1970-10-14 00:57:25, 1976-04-19 11:03:06, 1995-09-11 14:48:46, 2000-08-17 17:02:48\nstaff_id : 120, 114, 116, 117, 115, 118\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 \"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" }, { "role": "user", "content": "What are ids of the all distinct orders, sorted by placement date?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders.\nFrom these tables, I'll be using the following columns: order_id, date_order_placed.\nThe SQL query I'll be generating is:\nSELECT DISTINCT order_id FROM orders ORDER BY date_order_placed" } ]
[ { "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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Restaurant\" (\n\t\"ResID\" INTEGER, \n\t\"ResName\" VARCHAR(100), \n\t\"Address\" VARCHAR(100), \n\t\"Rating\" INTEGER, \n\tPRIMARY KEY (\"ResID\")\n)\n/*\nColumns in Restaurant and all categories for low cardinality columns :\nResID : 1, 2\nResName : Subway, Honeygrow\nAddress : 3212 St Paul St, Baltimore, MD 21218, 3233 St Paul St, Baltimore, MD 21218\nRating : 4, 3\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE takes (\n\t\"ID\" VARCHAR(5), \n\tcourse_id VARCHAR(8), \n\tsec_id VARCHAR(8), \n\tsemester VARCHAR(6), \n\tyear NUMERIC(4, 0), \n\tgrade VARCHAR(2), \n\tPRIMARY KEY (\"ID\", course_id, sec_id, semester, year), \n\tFOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year), \n\tFOREIGN KEY(\"ID\") REFERENCES student (\"ID\")\n)\n/*\nColumns in takes and 3 examples in each column for high cardinality columns :\nID : 99189, 44706, 56058\ncourse_id : 843, 400, 349\n*/\n/*\nColumns in takes and all categories for low cardinality columns :\nsec_id : 1, 2, 3\nsemester : Fall, Spring\nyear : 2004, 2009, 2001, 2005, 2008, 2006, 2003, 2002, 2010, 2007\ngrade : B-, B , C , B+, A , A-, C-, C+, A+\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 \"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 party (\n\t\"Party_ID\" INTEGER, \n\t\"Minister\" TEXT, \n\t\"Took_office\" TEXT, \n\t\"Left_office\" TEXT, \n\t\"Region_ID\" INTEGER, \n\t\"Party_name\" TEXT, \n\tPRIMARY KEY (\"Party_ID\"), \n\tFOREIGN KEY(\"Region_ID\") REFERENCES region (\"Region_ID\")\n)\n/*\nColumns in party and all categories for low cardinality columns :\nParty_ID : 1, 2, 5, 4, 3\nMinister : Kojo Botsio (MP), Ebenezer Ako-Adjei (MP), Dr. Kwame Nkrumah (MP), Imoru Egala (MP)\nTook_office : 1958, 1961, 1959, 1960, 1957\nLeft_office : 1962, 1958, 1961, 1959, 1960\nRegion_ID : 1, 2, 5, 4, 3\nParty_name : Convention Peoples Party, Sinefine Party, Convention Union Party, 3, Progress Party\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"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 \"Course\" (\n\t\"CID\" VARCHAR(7), \n\t\"CName\" VARCHAR(40), \n\t\"Credits\" INTEGER, \n\t\"Instructor\" INTEGER, \n\t\"Days\" VARCHAR(5), \n\t\"Hours\" VARCHAR(11), \n\t\"DNO\" INTEGER, \n\tPRIMARY KEY (\"CID\"), \n\tFOREIGN KEY(\"Instructor\") REFERENCES \"Faculty\" (\"FacID\"), \n\tFOREIGN KEY(\"DNO\") REFERENCES \"Department\" (\"DNO\")\n)\n/*\nColumns in Course and 3 examples in each column for high cardinality columns :\nCID : 600.433, 550.413, 050.381\nCName : UNIX SYSTEMS PROGRAMMING, BUSINESS LAW II, HIGH PERFORMANCE GRAPHICS AND MODELING\nInstructor : 6112, 7134, 8918\nDays : Tu, TTh, M\nHours : 4-5:15, 9, 1-4\n*/\n/*\nColumns in Course and all categories for low cardinality columns :\nCredits : 1, 2, 4, 3\nDNO : 50, 520, 550, 600\n*/\n \nCREATE TABLE locations (\n\t\"LOCATION_ID\" DECIMAL(4, 0) DEFAULT '0' NOT NULL, \n\t\"STREET_ADDRESS\" VARCHAR(40) DEFAULT NULL, \n\t\"POSTAL_CODE\" VARCHAR(12) DEFAULT NULL, \n\t\"CITY\" VARCHAR(30) NOT NULL, \n\t\"STATE_PROVINCE\" VARCHAR(25) DEFAULT NULL, \n\t\"COUNTRY_ID\" VARCHAR(2) DEFAULT NULL, \n\tPRIMARY KEY (\"LOCATION_ID\"), \n\tFOREIGN KEY(\"COUNTRY_ID\") REFERENCES countries (\"COUNTRY_ID\")\n)\n/*\nColumns in locations and 3 examples in each column for high cardinality columns :\nLOCATION_ID : 1900, 1700, 1200\nSTREET_ADDRESS : 2004 Charade Rd, Mariano Escobedo 9991, 9450 Kamiya-cho\nPOSTAL_CODE : , 1689, 98199\nCITY : Tokyo, Southlake, South San Francisco\nSTATE_PROVINCE : , New South Wales, Sao Paulo\nCOUNTRY_ID : AU, NL, JP\n*/\n\n \nCREATE TABLE \"Products\" (\n\t\"Code\" INTEGER, \n\t\"Name\" VARCHAR(255) NOT NULL, \n\t\"Price\" DECIMAL NOT NULL, \n\t\"Manufacturer\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"Code\"), \n\tFOREIGN KEY(\"Manufacturer\") REFERENCES \"Manufacturers\" (\"Code\")\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nCode : 1, 11, 2\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nName : Printer, Floppy disk, Memory, Monitor, Toner cartridge, CD drive, DVD burner, Hard drive, ZIP drive, DVD drive\nPrice : 150.0000000000, 120.0000000000, 90.0000000000, 5.0000000000, 270.0000000000, 180.0000000000, 66.0000000000, 240.0000000000\nManufacturer : 1, 2, 5, 4, 6, 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 \"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 \"Customers_Policies\" (\n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Date_Opened\" DATE, \n\t\"Date_Closed\" DATE, \n\tPRIMARY KEY (\"Customer_ID\", \"Policy_ID\"), \n\tFOREIGN KEY(\"Customer_ID\") REFERENCES \"Customers\" (\"Customer_ID\"), \n\tFOREIGN KEY(\"Policy_ID\") REFERENCES \"Available_Policies\" (\"Policy_ID\")\n)\n/*\nColumns in Customers_Policies and 3 examples in each column for high cardinality columns :\nPolicy_ID : 586, 346, 630\nDate_Opened : 2016-06-24, 2016-11-18, 2016-07-07\nDate_Closed : 2018-03-08, 2018-02-20, 2018-03-19\n*/\n/*\nColumns in Customers_Policies and all categories for low cardinality columns :\nCustomer_ID : 562, 582, 892, 826, 682, 214, 996, 256, 641\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 \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n" }, { "role": "user", "content": "What is the id of the order which has the most items?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items.\nFrom these tables, I'll be using the following columns: orders.order_id, order_items.order_id.\nThe SQL query I'll be generating is:\nSELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id 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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Ref_Document_Types\" (\n\tdocument_type_code CHAR(15) NOT NULL, \n\tdocument_type_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (document_type_code)\n)\n/*\nColumns in Ref_Document_Types and all categories for low cardinality columns :\ndocument_type_code : Hard Drive, CD, Paper\ndocument_type_description : f, u, b\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Ref_Budget_Codes\" (\n\t\"Budget_Type_Code\" CHAR(15) NOT NULL, \n\t\"Budget_Type_Description\" VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (\"Budget_Type_Code\")\n)\n/*\nColumns in Ref_Budget_Codes and all categories for low cardinality columns :\nBudget_Type_Code : GV, SF, ORG\nBudget_Type_Description : Self founded, Government, Organisation\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Band\" (\n\t\"Id\" INTEGER, \n\t\"Firstname\" TEXT, \n\t\"Lastname\" TEXT, \n\tPRIMARY KEY (\"Id\")\n)\n/*\nColumns in Band and all categories for low cardinality columns :\nId : \nFirstname : \nLastname : \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 \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 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 \"Customers\" (\n\t\"Customer_ID\" VARCHAR(100) NOT NULL, \n\t\"Address_ID\" INTEGER NOT NULL, \n\t\"Customer_Name\" VARCHAR(255), \n\t\"Customer_Phone\" VARCHAR(255), \n\t\"Customer_Email_Address\" VARCHAR(255), \n\t\"Other_Details\" VARCHAR(255), \n\tPRIMARY KEY (\"Customer_ID\"), \n\tFOREIGN KEY(\"Address_ID\") REFERENCES \"Addresses\" (\"Address_ID\"), \n\tUNIQUE (\"Customer_ID\")\n)\n/*\nColumns in Customers and 3 examples in each column for high cardinality columns :\nCustomer_ID : 714, 267, 556\nAddress_ID : 230, 110, 201\nCustomer_Name : Isaiah, Wade, Davonte\nCustomer_Phone : 02902266118, 056.568.7725, (514)659-1318x46123\nCustomer_Email_Address : cassin.cielo@example.org, eleannon@example.org, ggrant@example.com\n*/\n/*\nColumns in Customers and all categories for low cardinality columns :\nOther_Details : None, VIP\n*/\n \nCREATE TABLE \"Document_Functional_Areas\" (\n\tdocument_code VARCHAR(15) NOT NULL, \n\tfunctional_area_code VARCHAR(15) NOT NULL, \n\tFOREIGN KEY(functional_area_code) REFERENCES \"Functional_Areas\" (functional_area_code), \n\tFOREIGN KEY(document_code) REFERENCES \"Documents\" (document_code)\n)\n/*\nColumns in Document_Functional_Areas and 3 examples in each column for high cardinality columns :\ndocument_code : 217, 930, 958\n*/\n/*\nColumns in Document_Functional_Areas and all categories for low cardinality columns :\nfunctional_area_code : 1, 8, 9\n*/\n \nCREATE TABLE enrollments (\n\t\"Campus\" INTEGER, \n\t\"Year\" INTEGER, \n\t\"TotalEnrollment_AY\" INTEGER, \n\t\"FTE_AY\" INTEGER, \n\tPRIMARY KEY (\"Campus\", \"Year\"), \n\tFOREIGN KEY(\"Campus\") REFERENCES \"Campuses\" (\"Id\")\n)\n/*\nColumns in enrollments and 3 examples in each column for high cardinality columns :\nYear : 1979, 2004, 1937\nTotalEnrollment_AY : 495, 5734, 9547\nFTE_AY : 3877, 14324, 12876\n*/\n/*\nColumns in enrollments and all categories for low cardinality columns :\nCampus : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"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 \"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" }, { "role": "user", "content": "Which order deals with the most items? Return the order id." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, order_items.\nFrom these tables, I'll be using the following columns: orders.order_id, order_items.order_id.\nThe SQL query I'll be generating is:\nSELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id 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 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 \"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 election (\n\t\"Election_ID\" INTEGER, \n\t\"Counties_Represented\" TEXT, \n\t\"District\" INTEGER, \n\t\"Delegate\" TEXT, \n\t\"Party\" INTEGER, \n\t\"First_Elected\" REAL, \n\t\"Committee\" TEXT, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"District\") REFERENCES county (\"County_Id\"), \n\tFOREIGN KEY(\"Party\") REFERENCES party (\"Party_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 7, 8, 4, 6, 3\nCounties_Represented : 09.1 9A, 13, 12.1 12A, 12.2 12B\nDistrict : 1, 2, 4, 3\nDelegate : Miller, Warren E. Warren E. Miller, Bobo, Elizabeth Elizabeth Bobo, Pendergrass, Shane E. Shane Pendergrass, Bates, Gail H. Gail H. Bates, DeBoy, Steven J. Sr. Steven J. DeBoy, Sr., Guzzone, Guy Guy Guzzone, Turner, Frank S. Frank S. Turner, Malone, James E. Jr. James E. Malone, Jr.\nParty : 1, 2, 7, 4, 3\nFirst_Elected : 2002.0, 2006.0, 1994.0, 2003.0\nCommittee : Environmental Matters, Economic Matters, Ways and Means, Environmental Matters (Vice-Chair), Health and Government Operations, Appropriations\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"Album\" (\n\t\"AlbumId\" INTEGER NOT NULL, \n\t\"Title\" VARCHAR(160) NOT NULL, \n\t\"ArtistId\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"AlbumId\"), \n\tFOREIGN KEY(\"ArtistId\") REFERENCES \"Artist\" (\"ArtistId\")\n)\n/*\nColumns in Album and 3 examples in each column for high cardinality columns :\nAlbumId : 87, 56, 65\nTitle : The Number of The Beast, One By One, Dance Of Death\nArtistId : 87, 56, 95\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\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 \"Album\" (\n\t\"AlbumId\" INTEGER NOT NULL, \n\t\"Title\" VARCHAR(160) NOT NULL, \n\t\"ArtistId\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"AlbumId\"), \n\tFOREIGN KEY(\"ArtistId\") REFERENCES \"Artist\" (\"ArtistId\")\n)\n/*\nColumns in Album and 3 examples in each column for high cardinality columns :\nAlbumId : 87, 56, 65\nTitle : The Number of The Beast, One By One, Dance Of Death\nArtistId : 87, 56, 95\n*/\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Mailshot_Campaigns\" (\n\tmailshot_id INTEGER, \n\tproduct_category VARCHAR(15), \n\tmailshot_name VARCHAR(80), \n\tmailshot_start_date DATETIME, \n\tmailshot_end_date DATETIME, \n\tPRIMARY KEY (mailshot_id)\n)\n/*\nColumns in Mailshot_Campaigns and 3 examples in each column for high cardinality columns :\nmailshot_id : 17, 9, 16\nmailshot_start_date : 2017-05-20 20:05:09, 2018-02-04 13:13:36, 2017-09-27 02:35:45\nmailshot_end_date : 2018-03-15 01:06:16, 2018-03-13 14:42:26, 2018-03-01 13:42:09\n*/\n/*\nColumns in Mailshot_Campaigns and all categories for low cardinality columns :\nproduct_category : food, clothes\nmailshot_name : USPS, US, AL, FED\n*/\n \nCREATE TABLE project (\n\t\"Pname\" TEXT, \n\t\"Pnumber\" INTEGER, \n\t\"Plocation\" TEXT, \n\t\"Dnum\" INTEGER, \n\tPRIMARY KEY (\"Pnumber\")\n)\n/*\nColumns in project and all categories for low cardinality columns :\nPname : Newbenefits, Reorganization, ProductX, Computerization, ProductZ, ProductY\nPnumber : 1, 20, 2, 30, 3, 10\nPlocation : Stafford, Sugarland, Bellaire, Houston\nDnum : 1, 4, 5\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE \"First_Notification_of_Loss\" (\n\t\"FNOL_ID\" INTEGER NOT NULL, \n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Service_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"FNOL_ID\"), \n\tFOREIGN KEY(\"Service_ID\") REFERENCES \"Services\" (\"Service_ID\"), \n\tFOREIGN KEY(\"Customer_ID\", \"Policy_ID\") REFERENCES \"Customers_Policies\" (\"Customer_ID\", \"Policy_ID\"), \n\tUNIQUE (\"FNOL_ID\")\n)\n/*\nColumns in First_Notification_of_Loss and all categories for low cardinality columns :\nFNOL_ID : 1611, 4226, 2543, 4525, 1722, 4323, 532\nCustomer_ID : 582, 892, 826, 214, 996\nPolicy_ID : 586, 630, 257, 927, 366, 879, 993\nService_ID : 1, 9, 4, 6\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 device (\n\t\"Device_ID\" INTEGER, \n\t\"Device\" TEXT, \n\t\"Carrier\" TEXT, \n\t\"Package_Version\" TEXT, \n\t\"Applications\" TEXT, \n\t\"Software_Platform\" TEXT, \n\tPRIMARY KEY (\"Device_ID\")\n)\n/*\nColumns in device and all categories for low cardinality columns :\nDevice_ID : 1, 2, 5, 4, 6, 3\nDevice : Huawei, Galaxy, Apple, Xiaomi, BlackBerry Storm 9530, Samsung\nCarrier : MTS Mobility, Bell Mobility, Telus Mobility, Vodafone AU, Verizon Wireless, Iusacell\nPackage_Version : 4.7.0.208, 5.0.0.742, 5.0.0.808, 5.0.0.328, 5.0.0.419\nApplications : 4.7.0.151, 5.0.0.451, 5.0.0.328, 5.0.0.419\nSoftware_Platform : iOS, Android\n*/\n \nCREATE TABLE election (\n\t\"Election_ID\" INTEGER, \n\t\"Representative_ID\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Votes\" REAL, \n\t\"Vote_Percent\" REAL, \n\t\"Seats\" REAL, \n\t\"Place\" REAL, \n\tPRIMARY KEY (\"Election_ID\"), \n\tFOREIGN KEY(\"Representative_ID\") REFERENCES representative (\"Representative_ID\")\n)\n/*\nColumns in election and all categories for low cardinality columns :\nElection_ID : 1, 2, 5, 4, 3\nRepresentative_ID : 1, 2, 5, 7, 4\nDate : 1946, 1949, July 1942, October 1942, 1953\nVotes : 11059.0, 9423.0, 13049.0, 12422.0, 14077.0\nVote_Percent : 16.0, 19.5, 16.2, 18.5\nSeats : 10.0, 6.0, 7.0, 9.0\nPlace : 3.0, 1.0, 2.0\n*/\n" }, { "role": "user", "content": "What is the name of the customer who has the largest number of orders?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id 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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_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 gymnast (\n\t\"Gymnast_ID\" INTEGER, \n\t\"Floor_Exercise_Points\" REAL, \n\t\"Pommel_Horse_Points\" REAL, \n\t\"Rings_Points\" REAL, \n\t\"Vault_Points\" REAL, \n\t\"Parallel_Bars_Points\" REAL, \n\t\"Horizontal_Bar_Points\" REAL, \n\t\"Total_Points\" REAL, \n\tPRIMARY KEY (\"Gymnast_ID\"), \n\tFOREIGN KEY(\"Gymnast_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in gymnast and all categories for low cardinality columns :\nGymnast_ID : 1, 2, 7, 8, 4, 6, 10\nFloor_Exercise_Points : 9.762, 9.65, 9.412, 9.725, 9.7, 9.687, 8.987\nPommel_Horse_Points : 9.625, 9.325, 9.675, 9.525, 9.737, 9.75, 9.712\nRings_Points : 9.512, 9.625, 9.3, 9.712, 9.475, 9.75, 9.487\nVault_Points : 9.537, 9.762, 9.65, 9.637, 9.55, 9.575\nParallel_Bars_Points : 9.625, 9.787, 9.762, 9.562, 9.587, 9.725, 9.5\nHorizontal_Bar_Points : 9.55, 9.725, 9.412, 9.737, 9.5, 9.75\nTotal_Points : 57.398, 57.924, 57.649, 57.374, 57.436, 58.061, 57.424\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE appellations (\n\t\"No\" INTEGER, \n\t\"Appelation\" TEXT, \n\t\"County\" TEXT, \n\t\"State\" TEXT, \n\t\"Area\" TEXT, \n\t\"isAVA\" TEXT, \n\tPRIMARY KEY (\"No\"), \n\tUNIQUE (\"Appelation\")\n)\n/*\nColumns in appellations and 3 examples in each column for high cardinality columns :\nNo : 53, 56, 49\nAppelation : Anderson Valley, Fiddletown, Mendocino County\nCounty : Monterey, Solano, Santa Barbara\n*/\n/*\nColumns in appellations and all categories for low cardinality columns :\nState : California\nArea : Sierra Foothills, Central Valley, North Coast, Central Coast, N/A, California, Santa Cruz Mountains\nisAVA : Yes, No\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 performance (\n\t\"Performance_ID\" REAL, \n\t\"Date\" TEXT, \n\t\"Host\" TEXT, \n\t\"Location\" TEXT, \n\t\"Attendance\" INTEGER, \n\tPRIMARY KEY (\"Performance_ID\")\n)\n/*\nColumns in performance and all categories for low cardinality columns :\nPerformance_ID : 3.0, 1.0, 2.0, 6.0, 4.0, 5.0\nDate : February 7, February 4, February 2, February 5, February 10, February 11\nHost : Ottawa Senators, New York Rangers, Pittsburgh Penguins, Atlanta Thrashers, Montreal Canadiens, Boston Bruins\nLocation : Madison Square Garden, Scotiabank Place, Verizon Center, TD Garden, Bell Centre\nAttendance : 2173, 1878, 1877, 1820, 1982, 165\n*/\n \nCREATE TABLE happy_hour_member (\n\t\"HH_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Total_amount\" REAL, \n\tPRIMARY KEY (\"HH_ID\", \"Member_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in happy_hour_member and all categories for low cardinality columns :\nHH_ID : 1, 2, 5, 7, 8, 4\nMember_ID : 5, 9, 3\nTotal_amount : 4.9, 4.2, 20.9, 16.9, 16.92, 20.92\n*/\n \nCREATE TABLE nomination (\n\t\"Artwork_ID\" INTEGER, \n\t\"Festival_ID\" INTEGER, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (\"Artwork_ID\", \"Festival_ID\"), \n\tFOREIGN KEY(\"Festival_ID\") REFERENCES festival_detail (\"Festival_ID\"), \n\tFOREIGN KEY(\"Artwork_ID\") REFERENCES artwork (\"Artwork_ID\")\n)\n/*\nColumns in nomination and all categories for low cardinality columns :\nArtwork_ID : 1, 2, 8, 4, 3, 9\nFestival_ID : 1, 2, 5\nResult : Nominated, Won\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 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 technician (\n\ttechnician_id REAL, \n\t\"Name\" TEXT, \n\t\"Team\" TEXT, \n\t\"Starting_Year\" REAL, \n\t\"Age\" INTEGER, \n\tPRIMARY KEY (technician_id)\n)\n/*\nColumns in technician and all categories for low cardinality columns :\ntechnician_id : 3.0, 8.0, 10.0, 1.0, 7.0, 2.0, 6.0, 9.0, 4.0, 5.0\nName : Mark Sewell, John Brown, Mickey Cochrane, Joe Sewell, Tony Sewell, Joe Cochrane, Eddie Collins, Charlie Hollocher, Lou Boudreau\nTeam : CHC, NYY, CLE, PHA, CWS\nStarting_Year : 2013.0, 2016.0, 2003.0, 2006.0, 2005.0, 2002.0, 2009.0, 2012.0\nAge : 38, 37, 45, 46, 28, 36, 32, 47, 43, 35\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE train_station (\n\t\"Train_ID\" INTEGER, \n\t\"Station_ID\" INTEGER, \n\tPRIMARY KEY (\"Train_ID\", \"Station_ID\"), \n\tFOREIGN KEY(\"Train_ID\") REFERENCES train (\"Train_ID\"), \n\tFOREIGN KEY(\"Station_ID\") REFERENCES station (\"Station_ID\")\n)\n/*\nColumns in train_station and 3 examples in each column for high cardinality columns :\nTrain_ID : 1, 11, 2\n*/\n/*\nColumns in train_station and all categories for low cardinality columns :\nStation_ID : 1, 2, 5, 8, 3, 10, 9\n*/\n \nCREATE TABLE \"Available_Policies\" (\n\t\"Policy_ID\" INTEGER NOT NULL, \n\tpolicy_type_code CHAR(15), \n\t\"Customer_Phone\" VARCHAR(255), \n\tPRIMARY KEY (\"Policy_ID\"), \n\tUNIQUE (\"Policy_ID\")\n)\n/*\nColumns in Available_Policies and 3 examples in each column for high cardinality columns :\nPolicy_ID : 751, 300, 586\nCustomer_Phone : (777)537-7792, 991.642.6485x822, 1-797-927-3585x9321\n*/\n/*\nColumns in Available_Policies and all categories for low cardinality columns :\npolicy_type_code : Property Insurance, Mortgage Insurance, Life Insurance, Travel Insurance\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" }, { "role": "user", "content": "Find the name of the customer who made the most orders." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: customers, orders.\nFrom these tables, I'll be using the following columns: customers.customer_name, customers.customer_id, orders.customer_id.\nThe SQL query I'll be generating is:\nSELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id 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 city (\n\t\"City_ID\" INTEGER, \n\t\"County_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"White\" REAL, \n\t\"Black\" REAL, \n\t\"Amerindian\" REAL, \n\t\"Asian\" REAL, \n\t\"Multiracial\" REAL, \n\t\"Hispanic\" REAL, \n\tPRIMARY KEY (\"City_ID\"), \n\tFOREIGN KEY(\"County_ID\") REFERENCES county_public_safety (\"County_ID\")\n)\n/*\nColumns in city and 3 examples in each column for high cardinality columns :\nCity_ID : 1, 16, 13\nName : Aguadilla, Barranquitas, Bayamón\nWhite : 70.7, 78.3, 93.1\nBlack : 4.1, 22.8, 7.2\nMultiracial : 10.7, 12.1, 11.7\n*/\n/*\nColumns in city and all categories for low cardinality columns :\nCounty_ID : 1, 2, 5, 4, 6, 3\nAmerindian : 0.4, 0.6, 1.0, 0.3, 0.2, 0.9\nAsian : 0.1, 0.4, 0.3, 0.0, 0.2\nHispanic : 99.6, 98.5, 99.1, 99.5, 99.2, 99.4, 98.6, 98.9, 99.0, 99.3\n*/\n \nCREATE TABLE \"Investors\" (\n\tinvestor_id INTEGER, \n\t\"Investor_details\" VARCHAR(255), \n\tPRIMARY KEY (investor_id)\n)\n/*\nColumns in Investors and 3 examples in each column for high cardinality columns :\ninvestor_id : 17, 9, 16\nInvestor_details : d, t, b\n*/\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 player_coach (\n\t\"Player_ID\" INTEGER, \n\t\"Coach_ID\" INTEGER, \n\t\"Starting_year\" INTEGER, \n\tPRIMARY KEY (\"Player_ID\", \"Coach_ID\"), \n\tFOREIGN KEY(\"Coach_ID\") REFERENCES coach (\"Coach_ID\"), \n\tFOREIGN KEY(\"Player_ID\") REFERENCES player (\"Player_ID\")\n)\n/*\nColumns in player_coach and all categories for low cardinality columns :\nPlayer_ID : 1, 2, 4, 6, 14, 3, 10\nCoach_ID : 1, 2, 5, 3\nStarting_year : 2012, 2010, 2011, 2013\n*/\n \nCREATE TABLE \"Research_Outcomes\" (\n\toutcome_code VARCHAR(10), \n\toutcome_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (outcome_code)\n)\n/*\nColumns in Research_Outcomes and all categories for low cardinality columns :\noutcome_code : Patent, Paper\noutcome_description : Published Research Paper, Research Patent\n*/\n \nCREATE TABLE \"Club\" (\n\t\"ClubID\" INTEGER, \n\t\"ClubName\" VARCHAR(40), \n\t\"ClubDesc\" VARCHAR(1024), \n\t\"ClubLocation\" VARCHAR(40), \n\tPRIMARY KEY (\"ClubID\")\n)\n/*\nColumns in Club and all categories for low cardinality columns :\nClubID : 1, 2, 4, 3\nClubName : Bootup Baltimore, Pen and Paper Gaming, Tennis Club, Hopkins Student Enterprises\nClubDesc : Venture capital fund for student business., A competitive tennis club., Refurbish computers; teach kids and adults about computer basics., Play pen and paper games on campus.\nClubLocation : HHH, AKW\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Student_Tests_Taken\" (\n\tregistration_id INTEGER NOT NULL, \n\tdate_test_taken DATETIME NOT NULL, \n\ttest_result VARCHAR(255), \n\tFOREIGN KEY(registration_id) REFERENCES \"Student_Course_Enrolment\" (registration_id)\n)\n/*\nColumns in Student_Tests_Taken and 3 examples in each column for high cardinality columns :\ndate_test_taken : 2018-03-19 02:04:26, 2018-03-25 03:27:16, 2018-03-25 21:41:51\n*/\n/*\nColumns in Student_Tests_Taken and all categories for low cardinality columns :\nregistration_id : 16, 2, 5, 7, 17, 4, 12, 19, 10, 9\ntest_result : Fail, Pass\n*/\n \nCREATE TABLE artist (\n\t\"Artist_ID\" INTEGER, \n\t\"Artist\" TEXT, \n\t\"Age\" INTEGER, \n\t\"Famous_Title\" TEXT, \n\t\"Famous_Release_date\" TEXT, \n\tPRIMARY KEY (\"Artist_ID\")\n)\n/*\nColumns in artist and all categories for low cardinality columns :\nArtist_ID : 1, 2, 5, 7, 4, 6, 3\nArtist : Gorgoroth, Tangorodrim, Triumfall, Black Flame, Ophiolatry\nAge : 49, 34, 18, 27, 22, 35\nFamous_Title : Unholy Metal Way (re-release), Antievangelistical Process (re-release), Imperivm, Those Who Unleashed (re-release), Antithesis of All Flesh, Bergen 1996, Transmutation\nFamous_Release_date : November 2007, 2009, June 15, 2009, January 21, 2008, June 23, 2008\n*/\n \nCREATE TABLE \"Club\" (\n\t\"ClubID\" INTEGER, \n\t\"ClubName\" VARCHAR(40), \n\t\"ClubDesc\" VARCHAR(1024), \n\t\"ClubLocation\" VARCHAR(40), \n\tPRIMARY KEY (\"ClubID\")\n)\n/*\nColumns in Club and all categories for low cardinality columns :\nClubID : 1, 2, 4, 3\nClubName : Bootup Baltimore, Pen and Paper Gaming, Tennis Club, Hopkins Student Enterprises\nClubDesc : Venture capital fund for student business., A competitive tennis club., Refurbish computers; teach kids and adults about computer basics., Play pen and paper games on campus.\nClubLocation : HHH, AKW\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE coach (\n\t\"Coach_ID\" INTEGER, \n\t\"Coach_name\" TEXT, \n\t\"Gender\" TEXT, \n\t\"Club_ID\" INTEGER, \n\t\"Rank\" INTEGER, \n\tPRIMARY KEY (\"Coach_ID\"), \n\tFOREIGN KEY(\"Club_ID\") REFERENCES club (\"Club_ID\")\n)\n/*\nColumns in coach and all categories for low cardinality columns :\nCoach_ID : 1, 2, 5, 4, 3\nCoach_name : Robert Chen, James Wong, Smith Brown, Jameson Tomas, Joe Fabbri\nGender : F, M\nClub_ID : 1, 3\nRank : 1, 2, 5, 4, 3\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Staff_Roles\" (\n\trole_code VARCHAR(10), \n\trole_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (role_code)\n)\n/*\nColumns in Staff_Roles and all categories for low cardinality columns :\nrole_code : researcher, leader\nrole_description : Project Researcher, Project Leader\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 film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\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 book_club (\n\tbook_club_id INTEGER, \n\t\"Year\" INTEGER, \n\t\"Author_or_Editor\" TEXT, \n\t\"Book_Title\" TEXT, \n\t\"Publisher\" TEXT, \n\t\"Category\" TEXT, \n\t\"Result\" TEXT, \n\tPRIMARY KEY (book_club_id)\n)\n/*\nColumns in book_club and 3 examples in each column for high cardinality columns :\nbook_club_id : 1, 11, 2\nAuthor_or_Editor : Dolores Klaich, Antoinette Azolakov, Sandy Bayer\nBook_Title : Lessons In Murder, Somewhere in the Night, Mundaneӳ World\n*/\n/*\nColumns in book_club and all categories for low cardinality columns :\nYear : 1989, 1990\nPublisher : International Polygonics, William Morrow, St. Martin's Press, Crossing Press, Alyson, Naiad Press, Banned Books, Mysterious Press\nCategory : Lesb. M/SF, Gay SF/F, Gay M/SF\nResult : Nom, Won [B ], Won, Won [A ]\n*/\n" }, { "role": "user", "content": "Find the invoice numbers which are created before 1989-09-03 or after 2007-12-25." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: invoices.\nFrom these tables, I'll be using the following columns: invoice_number, invoice_date, 1989-09-03, 2007-12-25.\nThe SQL query I'll be generating is:\nSELECT invoice_number FROM invoices WHERE invoice_date < \"1989-09-03\" OR invoice_date > \"2007-12-25\"" } ]
[ { "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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_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 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 \nCREATE TABLE actor (\n\t\"Actor_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Musical_ID\" INTEGER, \n\t\"Character\" TEXT, \n\t\"Duration\" TEXT, \n\tage INTEGER, \n\tPRIMARY KEY (\"Actor_ID\"), \n\tFOREIGN KEY(\"Musical_ID\") REFERENCES actor (\"Actor_ID\")\n)\n/*\nColumns in actor and all categories for low cardinality columns :\nActor_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nName : Ray Meagher, Lynne McGranger, Ian Smith, Tom Oliver, Kate Ritchie, Ryan Moloney, Alan Fletcher, Stefan Dennis, Jackie Woodburne\nMusical_ID : 1, 2, 4, 6\nCharacter : Harold Bishop, Susan Kennedy, Karl Kennedy, Alf Stewart, Toadfish Rebecchi, Sally Fletcher, Paul Robinson, Lou Carpenter, Irene Roberts\nDuration : 1988—, 1985–1992, 1993, 2004—, 1993—, 1988, 1992—, 1995, 1996—, 1987–1991, 1996–2009, 2011, 1994—, 1988–2008, 2013\nage : 26, 20, 17, 21, 18, 22\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE architect (\n\tid TEXT, \n\tname TEXT, \n\tnationality TEXT, \n\tgender TEXT, \n\tPRIMARY KEY (id)\n)\n/*\nColumns in architect and all categories for low cardinality columns :\nid : 1, 2, 5, 4, 3\nname : Frank Lloyd Wright, Frank Gehry, Mies Van Der Rohe, Le Corbusier, Zaha Hadid\nnationality : American, Swiss, French, German, American, Canadian, Iraqi, British\ngender : female, male\n*/\n \nCREATE TABLE company (\n\t\"Company_ID\" REAL, \n\t\"Name\" TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Industry\" TEXT, \n\t\"Sales_in_Billion\" REAL, \n\t\"Profits_in_Billion\" REAL, \n\t\"Assets_in_Billion\" REAL, \n\t\"Market_Value_in_Billion\" REAL, \n\tPRIMARY KEY (\"Company_ID\")\n)\n/*\nColumns in company and 3 examples in each column for high cardinality columns :\nCompany_ID : 3.0, 8.0, 11.0\nName : PetroChina, Berkshire Hathaway, Petrobras\nSales_in_Billion : 82.6, 110.8, 143.7\nProfits_in_Billion : 15.7, 20.1, 25.1\nAssets_in_Billion : 213.0, 331.1, 1313.9\nMarket_Value_in_Billion : 237.4, 213.7, 164.3\n*/\n/*\nColumns in company and all categories for low cardinality columns :\nHeadquarters : UK, China, Brazil, France, Russia, USA, Germany, Netherlands\nIndustry : Retailing, Automotive, Conglomerate, Oil and gas, Banking\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_type_code VARCHAR(15), \n\tproduct_name VARCHAR(80), \n\tproduct_price DOUBLE, \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\nproduct_price : 5927021.8748021, 622.79275984494, 22956668.699482\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_type_code : Hardware, Clothes\nproduct_name : Apple, jcrew, Sony, gucci\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 body_builder (\n\t\"Body_Builder_ID\" INTEGER, \n\t\"People_ID\" INTEGER, \n\t\"Snatch\" REAL, \n\t\"Clean_Jerk\" REAL, \n\t\"Total\" REAL, \n\tPRIMARY KEY (\"Body_Builder_ID\"), \n\tFOREIGN KEY(\"People_ID\") REFERENCES people (\"People_ID\")\n)\n/*\nColumns in body_builder and all categories for low cardinality columns :\nBody_Builder_ID : 1, 2, 5, 4, 3\nPeople_ID : 1, 2, 5, 6, 3\nSnatch : 142.5, 137.5, 130.0, 140.0\nClean_Jerk : 162.5, 177.5, 175.0\nTotal : 315.0, 317.5, 312.5, 292.5\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE roller_coaster (\n\t\"Roller_Coaster_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Park\" TEXT, \n\t\"Country_ID\" INTEGER, \n\t\"Length\" REAL, \n\t\"Height\" REAL, \n\t\"Speed\" TEXT, \n\t\"Opened\" TEXT, \n\t\"Status\" TEXT, \n\tPRIMARY KEY (\"Roller_Coaster_ID\"), \n\tFOREIGN KEY(\"Country_ID\") REFERENCES country (\"Country_ID\")\n)\n/*\nColumns in roller_coaster and all categories for low cardinality columns :\nRoller_Coaster_ID : 1, 2, 5, 4, 6, 3\nName : The Voyage, Twister, Boardwalk Bullet, Hades 360, Dauling Dragon, Ravine Flyer II\nPark : Waldameer, Happy Valley, Mt. Olympus, Gröna Lund, Kemah Boardwalk, Holiday World\nCountry_ID : 1, 2, 3\nLength : 6442.0, 4726.0, 3236.0, 1574.0, 2900.0, 3914.0\nHeight : 96.0, 105.0, 136.0, 50.0, 120.0, 163.0\nSpeed : 67, 55, 37.9, 70, 57, 51\nOpened : May 14, 2005, 2012, August 31, 2007, 2011, May 6, 2006, May 17, 2008\nStatus : Operating\n*/\n \nCREATE TABLE works_on (\n\t\"Essn\" INTEGER, \n\t\"Pno\" INTEGER, \n\t\"Hours\" REAL, \n\tPRIMARY KEY (\"Essn\", \"Pno\")\n)\n/*\nColumns in works_on and all categories for low cardinality columns :\nEssn : 987987987, 333445555, 453453453, 666884444, 123456789, 987654321, 888665555, 999887777\nPno : 1, 20, 2, 30, 3, 10\nHours : 30.0, 15.0, 32.5, 10.0, 7.5, 40.0, 35.0, None, 20.0, 5.0\n*/\n \nCREATE TABLE film_market_estimation (\n\t\"Estimation_ID\" INTEGER, \n\t\"Low_Estimate\" REAL, \n\t\"High_Estimate\" REAL, \n\t\"Film_ID\" INTEGER, \n\t\"Type\" TEXT, \n\t\"Market_ID\" INTEGER, \n\t\"Year\" INTEGER, \n\tPRIMARY KEY (\"Estimation_ID\"), \n\tFOREIGN KEY(\"Film_ID\") REFERENCES film (\"Film_ID\"), \n\tFOREIGN KEY(\"Market_ID\") REFERENCES market (\"Market_ID\")\n)\n/*\nColumns in film_market_estimation and all categories for low cardinality columns :\nEstimation_ID : 1, 2, 5, 7, 8, 4, 6, 3, 9\nLow_Estimate : 80000.0, 39.0, 16.0, 3000.0, 300.0, 53.0, 960.0, 913.0, 8000.0\nHigh_Estimate : 39.0, 16.0, 1000.0, 53.0, 960.0, 913.0, 8000.0, 80400.0\nFilm_ID : 1, 2, 4, 3\nType : Mass human sacrifice, Mass suicide murder, Mass suicide\nMarket_ID : 1, 2, 3\nYear : 1978, 1945, 1973, 1994, 1995, 2000, 1997, 1487, 1944\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 happy_hour_member (\n\t\"HH_ID\" INTEGER, \n\t\"Member_ID\" INTEGER, \n\t\"Total_amount\" REAL, \n\tPRIMARY KEY (\"HH_ID\", \"Member_ID\"), \n\tFOREIGN KEY(\"Member_ID\") REFERENCES member (\"Member_ID\")\n)\n/*\nColumns in happy_hour_member and all categories for low cardinality columns :\nHH_ID : 1, 2, 5, 7, 8, 4\nMember_ID : 5, 9, 3\nTotal_amount : 4.9, 4.2, 20.9, 16.9, 16.92, 20.92\n*/\n \nCREATE TABLE \"Discount_Coupons\" (\n\tcoupon_id INTEGER, \n\tdate_issued DATETIME, \n\tcoupon_amount DECIMAL(19, 4), \n\tPRIMARY KEY (coupon_id)\n)\n/*\nColumns in Discount_Coupons and 3 examples in each column for high cardinality columns :\ncoupon_id : 1, 13, 11\ndate_issued : 2018-02-24 01:40:52, 2017-09-06 01:33:27, 2018-02-10 21:18:23\ncoupon_amount : 245.3600, 501.3000, 508.4400\n*/\n\n" }, { "role": "user", "content": "What are the invoice numbers created before 1989-09-03 or after 2007-12-25?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: invoices.\nFrom these tables, I'll be using the following columns: invoice_number, invoice_date, 1989-09-03, 2007-12-25.\nThe SQL query I'll be generating is:\nSELECT invoice_number FROM invoices WHERE invoice_date < \"1989-09-03\" OR invoice_date > \"2007-12-25\"" } ]
[ { "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 \"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 film (\n\t\"Film_ID\" INTEGER, \n\t\"Title\" TEXT, \n\t\"Studio\" TEXT, \n\t\"Director\" TEXT, \n\t\"Gross_in_dollar\" INTEGER, \n\tPRIMARY KEY (\"Film_ID\")\n)\n/*\nColumns in film and 3 examples in each column for high cardinality columns :\nFilm_ID : 1, 13, 11\nTitle : Annie, Rocky III, Tootsie\nDirector : Richard Attenborough, Nicholas Meyer, Ted Kotcheff\nGross_in_dollar : 53977250, 76606280, 125049125\n*/\n/*\nColumns in film and all categories for low cardinality columns :\nStudio : MGM, United Artists, Universal, 20th Century Fox, Columbia, Paramount, Columbia / Rastar, Paramount / Lorimar, Orion / Carolco, Universal / RKO\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 \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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\tdept_name VARCHAR(20), \n\tbuilding VARCHAR(15), \n\tbudget NUMERIC(12, 2), \n\tPRIMARY KEY (dept_name), \n\tCHECK (budget > 0)\n)\n/*\nColumns in department and 3 examples in each column for high cardinality columns :\ndept_name : Math, Athletics, English\nbuilding : Brodhead, Saucon, Wrigley\nbudget : 734550.70, 255041.46, 601283.60\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Services\" (\n\t\"Service_ID\" INTEGER NOT NULL, \n\t\"Service_Type_Code\" CHAR(15) NOT NULL, \n\tPRIMARY KEY (\"Service_ID\")\n)\n/*\nColumns in Services and all categories for low cardinality columns :\nService_ID : 8, 2, 5, 6\nService_Type_Code : Marriage, Birth Proof, Death Proof, Property Change\n*/\n \nCREATE TABLE \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 \"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 \"SAVINGS\" (\n\tcustid BIGINT NOT NULL, \n\tbalance FLOAT NOT NULL, \n\tPRIMARY KEY (custid), \n\tFOREIGN KEY(custid) REFERENCES \"ACCOUNTS\" (custid)\n)\n/*\nColumns in SAVINGS and all categories for low cardinality columns :\ncustid : 1, 2, 5, 4, 6, 3\nbalance : 80000.0, 230000.0, 999999999.0, 60.0, 240.0, 200000.0\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 \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE county_public_safety (\n\t\"County_ID\" INTEGER, \n\t\"Name\" TEXT, \n\t\"Population\" INTEGER, \n\t\"Police_officers\" INTEGER, \n\t\"Residents_per_officer\" INTEGER, \n\t\"Case_burden\" INTEGER, \n\t\"Crime_rate\" REAL, \n\t\"Police_force\" TEXT, \n\t\"Location\" TEXT, \n\tPRIMARY KEY (\"County_ID\")\n)\n/*\nColumns in county_public_safety and all categories for low cardinality columns :\nCounty_ID : 1, 2, 5, 4, 6, 3\nName : Central Saanich, Campbell River, Chilliwack, Castlegar, Burnaby, Abbotsford\nPopulation : 16821, 204320, 128165, 73066, 7821, 30810\nPolice_officers : 91, 11, 187, 253, 40, 21\nResidents_per_officer : 711, 770, 801, 808, 803, 685\nCase_burden : 100, 137, 140, 39, 107, 81\nCrime_rate : 178.0, 150.0, 49.0, 118.0, 174.0, 123.0\nPolice_force : Abbotsford Police Department, Central Saanich Police, RCMP\nLocation : West, East, North\n*/\n \nCREATE TABLE company (\n\t\"Company_ID\" INTEGER, \n\t\"Rank\" INTEGER, \n\t\"Company\" TEXT, \n\t\"Headquarters\" TEXT, \n\t\"Main_Industry\" TEXT, \n\t\"Sales_billion\" REAL, \n\t\"Profits_billion\" REAL, \n\t\"Assets_billion\" REAL, \n\t\"Market_Value\" REAL, \n\tPRIMARY KEY (\"Company_ID\")\n)\n/*\nColumns in company and all categories for low cardinality columns :\nCompany_ID : 1, 2, 5, 7, 8, 4, 6, 3, 10, 9\nRank : 1, 11, 5, 7, 8, 4, 6, 3, 10, 9\nCompany : ExxonMobil, HSBC, General Electric, PetroChina, Industrial and Commercial Bank of China, Wells Fargo, Berkshire Hathaway, Petrobras, Royal Dutch Shell, BP\nHeadquarters : UK, China, Brazil, USA, Netherlands\nMain_Industry : Conglomerate, Banking, Oil and gas\nSales_billion : 143.7, 310.1, 433.5, 147.3, 470.2, 145.9, 87.6, 82.6, 375.5, 102.0\nProfits_billion : 20.1, 41.1, 30.9, 25.1, 14.2, 25.7, 20.6, 16.2, 15.9, 10.3\nAssets_billion : 1313.9, 319.4, 717.2, 340.5, 331.1, 2039.1, 292.5, 304.7, 392.6, 2550.0\nMarket_Value : 237.4, 213.7, 227.6, 147.4, 164.3, 202.2, 294.7, 180.0, 407.4, 178.7\n*/\n \nCREATE TABLE \"match\" (\n\t\"Round\" REAL, \n\t\"Location\" TEXT, \n\t\"Country\" TEXT, \n\t\"Date\" TEXT, \n\t\"Fastest_Qualifying\" TEXT, \n\t\"Winning_Pilot\" TEXT, \n\t\"Winning_Aircraft\" TEXT, \n\tPRIMARY KEY (\"Round\"), \n\tFOREIGN KEY(\"Winning_Pilot\") REFERENCES pilot (\"Pilot_Id\"), \n\tFOREIGN KEY(\"Winning_Aircraft\") REFERENCES aircraft (\"Aircraft_ID\")\n)\n/*\nColumns in match and all categories for low cardinality columns :\nRound : 3.0, 1.0, 7.0, 2.0, 6.0, 4.0, 5.0\nLocation : EuroSpeedway Lausitz, Flamengo Beach , Rio de Janeiro, River Danube , Budapest, Swan River , Perth, Mina' Zayid , Abu Dhabi, New York City, Windsor , Ontario\nCountry : Canada, United States, Australia, Brazil, Germany, United Arab Emirates, Hungary\nDate : June 5–6, June 19–20, August 7–8, May 8–9, March 26–27, April 17–18, Cancelled\nFastest_Qualifying : Hannes Arch, Paul Bonhomme, Cancelled, Nigel Lamb\nWinning_Pilot : 1, 2, 4, 6, 9\nWinning_Aircraft : 1, 2, 5, 4, 3\n*/\n \nCREATE TABLE \"Customer_Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status_code VARCHAR(10) NOT NULL, \n\torder_date DATETIME NOT NULL, \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Customer_Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\norder_date : 2018-03-16 22:42:46, 2018-01-31 17:49:18, 2018-02-16 19:42:39\n*/\n/*\nColumns in Customer_Orders and all categories for low cardinality columns :\ncustomer_id : 1, 13, 11, 10, 7, 8, 4, 6, 12, 15\norder_status_code : Pending, Completed, PartFilled, Cancelled, New\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 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" }, { "role": "user", "content": "Find the distinct details of invoices which are created before 1989-09-03 or after 2007-12-25." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: invoices.\nFrom these tables, I'll be using the following columns: invoice_details, invoice_date, 1989-09-03, 2007-12-25.\nThe SQL query I'll be generating is:\nSELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < \"1989-09-03\" OR invoice_date > \"2007-12-25\"" } ]
[ { "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 \"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 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 \"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 \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE shop (\n\t\"Shop_ID\" INTEGER, \n\t\"Shop_Name\" TEXT, \n\t\"Location\" TEXT, \n\t\"Open_Date\" TEXT, \n\t\"Open_Year\" INTEGER, \n\tPRIMARY KEY (\"Shop_ID\")\n)\n/*\nColumns in shop and 3 examples in each column for high cardinality columns :\nShop_ID : 1, 11, 2\nShop_Name : Pentre store, Best Buy, Apple\nOpen_Date : 24 February, 18 February, 1 January\n*/\n/*\nColumns in shop and all categories for low cardinality columns :\nLocation : Maerdy, Porth, Blaenllechau, Pentre, Penygraig, Gelli, Dinas, Wattstown, Cymmer\nOpen_Year : 2009, 2013, 2015, 2017, 2006, 2011, 2014, 2010, 2007\n*/\n \nCREATE TABLE \"Organisation_Types\" (\n\torganisation_type VARCHAR(10), \n\torganisation_type_description VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (organisation_type)\n)\n/*\nColumns in Organisation_Types and all categories for low cardinality columns :\norganisation_type : RES, SPON\norganisation_type_description : Sponsor, Research\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 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 \"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 \"Transactions\" (\n\ttransaction_id INTEGER, \n\tinvestor_id INTEGER NOT NULL, \n\ttransaction_type_code VARCHAR(10) NOT NULL, \n\tdate_of_transaction DATETIME, \n\tamount_of_transaction DECIMAL(19, 4), \n\tshare_count VARCHAR(40), \n\tother_details VARCHAR(255), \n\tPRIMARY KEY (transaction_id), \n\tFOREIGN KEY(transaction_type_code) REFERENCES \"Ref_Transaction_Types\" (transaction_type_code), \n\tFOREIGN KEY(investor_id) REFERENCES \"Investors\" (investor_id)\n)\n/*\nColumns in Transactions and 3 examples in each column for high cardinality columns :\ntransaction_id : 1, 13, 11\ndate_of_transaction : 1990-12-02 09:03:38, 2001-11-28 15:06:25, 2002-09-13 03:04:56\namount_of_transaction : 207484122.2796, 27.2570, 822.8030\nshare_count : , 8718572, 930\n*/\n/*\nColumns in Transactions and all categories for low cardinality columns :\ninvestor_id : 3, 20, 2, 7, 8, 17, 6, 14, 19, 18\ntransaction_type_code : PUR, SALE\nother_details : None\n*/\n \nCREATE TABLE \"Ref_Incident_Type\" (\n\tincident_type_code VARCHAR(10), \n\tincident_type_description VARCHAR(80), \n\tPRIMARY KEY (incident_type_code)\n)\n/*\nColumns in Ref_Incident_Type and all categories for low cardinality columns :\nincident_type_code : VIOLENCE, DISTURB, NOISE\nincident_type_description : Noise, Violence, Disturbance\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Services\" (\n\tservice_id INTEGER, \n\tservice_type_code VARCHAR(15) NOT NULL, \n\tservice_name VARCHAR(80), \n\tservice_descriptio VARCHAR(255), \n\tPRIMARY KEY (service_id)\n)\n/*\nColumns in Services and 3 examples in each column for high cardinality columns :\nservice_id : 1, 13, 11\n*/\n/*\nColumns in Services and all categories for low cardinality columns :\nservice_type_code : Welfare, Health, Education\nservice_name : Welfare, Health, Education\nservice_descriptio : Welfare, Health, Education\n*/\n \nCREATE TABLE \"Lessons\" (\n\tlesson_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\tlesson_status_code VARCHAR(15) NOT NULL, \n\tstaff_id INTEGER, \n\tvehicle_id INTEGER NOT NULL, \n\tlesson_date DATETIME, \n\tlesson_time VARCHAR(10), \n\tprice DOUBLE, \n\tPRIMARY KEY (lesson_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id), \n\tFOREIGN KEY(staff_id) REFERENCES \"Staff\" (staff_id), \n\tFOREIGN KEY(vehicle_id) REFERENCES \"Vehicles\" (vehicle_id)\n)\n/*\nColumns in Lessons and 3 examples in each column for high cardinality columns :\nlesson_id : 1, 13, 11\nlesson_date : 2018-03-03 15:10:16, 2018-03-07 16:12:36, 2018-03-08 16:05:05\nprice : 306.0, 492.0, 446.0\n*/\n/*\nColumns in Lessons and all categories for low cardinality columns :\ncustomer_id : 13, 11, 2, 5, 8, 6, 3, 10, 9\nlesson_status_code : Completed, Cancelled\nstaff_id : 1, 11, 5, 8, 4, 14, 3, 12, 15\nvehicle_id : 1, 2, 3\nlesson_time : 2, 5, 4, 6, 3, 9\n*/\n \nCREATE TABLE city (\n\t\"City_ID\" INTEGER, \n\t\"Official_Name\" TEXT, \n\t\"Status\" TEXT, \n\t\"Area_km_2\" REAL, \n\t\"Population\" REAL, \n\t\"Census_Ranking\" TEXT, \n\tPRIMARY KEY (\"City_ID\")\n)\n/*\nColumns in city and all categories for low cardinality columns :\nCity_ID : 1, 2, 5, 4, 3\nOfficial_Name : Plaster Rock, Aroostook, Perth-Andover, Drummond, Grand Falls/Grand-Sault\nStatus : Village, Town\nArea_km_2 : 8.91, 18.06, 8.89, 2.24, 3.09\nPopulation : 351.0, 1135.0, 775.0, 1778.0, 5706.0\nCensus_Ranking : 3460 of 5008, 1936 of 5,008, 2418 of 5008, 636 of 5008, 1442 of 5,008\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 airport_aircraft (\n\t\"ID\" INTEGER, \n\t\"Airport_ID\" INTEGER, \n\t\"Aircraft_ID\" INTEGER, \n\tPRIMARY KEY (\"Airport_ID\", \"Aircraft_ID\"), \n\tFOREIGN KEY(\"Aircraft_ID\") REFERENCES aircraft (\"Aircraft_ID\"), \n\tFOREIGN KEY(\"Airport_ID\") REFERENCES airport (\"Airport_ID\")\n)\n/*\nColumns in airport_aircraft and all categories for low cardinality columns :\nID : 1, 2, 4, 3\nAirport_ID : 1, 9, 2, 6\nAircraft_ID : 1, 2, 5, 3\n*/\n" }, { "role": "user", "content": "What are the distinct details of invoices created before 1989-09-03 or after 2007-12-25?" }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: invoices.\nFrom these tables, I'll be using the following columns: invoice_details, invoice_date, 1989-09-03, 2007-12-25.\nThe SQL query I'll be generating is:\nSELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < \"1989-09-03\" OR invoice_date > \"2007-12-25\"" } ]
[ { "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 \"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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\n\n \nCREATE TABLE \"Order_Items\" (\n\torder_item_id INTEGER, \n\tproduct_id INTEGER NOT NULL, \n\torder_id INTEGER NOT NULL, \n\torder_item_status VARCHAR(10) NOT NULL, \n\torder_item_details VARCHAR(255), \n\tPRIMARY KEY (order_item_id), \n\tFOREIGN KEY(product_id) REFERENCES \"Products\" (product_id), \n\tFOREIGN KEY(order_id) REFERENCES \"Orders\" (order_id)\n)\n/*\nColumns in Order_Items and 3 examples in each column for high cardinality columns :\norder_item_id : 1, 13, 11\n*/\n/*\nColumns in Order_Items and all categories for low cardinality columns :\nproduct_id : 1, 3, 11, 7, 8, 4, 12, 14, 15\norder_id : 11, 5, 15, 7, 8, 6, 14, 10, 9\norder_item_status : Finish, Cancel, Payed\norder_item_details : None\n*/\n \nCREATE TABLE \"Services\" (\n\t\"Service_ID\" INTEGER NOT NULL, \n\t\"Service_Type_Code\" CHAR(15) NOT NULL, \n\tPRIMARY KEY (\"Service_ID\")\n)\n/*\nColumns in Services and all categories for low cardinality columns :\nService_ID : 8, 2, 5, 6\nService_Type_Code : Marriage, Birth Proof, Death Proof, Property Change\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\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 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 dependent (\n\t\"Essn\" INTEGER, \n\t\"Dependent_name\" TEXT, \n\t\"Sex\" TEXT, \n\t\"Bdate\" TEXT, \n\t\"Relationship\" TEXT, \n\tPRIMARY KEY (\"Essn\", \"Dependent_name\")\n)\n/*\nColumns in dependent and all categories for low cardinality columns :\nEssn : 333445555, 123456789, 987654321\nDependent_name : Alice, Michael, Theodore, Abner, Joy, Elizabeth\nSex : F, M\nBdate : 1986-04-05, 1988-01-04, 1967-05-05, 1983-10-25, 1958-05-03, 1942-02-28, 1988-12-30\nRelationship : Daughter, Son, Spouse\n*/\n \nCREATE TABLE \"Products\" (\n\tproduct_id INTEGER, \n\tproduct_name VARCHAR(80), \n\tproduct_details VARCHAR(255), \n\tPRIMARY KEY (product_id)\n)\n/*\nColumns in Products and 3 examples in each column for high cardinality columns :\nproduct_id : 1, 13, 11\n*/\n/*\nColumns in Products and all categories for low cardinality columns :\nproduct_name : music, food, clothes, book, phone\nproduct_details : None\n*/\n \nCREATE TABLE \"COURSE\" (\n\t\"CRS_CODE\" VARCHAR(10), \n\t\"DEPT_CODE\" VARCHAR(10), \n\t\"CRS_DESCRIPTION\" VARCHAR(35), \n\t\"CRS_CREDIT\" FLOAT, \n\tPRIMARY KEY (\"CRS_CODE\"), \n\tFOREIGN KEY(\"DEPT_CODE\") REFERENCES \"DEPARTMENT\" (\"DEPT_CODE\")\n)\n/*\nColumns in COURSE and all categories for low cardinality columns :\nCRS_CODE : ACCT-212, QM-362, QM-261, CIS-420, CIS-220, ACCT-211\nDEPT_CODE : CIS, ACCT\nCRS_DESCRIPTION : Statistical Applications, Accounting I, Accounting II, Database Design and Implementation, Intro. to Microcomputing, Intro. to Statistics\nCRS_CREDIT : 3.0, 4.0\n*/\n \nCREATE TABLE \"First_Notification_of_Loss\" (\n\t\"FNOL_ID\" INTEGER NOT NULL, \n\t\"Customer_ID\" INTEGER NOT NULL, \n\t\"Policy_ID\" INTEGER NOT NULL, \n\t\"Service_ID\" INTEGER NOT NULL, \n\tPRIMARY KEY (\"FNOL_ID\"), \n\tFOREIGN KEY(\"Service_ID\") REFERENCES \"Services\" (\"Service_ID\"), \n\tFOREIGN KEY(\"Customer_ID\", \"Policy_ID\") REFERENCES \"Customers_Policies\" (\"Customer_ID\", \"Policy_ID\"), \n\tUNIQUE (\"FNOL_ID\")\n)\n/*\nColumns in First_Notification_of_Loss and all categories for low cardinality columns :\nFNOL_ID : 1611, 4226, 2543, 4525, 1722, 4323, 532\nCustomer_ID : 582, 892, 826, 214, 996\nPolicy_ID : 586, 630, 257, 927, 366, 879, 993\nService_ID : 1, 9, 4, 6\n*/\n \nCREATE TABLE \"Orders\" (\n\torder_id INTEGER, \n\tcustomer_id INTEGER NOT NULL, \n\torder_status VARCHAR(10) NOT NULL, \n\tdate_order_placed DATETIME NOT NULL, \n\torder_details VARCHAR(255), \n\tPRIMARY KEY (order_id), \n\tFOREIGN KEY(customer_id) REFERENCES \"Customers\" (customer_id)\n)\n/*\nColumns in Orders and 3 examples in each column for high cardinality columns :\norder_id : 1, 13, 11\ndate_order_placed : 1974-06-24 22:10:26, 2002-09-13 07:38:09, 1982-12-09 09:42:23\n*/\n/*\nColumns in Orders and all categories for low cardinality columns :\ncustomer_id : 11, 10, 2, 5, 7, 8, 4, 3, 15, 9\norder_status : On Road, Packing, Shipped\norder_details : None\n*/\n \nCREATE TABLE game (\n\tstadium_id INTEGER, \n\tid INTEGER, \n\t\"Season\" INTEGER, \n\t\"Date\" TEXT, \n\t\"Home_team\" TEXT, \n\t\"Away_team\" TEXT, \n\t\"Score\" TEXT, \n\t\"Competition\" TEXT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(stadium_id) REFERENCES stadium (id)\n)\n/*\nColumns in game and 3 examples in each column for high cardinality columns :\nstadium_id : 1, 11, 2\nid : 17, 9, 16\nDate : 30 June 2013, 18 May 2007, 8 August 2009\nScore : 0–0 (7:6), –, 1–3\n*/\n/*\nColumns in game and all categories for low cardinality columns :\nSeason : 2009, 2013, 2008, 2012, 2011, 2010, 2007\nHome_team : Pakhtakor, Bunyodkor, Quruvchi\nAway_team : Pakhtakor, Bunyodkor, Quruvchi\nCompetition : League, Supercup, Cup\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 employees (\n\t\"EMPLOYEE_ID\" DECIMAL(6, 0) DEFAULT '0' NOT NULL, \n\t\"FIRST_NAME\" VARCHAR(20) DEFAULT NULL, \n\t\"LAST_NAME\" VARCHAR(25) NOT NULL, \n\t\"EMAIL\" VARCHAR(25) NOT NULL, \n\t\"PHONE_NUMBER\" VARCHAR(20) DEFAULT NULL, \n\t\"HIRE_DATE\" DATE NOT NULL, \n\t\"JOB_ID\" VARCHAR(10) NOT NULL, \n\t\"SALARY\" DECIMAL(8, 2) DEFAULT NULL, \n\t\"COMMISSION_PCT\" DECIMAL(2, 2) DEFAULT NULL, \n\t\"MANAGER_ID\" DECIMAL(6, 0) DEFAULT NULL, \n\t\"DEPARTMENT_ID\" DECIMAL(4, 0) DEFAULT NULL, \n\tPRIMARY KEY (\"EMPLOYEE_ID\"), \n\tFOREIGN KEY(\"DEPARTMENT_ID\") REFERENCES departments (\"DEPARTMENT_ID\"), \n\tFOREIGN KEY(\"JOB_ID\") REFERENCES jobs (\"JOB_ID\")\n)\n/*\nColumns in employees and 3 examples in each column for high cardinality columns :\nEMPLOYEE_ID : 135, 187, 194\nFIRST_NAME : Randall, Adam, Susan\nLAST_NAME : Mourgos, Baida, Ande\nEMAIL : SSTILES, SMAVRIS, GHIMURO\nPHONE_NUMBER : 515.123.8080, 515.127.4563, 011.44.1346.629268\nHIRE_DATE : 1987-07-25, 1987-07-09, 1987-06-29\nJOB_ID : HR_REP, ST_MAN, AD_PRES\nSALARY : 2500.00, 8000.00, 8600.00\nMANAGER_ID : 102, 147, 122\nDEPARTMENT_ID : 110, 100, 20\n*/\n/*\nColumns in employees and all categories for low cardinality columns :\nCOMMISSION_PCT : 0.00, 0.35, 0.25, 0.10, 0.15, 0.20, 0.30, 0.40\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 \"Customers\" (\n\tcustomer_id INTEGER, \n\tcustomer_name VARCHAR(80), \n\tcustomer_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_name : George, Beulah, Leilani\ncustomer_details : dicta, quidem, deleniti\n*/\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 inventory (\n\tinventory_id INTEGER NOT NULL, \n\tfilm_id INTEGER NOT NULL, \n\tstore_id INTEGER NOT NULL, \n\tlast_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, \n\tPRIMARY KEY (inventory_id), \n\tFOREIGN KEY(store_id) REFERENCES store (store_id), \n\tFOREIGN KEY(film_id) REFERENCES film (film_id)\n)\n/*\nColumns in inventory and 3 examples in each column for high cardinality columns :\ninventory_id : 87, 56, 65\nfilm_id : 44, 17, 21\n*/\n/*\nColumns in inventory and all categories for low cardinality columns :\nstore_id : 1, 2\nlast_update : 2006-02-15 05:09:17\n*/\n" }, { "role": "user", "content": "For each customer who has at least two orders, find the customer name and number of orders made." }, { "role": "assistant", "content": "\nTo construct the query, I'll be working with the following tables: orders, customers.\nFrom these tables, I'll be using the following columns: customers.customer_name, orders.customer_id, customers.customer_id.\nThe SQL query I'll be generating is:\nSELECT T2.customer_name , count(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*) >= 2" } ]