input
stringlengths
193
2.69k
output
stringlengths
24
744
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: Among the listed winery, what is the street number of the winery named "Tulocay Winery"? [/INST]
SELECT T1.street_num FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.label = 'Tulocay winery' AND T2.food_type = 'winery';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: List the review and label of the restaurants in Mission Blvd., Hayward. [/INST]
SELECT T2.review, T2.label FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.city = 'hayward' AND T1.street_name = 'mission blvd';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: Among all indian restaurants in Castro St., Mountainview, how many of them is about cookhouse in their label? [/INST]
SELECT COUNT(T1.id_restaurant) FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.street_name = 'castro st' AND T1.city = 'mountain view' AND T2.food_type = 'indian' AND T2.label LIKE '%cookhouse%';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: In restaurants with a review of 2, how many restaurants have a street number below 500? [/INST]
SELECT COUNT(T1.id_restaurant) FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.review = 2 AND T1.street_num < 500;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: Among all asian restaurants in N. Milpitas Blvd., Milpitas, how many of them have restaurant ID greater than 385? [/INST]
SELECT COUNT(T1.id_restaurant) AS num FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.city = 'milpitas' AND T2.food_type = 'asian' AND T1.street_name = 'n milpitas blvd' AND T1.id_restaurant > 385;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: What is the restaurant's name and ID located at Ocean Avenue, San Francisco? [/INST]
SELECT T2.label, T1.id_restaurant FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'san francisco' AND T1.street_name = 'ocean avenue';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: What is the full address of the restaurant named "Sanuki Restaurant"? [/INST]
SELECT T2.city, T1.street_num, T1.street_name FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.label = 'sanuki restaurant';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: List the food type of the restaurant located in 22779 6th St., Hayward City. [/INST]
SELECT T2.food_type FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.street_num = 22779 AND T1.street_name = '6th St' AND T2.city = 'hayward';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: How many American restaurants are located in Front, San Francisco? [/INST]
SELECT COUNT(T2.food_type = 'american') FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'san francisco' AND T1.street_name = 'front';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: List the restaurant's ID that has a review greater than the 70% of average review of all American restaurants with street number greater than 2000. [/INST]
SELECT T1.id_restaurant FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.food_type = 'american' AND T1.street_num > 2000 GROUP BY T1.id_restaurant ORDER BY AVG(T2.review) * 0.7 DESC;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: Among the restaurants located on the street number ranges from 1000 to 2000, what is the percentage of Afghani restaurants are there? [/INST]
SELECT CAST(SUM(IIF(T2.food_type = 'afghani', 1, 0)) AS REAL) * 100 / COUNT(T1.id_restaurant) FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE 1000 <= T1.street_num <= 2000;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: What is the name of the most popular restaurant serving Asian foods in San Francisco? [/INST]
SELECT label FROM generalinfo WHERE food_type = 'asian' AND city = 'san francisco' AND review = ( SELECT MAX(review) FROM generalinfo WHERE food_type = 'asian' AND city = 'san francisco' );
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] Please write me a SQL statement that answers the following question: How many cities are there in Monterey? [/INST]
SELECT COUNT(DISTINCT city) FROM geographic WHERE region = 'monterey';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: How many deli in Belmont have a review rating of 2 or more? [/INST]
SELECT COUNT(id_restaurant) FROM generalinfo WHERE city = 'belmont' AND review > 2 AND food_type = 'deli';
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] Please write me a SQL statement that answers the following question: Which county in northern California has the highest number of cities? [/INST]
SELECT county FROM geographic WHERE region = 'northern california' GROUP BY county ORDER BY COUNT(city) DESC LIMIT 1;
[INST] Here is a database schema: location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: How many restaurants can you find in Concord? [/INST]
SELECT COUNT(id_restaurant) FROM location WHERE city = 'concord';
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: In which region can you find the top 4 most popular restaurants? [/INST]
SELECT T2.region FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city ORDER BY T1.review DESC LIMIT 4;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: How many Chinese restaurants are there on 1st st, Livermore? [/INST]
SELECT COUNT(T1.id_restaurant) FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'livermore' AND T1.food_type = 'chinese' AND T2.street_name = '1st st';
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: How many Indian restaurants are there in the Los Angeles area? [/INST]
SELECT COUNT(T1.city) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T2.food_type = 'indian' AND T1.region = 'los angeles area';
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: In the Bay Area, what is the most common type of food served by restaurants? [/INST]
SELECT T2.food_type FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.region = 'bay area' GROUP BY T2.food_type ORDER BY COUNT(T2.food_type) DESC LIMIT 1;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: How many restaurants in Broadway, Oakland received a review of no more than 3? [/INST]
SELECT COUNT(T1.id_restaurant) FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.street_name = 'broadway' AND T2.review < 3 AND T1.city = 'oakland';
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: In which region can you find the highest number of Baskin Robbins restaurants? [/INST]
SELECT T2.region AS num FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label = 'baskin robbins' GROUP BY T2.region ORDER BY COUNT(T1.city) DESC LIMIT 1;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: List all the streets where pizza-serving restaurants are found in San Jose. [/INST]
SELECT T1.street_name FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T2.food_type = 'pizza' AND T1.city = 'san jose';
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: How many types of restaurants are there in the Yosemite and Mono Lake area? [/INST]
SELECT COUNT(T2.food_type) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.region = 'yosemite and mono lake area';
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: What is the full address of the most popular restaurant among the diners? [/INST]
SELECT T2.street_name, T2.street_num, T2.city FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant ORDER BY T1.review DESC LIMIT 1;
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] Please write me a SQL statement that answers the following question: In which counties can you find the restaurant with the highest number of branches? [/INST]
SELECT T2.county FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city GROUP BY T2.county ORDER BY COUNT(T1.label) DESC LIMIT 1;
[INST] Here is a database schema: geographic : city [ TEXT ] primary_key county [ TEXT ] region [ TEXT ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: Which region has the highest number of restaurants? [/INST]
SELECT T1.region FROM geographic AS T1 INNER JOIN location AS T2 ON T1.city = T2.city GROUP BY T1.region ORDER BY COUNT(T2.id_restaurant) DESC LIMIT 1;
[INST] Here is a database schema: generalinfo : id_restaurant [ INTEGER ] primary_key label [ TEXT ] food_type [ TEXT ] city [ TEXT ] generalinfo.city = geographic.city review [ REAL ] location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant street_num [ INTEGER ] street_name [ TEXT ] city [ TEXT ] location.city = geographic.city Please write me a SQL statement that answers the following question: List the full address of all the American restaurants with a review of 4 or more? [/INST]
SELECT T1.street_num, T1.street_name, T1.city FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T2.review >= 4;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: How many players were born after the year 1985? [/INST]
SELECT COUNT(Player_Id) FROM Player WHERE SUBSTR(DOB, 1, 4) > 1985;
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: How many players are from Australia? [/INST]
SELECT COUNT(CASE WHEN T2.Country_Name = 'Australia' THEN T1.Player_Id ELSE NULL END) FROM Player AS T1 INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_Id;
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Which country is the oldest player from? [/INST]
SELECT T1.Country_Name FROM Country AS T1 INNER JOIN Player AS T2 ON T2.Country_Name = T1.Country_Id WHERE T2.Country_Name IS NOT NULL ORDER BY T2.DOB LIMIT 1;
[INST] Here is a database schema: Bowling_Style : Bowling_Id [ INTEGER ] primary_key Bowling_skill [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: What is the bowling skill of SC Ganguly? [/INST]
SELECT T1.Bowling_Skill FROM Bowling_Style AS T1 INNER JOIN Player AS T2 ON T2.Bowling_skill = T1.Bowling_Id WHERE T2.Player_Name = 'SC Ganguly';
[INST] Here is a database schema: Batting_Style : Batting_Id [ INTEGER ] primary_key Batting_hand [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Among the players who use the right hand as their batting hand, how many of them were born after 1985? [/INST]
SELECT SUM(CASE WHEN SUBSTR(T1.DOB, 1, 4) > 1985 THEN 1 ELSE 0 END) FROM Player AS T1 INNER JOIN Batting_Style AS T2 ON T1.Batting_hand = T2.Batting_Id WHERE T2.Batting_Hand = 'Right-hand bat';
[INST] Here is a database schema: Batting_Style : Batting_Id [ INTEGER ] primary_key Batting_hand [ TEXT ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Please list the names of the players who use the right hand as their batting hand and are from Australia. [/INST]
SELECT T2.Player_Name FROM Country AS T1 INNER JOIN Player AS T2 ON T2.Country_Name = T1.Country_id INNER JOIN Batting_Style AS T3 ON T2.Batting_hand = T3.Batting_Id WHERE T1.Country_Name = 'Australia' AND T3.Batting_Hand = 'Right-hand bat';
[INST] Here is a database schema: Bowling_Style : Bowling_Id [ INTEGER ] primary_key Bowling_skill [ TEXT ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Please list the bowling skills of all the players from Australia. [/INST]
SELECT T2.Bowling_Skill FROM Player AS T1 INNER JOIN Bowling_Style AS T2 ON T1.Bowling_skill = T2.Bowling_Id INNER JOIN Country AS T3 ON T1.Country_Name = T3.Country_Id WHERE T3.Country_Name = 'Australia' GROUP BY T2.Bowling_Skill;
[INST] Here is a database schema: Bowling_Style : Bowling_Id [ INTEGER ] primary_key Bowling_skill [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Among the players whose bowling skill is "Legbreak", when was the oldest one of them born? [/INST]
SELECT MIN(T1.DOB) FROM Player AS T1 INNER JOIN Bowling_Style AS T2 ON T1.Bowling_skill = T2.Bowling_Id WHERE T2.Bowling_Skill = 'Legbreak';
[INST] Here is a database schema: Bowling_Style : Bowling_Id [ INTEGER ] primary_key Bowling_skill [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: What is the bowling skill used by most players? [/INST]
SELECT T1.Bowling_Skill FROM Bowling_Style AS T1 INNER JOIN Player AS T2 ON T2.Bowling_skill = T1.Bowling_Id GROUP BY T1.Bowling_Skill ORDER BY COUNT(T1.Bowling_Skill) DESC LIMIT 1;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: What is the name of the player who won the "man of the match" award in the match on 2008/4/18? [/INST]
SELECT T2.Player_Name FROM Match AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_Match WHERE T1.Match_Date = '2008-04-18';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Rolee : Role_Id [ INTEGER ] primary_key Role_Desc [ TEXT ] Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: For how many times has SC Ganguly played as team captain in a match? [/INST]
SELECT SUM(CASE WHEN T3.Role_Desc = 'Captain' THEN 1 ELSE 0 END) FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Rolee AS T3 ON T2.Role_Id = T3.Role_Id WHERE T1.Player_Name = 'SC Ganguly';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Rolee : Role_Id [ INTEGER ] primary_key Role_Desc [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: What is the role of SC Ganguly in the match on 2008/4/18? [/INST]
SELECT T2.Role_Id FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Rolee AS T3 ON T2.Role_Id = T3.Role_Id INNER JOIN Match AS T4 ON T2.Match_Id = T4.Match_Id WHERE T1.Player_Name = 'SC Ganguly' AND T4.Match_Date = '2008-04-18';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: Among all the matches SC Ganguly has played in, what is the highest winning margin? [/INST]
SELECT MAX(T3.Win_Margin) FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Match AS T3 ON T2.Match_Id = T3.Match_Id WHERE T1.Player_Name = 'SC Ganguly';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: What is the average winning margin of all the matches SC Ganguly has played in? [/INST]
SELECT CAST(SUM(T3.Win_Margin) AS REAL) / COUNT(*) FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Match AS T3 ON T2.Match_Id = T3.Match_Id WHERE T1.Player_Name = 'SC Ganguly';
[INST] Here is a database schema: Batting_Style : Batting_Id [ INTEGER ] primary_key Batting_hand [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Among all the players born after the year 1985, what is the percentage of the players who use the right hand as their batting hand? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Batting_Hand = 'Right-hand bat' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Player_Id) FROM Player AS T1 INNER JOIN Batting_Style AS T2 ON T1.Batting_hand = T2.Batting_Id WHERE SUBSTR(T1.DOB, 1, 4) > 1985;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Give the name of the youngest player. [/INST]
SELECT Player_Name FROM Player ORDER BY DOB DESC LIMIT 1;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Ball_by_Ball : Match_Id [ INTEGER ] Ball_by_Ball.Match_Id = Match.Match_Id Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Innings_No [ INTEGER ] Team_Batting [ INTEGER ] Team_Bowling [ INTEGER ] Striker_Batting_Position [ INTEGER ] Striker [ INTEGER ] Non_Striker [ INTEGER ] Bowler [ INTEGER ] Please write me a SQL statement that answers the following question: Give the name of the striker in the match no. 419169, over no.3, ball no.2, inning no.2. [/INST]
SELECT T2.Player_Name FROM Ball_by_Ball AS T1 INNER JOIN Player AS T2 ON T1.Striker = T2.Player_Id WHERE T1.Match_Id = 419169 AND T1.Over_Id = 3 AND T1.Ball_Id = 2 AND T1.Innings_No = 2;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: For the game on 2008/5/12, who was the man of the match? [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Match AS T2 ON T1.Player_Id = T2.Man_of_the_Match WHERE T2.Match_Date = '2008-05-12';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Rolee : Role_Id [ INTEGER ] primary_key Role_Desc [ TEXT ] Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: State the name of captain keeper of the match no.419117. [/INST]
SELECT T3.Player_Name FROM Player_Match AS T1 INNER JOIN Rolee AS T2 ON T1.Role_Id = T2.Role_Id INNER JOIN Player AS T3 ON T1.Player_Id = T3.Player_Id WHERE T1.Match_Id = '419117' AND T2.Role_Desc = 'CaptainKeeper';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Season : Season_Id [ INTEGER ] primary_key Man_of_the_Series [ INTEGER ] Orange_Cap [ INTEGER ] Purple_Cap [ INTEGER ] Season_Year [ INTEGER ] Please write me a SQL statement that answers the following question: Who was the man of the series in 2013? Give the full name. [/INST]
SELECT T2.Player_Name FROM Season AS T1 INNER JOIN Player AS T2 ON T1.Man_of_the_Series = T2.Player_Id WHERE T1.Season_Year = 2013;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Season : Season_Id [ INTEGER ] primary_key Man_of_the_Series [ INTEGER ] Orange_Cap [ INTEGER ] Purple_Cap [ INTEGER ] Season_Year [ INTEGER ] Please write me a SQL statement that answers the following question: Give the date of birth of the 2014 Orange Cap winner. [/INST]
SELECT T2.DOB FROM Season AS T1 INNER JOIN Player AS T2 ON T1.Man_of_the_Series = T2.Player_Id WHERE T1.Season_Year = 2014 AND T1.Orange_Cap IS NOT NULL;
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Season : Season_Id [ INTEGER ] primary_key Man_of_the_Series [ INTEGER ] Orange_Cap [ INTEGER ] Purple_Cap [ INTEGER ] Season_Year [ INTEGER ] Please write me a SQL statement that answers the following question: What is the nationality of the 7th season Purple Cap winner? [/INST]
SELECT T3.Country_Name FROM Season AS T1 INNER JOIN Player AS T2 ON T1.Man_of_the_Series = T2.Player_Id INNER JOIN Country AS T3 ON T2.Country_Name = T3.Country_Id WHERE T1.Season_Id = 7 AND T1.Purple_Cap IS NOT NULL;
[INST] Here is a database schema: City : City_Id [ INTEGER ] primary_key City_Name [ TEXT ] Country_id [ INTEGER ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Please write me a SQL statement that answers the following question: Which country does Ranchi city belong to? [/INST]
SELECT T2.Country_Name FROM City AS T1 INNER JOIN Country AS T2 ON T1.Country_Id = T2.Country_Id WHERE T1.City_Name = 'Ranchi';
[INST] Here is a database schema: City : City_Id [ INTEGER ] primary_key City_Name [ TEXT ] Country_id [ INTEGER ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Please write me a SQL statement that answers the following question: How many Indian cities are there in the database? [/INST]
SELECT SUM(CASE WHEN T2.Country_Name = 'India' THEN 1 ELSE 0 END) FROM City AS T1 INNER JOIN Country AS T2 ON T1.Country_Id = T2.Country_Id;
[INST] Here is a database schema: City : City_Id [ INTEGER ] primary_key City_Name [ TEXT ] Country_id [ INTEGER ] Venue : Venue_Id [ INTEGER ] primary_key Venue_Name [ TEXT ] City_Id [ INTEGER ] Venue.City_Id = City.City_Id Please write me a SQL statement that answers the following question: State the name of the city with the most venues. [/INST]
SELECT T1.City_Name FROM City AS T1 INNER JOIN Venue AS T2 ON T1.City_Id = T2.City_Id GROUP BY T1.City_Id ORDER BY COUNT(T2.Venue_Id) DESC LIMIT 1;
[INST] Here is a database schema: Batting_Style : Batting_Id [ INTEGER ] primary_key Batting_hand [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: What is the batting hand of MK Pandey? [/INST]
SELECT T2.Batting_hand FROM Player AS T1 INNER JOIN Batting_Style AS T2 ON T1.Batting_hand = T2.Batting_Id WHERE T1.Player_Name = 'MK Pandey';
[INST] Here is a database schema: City : City_Id [ INTEGER ] primary_key City_Name [ TEXT ] Country_id [ INTEGER ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Please write me a SQL statement that answers the following question: In the database, how many times is the number of Indian cities to the South African cities? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Country_Name = 'India' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.Country_Name = 'South Africa' THEN 1 ELSE 0 END) FROM City AS T1 INNER JOIN Country AS T2 ON T1.Country_Id = T2.Country_Id;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Who is the oldest player? [/INST]
SELECT Player_Name FROM Player ORDER BY DOB ASC LIMIT 1;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: How many players were born in the 90s? [/INST]
SELECT COUNT(Player_Id) AS cnt FROM Player WHERE DOB BETWEEN '1990-01-01' AND '1999-12-31';
[INST] Here is a database schema: Season : Season_Id [ INTEGER ] primary_key Man_of_the_Series [ INTEGER ] Orange_Cap [ INTEGER ] Purple_Cap [ INTEGER ] Season_Year [ INTEGER ] Please write me a SQL statement that answers the following question: List the id of the player who won the Orange Cap for 2 consecutive seasons. [/INST]
SELECT Orange_Cap FROM Season GROUP BY Orange_Cap HAVING COUNT(Season_Year) > 1;
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Umpire : Umpire_Id [ INTEGER ] primary_key Umpire_Name [ TEXT ] Umpire_Country [ INTEGER ] Umpire.Umpire_Country = Country.Country_Id Please write me a SQL statement that answers the following question: How many umpires are from South Africa? [/INST]
SELECT SUM(CASE WHEN T1.Country_Name = 'South Africa' THEN 1 ELSE 0 END) FROM Country AS T1 INNER JOIN Umpire AS T2 ON T1.Country_ID = T2.Umpire_Country;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: What is the name of the player with the highest number of outstanding player awards in a particular match? [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Match AS T2 ON T1.Player_Id = T2.Man_of_the_Match GROUP BY T2.Man_of_the_Match ORDER BY COUNT(T2.Man_of_the_Match) DESC LIMIT 1;
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: In which country do the majority of the players are from? [/INST]
SELECT T1.Country_Name FROM Country AS T1 INNER JOIN Player AS T2 ON T1.Country_Id = T2.Country_Name GROUP BY T2.Country_Name ORDER BY COUNT(T2.Country_Name) DESC LIMIT 1;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Season : Season_Id [ INTEGER ] primary_key Man_of_the_Series [ INTEGER ] Orange_Cap [ INTEGER ] Purple_Cap [ INTEGER ] Season_Year [ INTEGER ] Please write me a SQL statement that answers the following question: How many Orange Cap awards were won by CH Gayle? [/INST]
SELECT SUM(CASE WHEN T1.Player_Name = 'CH Gayle' THEN 1 ELSE 0 END) AS cnt FROM Player AS T1 INNER JOIN Season AS T2 ON T1.Player_Id = T2.Orange_Cap;
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Venue : Venue_Id [ INTEGER ] primary_key Venue_Name [ TEXT ] City_Id [ INTEGER ] Venue.City_Id = City.City_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Which venue did Kolkata Knight Riders play most of their matches as a Team 1? [/INST]
SELECT T3.Venue_Name FROM Team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Team_1 INNER JOIN Venue AS T3 ON T2.Venue_Id = T3.Venue_Id WHERE T1.Team_Name = 'Kolkata Knight Riders' GROUP BY T3.Venue_Id ORDER BY COUNT(T3.Venue_Id) DESC LIMIT 1;
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Which team has the highest number of losses of all time? [/INST]
SELECT T1.Team_Name FROM Team AS T1 INNER JOIN ( SELECT COUNT(Team_1) AS a, Team_1 FROM Match WHERE Team_1 <> Match_Winner GROUP BY Team_1 UNION SELECT COUNT(Team_2) AS a, Team_2 FROM Match WHERE Team_2 <> Match_Winner GROUP BY Team_2 ORDER BY a DESC LIMIT 1 ) AS T2 ON T1.Team_Id = T2.Team_1;
[INST] Here is a database schema: Batting_Style : Batting_Id [ INTEGER ] primary_key Batting_hand [ TEXT ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: How many players with left-hand batting style are from India? [/INST]
SELECT SUM(CASE WHEN T1.Batting_hand = 'Left-hand bat' THEN 1 ELSE 0 END) AS cnt FROM Batting_Style AS T1 INNER JOIN Player AS T2 ON T1.Batting_Id = T2.Batting_hand INNER JOIN Country AS T3 ON T2.Country_Name = T3.Country_Id WHERE T3.Country_Name = 'India';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Rolee : Role_Id [ INTEGER ] primary_key Role_Desc [ TEXT ] Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: Who is the player that has the highest number of roles as a captain for Deccan Chargers? [/INST]
SELECT T4.Player_Name FROM Team AS T1 INNER JOIN Player_Match AS T2 ON T1.Team_id = T2.Team_id INNER JOIN Rolee AS T3 ON T2.Role_Id = T3.Role_Id INNER JOIN Player AS T4 ON T2.Player_Id = T4.Player_Id WHERE T1.Team_Name = 'Deccan Chargers' AND T1.Team_Id = 8 AND T3.Role_Desc = 'Captain' AND T3.Role_Id = 1 GROUP BY T4.Player_Id ORDER BY COUNT(T3.Role_Id) DESC LIMIT 1;
[INST] Here is a database schema: Batting_Style : Batting_Id [ INTEGER ] primary_key Batting_hand [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: What is the percentage of all right-handed batting players among all the other players? [/INST]
SELECT CAST(SUM(CASE WHEN T1.Batting_hand = 'Right-hand bat' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.Player_Id) FROM Batting_Style AS T1 INNER JOIN Player AS T2 ON T2.Batting_hand = T1.Batting_Id;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Name the player who is born on July 7, 1981. [/INST]
SELECT Player_name FROM Player WHERE DOB = '1981-07-07';
[INST] Here is a database schema: Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: How many matches were played by the player with player ID 2? [/INST]
SELECT SUM(CASE WHEN Player_Id = 2 THEN 1 ELSE 0 END) FROM Player_Match;
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: List the first team's name in the match with the highest winning margin. [/INST]
SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_1 ORDER BY T1.Win_Margin DESC LIMIT 1;
[INST] Here is a database schema: City : City_Id [ INTEGER ] primary_key City_Name [ TEXT ] Country_id [ INTEGER ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Venue : Venue_Id [ INTEGER ] primary_key Venue_Name [ TEXT ] City_Id [ INTEGER ] Venue.City_Id = City.City_Id Please write me a SQL statement that answers the following question: Give the country where St. George's Park is located. [/INST]
SELECT T3.Country_Name FROM Venue AS T1 INNER JOIN City AS T2 ON T2.City_Id = T1.City_Id INNER JOIN Country AS T3 ON T3.Country_Id = T2.Country_id WHERE T1.Venue_Name = 'St George''s Park';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: List the player's name of Mumbai Indians in the match ID 335990. [/INST]
SELECT T3.Team_Name FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T2.Player_Id = T1.Player_Id INNER JOIN Team AS T3 ON T3.Team_Id = T2.Team_Id WHERE T2.Match_Id = 335990 AND T3.Team_Name = 'Mumbai Indians' GROUP BY T3.Team_Name;
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Provide the winning team's name in the match with the point of winning margin of 7 on May 7, 2009. [/INST]
SELECT T1.Team_Name FROM Team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Match_Winner WHERE T2.Match_Date = '2009-05-07' AND T2.Win_Margin = 7;
[INST] Here is a database schema: Outcome : Outcome_Id [ INTEGER ] primary_key Outcome_Type [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: How many of the matches are Superover? [/INST]
SELECT SUM(CASE WHEN T2.Outcome_Type = 'Superover' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Outcome AS T2 ON T2.Outcome_Id = T1.Outcome_type;
[INST] Here is a database schema: City : City_Id [ INTEGER ] primary_key City_Name [ TEXT ] Country_id [ INTEGER ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Please write me a SQL statement that answers the following question: List the cities located in U.A.E. [/INST]
SELECT T1.City_Name FROM City AS T1 INNER JOIN Country AS T2 ON T2.Country_Id = T1.Country_id WHERE T2.Country_Name = 'U.A.E';
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: What is the total number of won matches of the team named "Pune Warriors"? [/INST]
SELECT SUM(CASE WHEN T2.Team_Name = 'Pune Warriors' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner;
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Among the matches held in 2015, who is the winning team in the match ID 829768? [/INST]
SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner WHERE T1.Match_Date LIKE '2015%' AND T1.Match_Id = 829768;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Rolee : Role_Id [ INTEGER ] primary_key Role_Desc [ TEXT ] Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: What is the role of K Goel in the match ID 335992? [/INST]
SELECT T3.Role_Desc FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T2.Player_Id = T1.Player_Id INNER JOIN Rolee AS T3 ON T3.Role_Id = T2.Role_Id WHERE T2.Match_Id = 335992 AND T1.Player_Name = 'K Goel';
[INST] Here is a database schema: City : City_Id [ INTEGER ] primary_key City_Name [ TEXT ] Country_id [ INTEGER ] Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Please write me a SQL statement that answers the following question: How many cities are located in South Africa? [/INST]
SELECT SUM(CASE WHEN T2.Country_Name = 'South Africa' THEN 1 ELSE 0 END) FROM City AS T1 INNER JOIN Country AS T2 ON T2.Country_Id = T1.Country_id;
[INST] Here is a database schema: Venue : Venue_Id [ INTEGER ] primary_key Venue_Name [ TEXT ] City_Id [ INTEGER ] Venue.City_Id = City.City_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: How many matches were held at the venue named "Newlands"? [/INST]
SELECT SUM(CASE WHEN T2.Venue_Name = 'Newlands' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Venue AS T2 ON T2.Venue_Id = T1.Venue_Id;
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Provide the point of the winning margin in a match between Mumbai Indians and Royal Challengers Bangalore on May 28, 2008. [/INST]
SELECT T1.Win_Margin FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_1 INNER JOIN Team AS T3 ON T3.Team_Id = T1.Team_2 WHERE (T2.Team_Name = 'Mumbai Indians' AND T3.Team_Name = 'Royal Challengers Bangalore' AND T1.Match_Date = '2008-05-28') OR (T2.Team_Name = 'Royal Challengers Bangalore' AND T3.Team_Name = 'Mumbai Indians' AND T1.Match_Date = '2008-05-28');
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: List the names of the first andthe second teams that played a match with the point of the winning margin lower than the 30% of the average winning margin of the matches held in 2011. [/INST]
SELECT DISTINCT CASE WHEN T1.Win_Margin < ( SELECT AVG(Win_Margin) * 0.3 FROM Match WHERE Match_Date LIKE '2011%' ) THEN T2.Team_Name END, CASE WHEN T1.Win_Margin < ( SELECT AVG(Win_Margin) * 0.3 FROM Match WHERE Match_Date LIKE '2011%' ) THEN T3.Team_Name END FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_1 INNER JOIN Team AS T3 ON T3.Team_Id = T1.Team_2 WHERE T1.Match_Date LIKE '2011%';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Rolee : Role_Id [ INTEGER ] primary_key Role_Desc [ TEXT ] Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: Among the players born in 1977, what is the percentage of the players with a role as a captain? [/INST]
SELECT CAST(SUM(CASE WHEN T1.Role_Desc = 'Captain' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Role_Id) FROM Rolee AS T1 INNER JOIN Player_Match AS T2 ON T2.Role_Id = T1.Role_Id INNER JOIN Player AS T3 ON T3.Player_Id = T2.Player_Id WHERE T3.DOB LIKE '1977%';
[INST] Here is a database schema: Ball_by_Ball : Match_Id [ INTEGER ] Ball_by_Ball.Match_Id = Match.Match_Id Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Innings_No [ INTEGER ] Team_Batting [ INTEGER ] Team_Bowling [ INTEGER ] Striker_Batting_Position [ INTEGER ] Striker [ INTEGER ] Non_Striker [ INTEGER ] Bowler [ INTEGER ] Please write me a SQL statement that answers the following question: How many overs were there in the first innings of match ID "335996"? [/INST]
SELECT COUNT(Over_Id) FROM Ball_by_Ball WHERE Match_Id = 335996 AND Innings_No = 1;
[INST] Here is a database schema: Batsman_Scored : Match_Id [ INTEGER ] Batsman_Scored.Match_Id = Match.Match_Id Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Runs_Scored [ INTEGER ] Innings_No [ INTEGER ] Please write me a SQL statement that answers the following question: List the over IDs, ball IDs, and innings numbers of the match ID "336004" while the batsman got the maximum scores. [/INST]
SELECT Over_Id, Ball_Id, Innings_No FROM Batsman_Scored WHERE Match_Id = 336004 ORDER BY Runs_Scored DESC LIMIT 1;
[INST] Here is a database schema: Ball_by_Ball : Match_Id [ INTEGER ] Ball_by_Ball.Match_Id = Match.Match_Id Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Innings_No [ INTEGER ] Team_Batting [ INTEGER ] Team_Bowling [ INTEGER ] Striker_Batting_Position [ INTEGER ] Striker [ INTEGER ] Non_Striker [ INTEGER ] Bowler [ INTEGER ] Please write me a SQL statement that answers the following question: Describe any five matches IDs that reached over ID 20. [/INST]
SELECT Match_Id FROM Ball_by_Ball WHERE Over_Id = 20 GROUP BY Match_Id LIMIT 5;
[INST] Here is a database schema: Wicket_Taken : Match_Id [ INTEGER ] Wicket_Taken.Match_Id = Match.Match_Id Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Player_Out [ INTEGER ] Wicket_Taken.Player_Out = Player.Player_Id Kind_Out [ INTEGER ] Wicket_Taken.Kind_Out = Out_Type.Out_Id Fielders [ INTEGER ] Wicket_Taken.Fielders = Player.Player_Id Innings_No [ INTEGER ] Please write me a SQL statement that answers the following question: How many players got out in the first inning of match ID "548335"? [/INST]
SELECT SUM(CASE WHEN Match_Id = 548335 THEN 1 ELSE 0 END) FROM Wicket_Taken WHERE Innings_No = 1;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: List the players' names who were born in 1971. [/INST]
SELECT Player_name FROM Player WHERE DOB LIKE '1971%';
[INST] Here is a database schema: Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Provide the match IDs which were held on 18th April 2015. [/INST]
SELECT Match_Id FROM Match WHERE Match_Date LIKE '%2015-04-18%';
[INST] Here is a database schema: Out_Type : Out_Id [ INTEGER ] primary_key Out_Name [ TEXT ] Wicket_Taken : Match_Id [ INTEGER ] Wicket_Taken.Match_Id = Match.Match_Id Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Player_Out [ INTEGER ] Wicket_Taken.Player_Out = Player.Player_Id Kind_Out [ INTEGER ] Wicket_Taken.Kind_Out = Out_Type.Out_Id Fielders [ INTEGER ] Wicket_Taken.Fielders = Player.Player_Id Innings_No [ INTEGER ] Please write me a SQL statement that answers the following question: List the match IDs which had players out by hit wickets. [/INST]
SELECT T1.Match_Id FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T2.Out_Id = T1.Kind_Out WHERE T2.Out_Name = 'hit wicket';
[INST] Here is a database schema: Out_Type : Out_Id [ INTEGER ] primary_key Out_Name [ TEXT ] Wicket_Taken : Match_Id [ INTEGER ] Wicket_Taken.Match_Id = Match.Match_Id Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Player_Out [ INTEGER ] Wicket_Taken.Player_Out = Player.Player_Id Kind_Out [ INTEGER ] Wicket_Taken.Kind_Out = Out_Type.Out_Id Fielders [ INTEGER ] Wicket_Taken.Fielders = Player.Player_Id Innings_No [ INTEGER ] Please write me a SQL statement that answers the following question: How many players got out by being stumped in the second innings of all matches? [/INST]
SELECT SUM(CASE WHEN T1.Innings_No = 2 THEN 1 ELSE 0 END) FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T2.Out_Id = T1.Kind_Out WHERE T2.Out_Name = 'stumped';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: How many times did Yuvraj Singh receive the Man of the Match award? [/INST]
SELECT SUM(CASE WHEN T2.Player_Name = 'Yuvraj Singh' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_Match;
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Among the players who were born in 1977, provide names and birthdates of the players from England. [/INST]
SELECT T2.Player_Name, T2.DOB FROM Country AS T1 INNER JOIN Player AS T2 ON T2.Country_Name = T1.Country_Id WHERE T2.DOB LIKE '1977%' AND T1.Country_Name = 'England';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Season : Season_Id [ INTEGER ] primary_key Man_of_the_Series [ INTEGER ] Orange_Cap [ INTEGER ] Purple_Cap [ INTEGER ] Season_Year [ INTEGER ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Who got the Man of the Series Award in 2010? [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Match AS T2 ON T2.Man_of_the_Match = T1.Player_Id INNER JOIN Season AS T3 ON T3.Season_Id = T2.Season_Id WHERE T3.Season_Year = 2010 GROUP BY T1.Player_Name;
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Please write me a SQL statement that answers the following question: Calculate the win rate of the team "Chennai Super Kings". [/INST]
SELECT CAST(SUM(CASE WHEN T1.Match_Winner = 3 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Match_Id) FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_1 INNER JOIN Team AS T3 ON T3.Team_Id = T1.Team_2 WHERE T2.Team_Name = 'Chennai Super Kings' OR T3.Team_Name = 'Chennai Super Kings';
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: List the names and countries of the players from Gujarat Lions who played in the match held on 11th April 2016. [/INST]
SELECT T4.Player_Name, T5.Country_Name FROM Player_Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_Id INNER JOIN Match AS T3 ON T3.Match_Id = T1.Match_Id INNER JOIN Player AS T4 ON T4.Player_Id = T1.Player_Id INNER JOIN Country AS T5 ON T5.Country_Id = T4.Country_Name WHERE T2.Team_Name = 'Gujarat Lions' AND T3.Match_Date = '2016-04-11';
[INST] Here is a database schema: Bowling_Style : Bowling_Id [ INTEGER ] primary_key Bowling_skill [ TEXT ] Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Please write me a SQL statement that answers the following question: Provide the names and birthdates of players who have left-arm fast skills. [/INST]
SELECT T1.Player_Name, T1.DOB FROM Player AS T1 INNER JOIN Bowling_Style AS T2 ON T2.Bowling_Id = T1.Bowling_skill WHERE T2.Bowling_skill = 'Left-arm fast';
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Umpire : Umpire_Id [ INTEGER ] primary_key Umpire_Name [ TEXT ] Umpire_Country [ INTEGER ] Umpire.Umpire_Country = Country.Country_Id Please write me a SQL statement that answers the following question: Where did BR Doctrove come from? [/INST]
SELECT T1.Country_Name FROM Country AS T1 INNER JOIN Umpire AS T2 ON T2.Umpire_Country = T1.Country_Id WHERE T2.Umpire_Name = 'BR Doctrove';
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Rolee : Role_Id [ INTEGER ] primary_key Role_Desc [ TEXT ] Match : Match_Id [ INTEGER ] primary_key Team_1 [ INTEGER ] Match.Team_1 = Team.Team_Id Team_2 [ INTEGER ] Match.Team_2 = Team.Team_Id Match_Date [ DATE ] Season_Id [ INTEGER ] Match.Season_Id = Season.Season_Id Venue_Id [ INTEGER ] Match.Venue_Id = Venue.Venue_Id Toss_Winner [ INTEGER ] Match.Toss_Winner = Team.Team_Id Toss_Decide [ INTEGER ] Match.Toss_Decide = Toss_Decision.Toss_Id Win_Type [ INTEGER ] Match.Win_Type = Win_By.Win_Id Win_Margin [ INTEGER ] Outcome_type [ INTEGER ] Match.Outcome_type = Out_Type.Out_Id Match_Winner [ INTEGER ] Match.Match_Winner = Team.Team_Id Man_of_the_Match [ INTEGER ] Match.Man_of_the_Match = Player.Player_Id Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: Who was the captain of the winning team in the match held on 1st June 2008? [/INST]
SELECT T3.Player_Name FROM Player_Match AS T1 INNER JOIN Match AS T2 ON T2.Match_Id = T1.Match_Id INNER JOIN Player AS T3 ON T3.Player_Id = T1.Player_Id INNER JOIN Rolee AS T4 ON T4.Role_Id = T1.Role_Id WHERE T2.Match_Date = '2008-06-01' AND T4.Role_Desc = 'Captain' AND T2.Match_Winner = T1.Team_Id;
[INST] Here is a database schema: Player : Player_Id [ INTEGER ] primary_key Player_Name [ TEXT ] DOB [ DATE ] Batting_hand [ INTEGER ] Player.Batting_hand = Batting_Style.Batting_Id Bowling_skill [ INTEGER ] Player.Bowling_skill = Bowling_Style.Bowling_Id Country_Name [ INTEGER ] Player.Country_Name = Country.Country_Id Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Player_Match : Match_Id [ INTEGER ] Player_Match.Match_Id = Match.Match_Id Player_Id [ INTEGER ] Player_Match.Player_Id = Player.Player_Id Role_Id [ INTEGER ] Player_Match.Role_Id = Rolee.Role_Id Team_Id [ INTEGER ] Player_Match.Team_Id = Team.Team_Id Please write me a SQL statement that answers the following question: Which team did CK Kapugedera belong to? How many matches did he play? [/INST]
SELECT T3.Team_Name, COUNT(T2.Match_Id) FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T2.Player_Id = T1.Player_Id INNER JOIN Team AS T3 ON T3.Team_Id = T2.Team_Id WHERE T1.Player_Name = 'CK Kapugedera';