input
stringlengths
193
2.69k
output
stringlengths
24
744
[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 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 Mumbai, how many percent of them were held in Wankhede Stadium? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Venue_Name = 'Wankhede Stadium' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T3.Match_Id) FROM City AS T1 INNER JOIN Venue AS T2 ON T2.City_Id = T1.City_Id INNER JOIN Match AS T3 ON T3.Venue_Id = T2.Venue_Id WHERE T1.City_Name = 'Mumbai';
[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: Among the players out in match ID 392187, calculate the percentage of players out by bowl. [/INST]
SELECT CAST(SUM(CASE WHEN T2.Out_Name = 'bowled' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Player_Out) FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T2.Out_Id = T1.Kind_Out WHERE T1.Match_Id = 392187;
[INST] Here is a database schema: Toss_Decision : Toss_Id [ INTEGER ] primary_key Toss_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: How many percent of the toss-winners decided to bowl first on the pitch from 2010 to 2016? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Toss_Name = 'field' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.Toss_Id) FROM Match AS T1 INNER JOIN Toss_Decision AS T2 ON T2.Toss_Id = T1.Toss_Decide WHERE T1.Match_Date BETWEEN '2010-01-01' AND '2016-12-31';
[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: List down the ID of toss winners who decided to bat after winning the "toss of the coin". [/INST]
SELECT Toss_Winner FROM Match WHERE Toss_Decide = 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: List down the match ID of matches that the "man of the match" award was given to BB McCullum. [/INST]
SELECT T1.Match_Id FROM Match AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_Match WHERE T2.Player_Name = 'BB McCullum';
[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: List down the DOB of players who received the "man of the match" award. [/INST]
SELECT T2.DOB FROM Match AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_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 down the name of teams that won the toss of the coin from matches with ID from 336010 to 336020. [/INST]
SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Toss_Winner WHERE T1.Match_Id BETWEEN 336010 AND 336020;
[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: How many matches have Mumbai Indians won? [/INST]
SELECT SUM(CASE WHEN T2.Team_Name = 'Mumbai Indians' 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: List down names of teams that have played as second team against Pune Warriors. [/INST]
SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_2 WHERE T1.Team_1 = ( SELECT Team_Id FROM Team WHERE Team_Name = 'Pune Warriors' ) GROUP BY T2.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: What is the name of the team that won match ID 336000? [/INST]
SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner WHERE T1.Match_Id = 336000;
[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: What are the match IDs that were played at Brabourne Stadium? [/INST]
SELECT T1.Match_Id FROM Match AS T1 INNER JOIN Venue AS T2 ON T2.Venue_Id = T1.Venue_Id WHERE T2.Venue_Name = 'Brabourne Stadium';
[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: List down the name of venues in season 2. [/INST]
SELECT T2.Venue_Name FROM Match AS T1 INNER JOIN Venue AS T2 ON T2.Venue_Id = T1.Venue_Id WHERE T1.Season_Id = 2 GROUP BY T2.Venue_Name;
[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: What is the city of M Chinnaswamy Stadium? [/INST]
SELECT T1.City_Name FROM City AS T1 INNER JOIN Venue AS T2 ON T2.City_Id = T1.City_Id WHERE T2.Venue_Name = 'M Chinnaswamy Stadium';
[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: List down all of the venues in Mumbai. [/INST]
SELECT T2.Venue_Name FROM City AS T1 INNER JOIN Venue AS T2 ON T2.City_Id = T1.City_Id WHERE T1.City_Name = 'Mumbai';
[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: List down all of the winning teams' IDs that played in St George's Park. [/INST]
SELECT T2.Match_Winner FROM Venue AS T1 INNER JOIN Match AS T2 ON T1.Venue_Id = T2.Venue_Id WHERE T1.Venue_Name LIKE 'St George%';
[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: Is SuperSport Park located at Centurion? [/INST]
SELECT T2.City_Name FROM Venue AS T1 INNER JOIN City AS T2 ON T1.City_Id = T2.City_Id WHERE T1.Venue_Name LIKE 'St George%';
[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 total winning match for Deccan Chargers. [/INST]
SELECT SUM(T2.Match_Winner) FROM Team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Match_Winner WHERE T1.Team_Name = 'Deccan Chargers';
[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: Count the total venues located in Pune City. [/INST]
SELECT SUM(T1.Venue_Name) FROM Venue AS T1 INNER JOIN City AS T2 ON T1.City_Id = T2.City_Id WHERE T2.City_Name = 'Pune';
[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: Give the player id of the player who was at the non-striker end for the most number of balls in the match 501219. [/INST]
SELECT Ball_Id FROM Ball_by_Ball WHERE Non_Striker = Ball_Id ORDER BY Ball_Id DESC LIMIT 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: Calculate the average runs scored during the first half of all first innings. [/INST]
SELECT CAST(SUM(CASE WHEN 1 < Over_Id AND Over_Id < 25 THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(Runs_Scored) FROM Batsman_Scored WHERE Innings_No = 1;
[INST] Here is a database schema: Extra_Runs : Match_Id [ INTEGER ] Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Extra_Type_Id [ INTEGER ] Extra_Runs.Extra_Type_Id = Extra_Type.Extra_Id Extra_Runs [ INTEGER ] Innings_No [ INTEGER ] Please write me a SQL statement that answers the following question: What are the average extra runs given in the second innings of every match? [/INST]
SELECT AVG(Innings_No) FROM Extra_Runs WHERE 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 Please write me a SQL statement that answers the following question: List the name of the players born between 1970 and 1990 in descending order of age. [/INST]
SELECT Player_Name FROM Player WHERE DOB BETWEEN '1970-01-01' AND '1990-12-31' ORDER BY DOB DESC;
[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: Of the wickets taken in the third overs, how many are without the involvement of fielders? [/INST]
SELECT SUM(CASE WHEN Fielders = '' THEN 1 ELSE 0 END) FROM Wicket_Taken WHERE Over_Id = 3;
[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: From which country does the most umpires are from? How many of them are from the mentioned country? [/INST]
SELECT T2.Country_Id, COUNT(T1.Umpire_Id) FROM Umpire AS T1 INNER JOIN Country AS T2 ON T2.Country_Id = T1.Umpire_Country GROUP BY T2.Country_Id ORDER BY COUNT(T1.Umpire_Id) DESC LIMIT 1;
[INST] Here is a database schema: 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, what percentage are both captain and keeper? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Role_Desc = 'CaptainKeeper' THEN 1 ELSE 0 END) AS REAL) * 100 / TOTAL(T1.Player_Id) FROM Player_Match AS T1 INNER JOIN Rolee AS T2 ON T1.Role_Id = T2.Role_Id;
[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: In the players, how many were out by hit wicket? [/INST]
SELECT Player_Out FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T1.Kind_Out = T2.Out_Id WHERE Out_Name = 'hit wicket';
[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: On average, how many players from each country bat with their right hand? [/INST]
SELECT CAST(SUM(CASE WHEN T1.Batting_hand = 'Right-hand bat' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.Country_Name) FROM Batting_Style AS T1 INNER JOIN Player AS T2 ON T1.Batting_id = T2.Batting_hand;
[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 percentage of players have Legbreak skill? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Bowling_skill = ' Legbreak' THEN 1 ELSE 0 END) AS REAL) * 100 / TOTAL(T1.Player_Id) FROM Player AS T1 INNER JOIN Bowling_Style AS T2 ON T1.Bowling_skill = T2.Bowling_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 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: Which player became the man of the series in the year 2012? Give the name and country of this player. [/INST]
SELECT T2.Player_Name, 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_Year = 2012;
[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: Write the name of the player who was the man of the series more than one time. [/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.Man_of_the_Series > 1;
[INST] Here is a database schema: Country : Country_Id [ INTEGER ] primary_key Country_Name [ TEXT ] Out_Type : Out_Id [ INTEGER ] primary_key Out_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 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 name and country of the players who got more than average catches in ascending order of the number of catches. [/INST]
SELECT T1.Player_Name, T4.Country_Name FROM Player AS T1 INNER JOIN Wicket_Taken AS T2 ON T1.Player_Id = T2.Fielders INNER JOIN Out_Type AS T3 ON T2.Kind_Out = T3.Out_Id INNER JOIN Country AS T4 ON T1.Country_Name = T4.Country_Id GROUP BY T1.Player_Name ORDER BY COUNT(T3.Out_Name) ASC;
[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: What is the difference in the average number of players out by lbw and runout in the matches? [/INST]
SELECT AVG(T1.Player_Out) FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T1.Kind_Out = T2.Out_Id WHERE T2.Out_Name = 'lbw';
[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: Identify by their ID all the overs in which the player with ID 7 was on strike. [/INST]
SELECT DISTINCT Over_Id FROM Ball_by_Ball WHERE Striker = 7;
[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 are older than Gurkeerat Singh player? [/INST]
SELECT SUM(CASE WHEN DOB < '1990-06-29' THEN 1 ELSE 0 END) FROM Player WHERE Player_Name != 'Gurkeerat Singh';
[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: Indicate the name of the most versatile players of the Delhi Daredevils. [/INST]
SELECT T3.Player_Name FROM Player_Match AS T1 INNER JOIN Team AS T2 ON T1.Team_Id = T2.Team_Id INNER JOIN Player AS T3 ON T1.Player_Id = T3.Player_Id WHERE T2.Team_Name = 'Delhi Daredevils' GROUP BY T3.Player_Name ORDER BY COUNT(T1.Role_Id) 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 ] 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 has been chosen the most times for 'Man of the Series'? [/INST]
SELECT T3.Player_Name FROM Season AS T1 INNER JOIN Match AS T2 ON T1.Man_of_the_Series = T2.Man_of_the_Match INNER JOIN Player AS T3 ON T2.Man_of_the_Match = T3.Player_Id GROUP BY T3.Player_Name ORDER BY COUNT(T1.Man_of_the_Series) 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 ] 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: In what year did SP Narine win the Orange Cap? [/INST]
SELECT T4.Season_Year, T4.Orange_Cap 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 INNER JOIN Season AS T4 ON T3.Season_Id = T4.Season_Id WHERE T1.Player_Name = 'SP Narine' GROUP BY T4.Season_Year, T4.Orange_Cap;
[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 ] 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: Which teams have had a player awarded the Purple Cap and another with the Orange Cap in the same season? [/INST]
SELECT T5.Team_Name, T1.Orange_Cap, T1.Purple_Cap FROM Season AS T1 INNER JOIN Match AS T2 ON T1.Season_Id = T2.Season_Id INNER JOIN Player_Match AS T3 ON T2.Match_Id = T3.Match_Id INNER JOIN Player AS T4 ON T3.Player_Id = T4.Player_Id INNER JOIN Team AS T5 ON T3.Team_Id = T5.Team_Id GROUP BY T5.Team_Name, T1.Orange_Cap, T1.Purple_Cap;
[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: List all Zimbabwean players. [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_Id WHERE T2.Country_Name = 'Zimbabwea';
[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: How many players bat with their left hands? [/INST]
SELECT SUM(CASE WHEN T2.Batting_hand = 'Left-hand bat' THEN 1 ELSE 0 END) FROM Player AS T1 INNER JOIN Batting_Style AS T2 ON T1.Batting_hand = T2.Batting_Id;
[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: List the name of all New Zealand umpires. [/INST]
SELECT T1.Umpire_Name FROM Umpire AS T1 INNER JOIN Country AS T2 ON T1.Umpire_Country = T2.Country_Id WHERE T2.Country_Name = 'New Zealand';
[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: In which country do most players have the 'slow left-arm chinaman' bowling style? [/INST]
SELECT T3.Country_Name FROM Bowling_Style AS T1 INNER JOIN Player AS T2 ON T1.Bowling_Id = T2.Bowling_skill INNER JOIN Country AS T3 ON T2.Country_Name = T3.Country_Id WHERE T1.Bowling_skill = 'Slow left-arm chinaman';
[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: In which venue did Kochi Tuskers Kerala play most of their matches? [/INST]
SELECT T1.Venue_Name FROM Venue AS T1 INNER JOIN Match AS T2 ON T1.Venue_Id = T2.Venue_Id INNER JOIN Team AS T3 ON T2.Team_1 = T3.Team_Id WHERE T3.Team_Name = 'Kochi Tuskers Kerala' GROUP BY T1.Venue_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 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 ] 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: In how many games in which the batting team was the Delhi Daredevils were no runs scored? [/INST]
SELECT COUNT(T1.Runs_Scored) FROM Batsman_Scored AS T1 INNER JOIN Ball_by_Ball AS T2 ON T1.Match_Id = T2.Match_Id INNER JOIN Match AS T3 ON T2.Match_Id = T3.Match_Id INNER JOIN Team AS T4 ON T3.Team_1 = T4.Team_Id WHERE T2.Team_Batting = 1 OR T2.Team_Batting = 2 AND T4.Team_Name = 'Delhi Daredevils';
[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: In what percentage of games played at the Dr DY Patil Sports Academy venue did the winning team win by a margin of less than 10? [/INST]
SELECT CAST(COUNT(CASE WHEN T2.Win_Margin < 10 THEN 1 ELSE 0 END) AS REAL) * 100 / TOTAL(T1.Venue_Id) FROM Venue AS T1 INNER JOIN Match AS T2 ON T1.Venue_Id = T2.Venue_Id WHERE T1.Venue_Name = 'Dr DY Patil Sports Academy';
[INST] Here is a database schema: Extra_Type : Extra_Id [ INTEGER ] primary_key Extra_Name [ TEXT ] Extra_Runs : Match_Id [ INTEGER ] Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Extra_Type_Id [ INTEGER ] Extra_Runs.Extra_Type_Id = Extra_Type.Extra_Id Extra_Runs [ INTEGER ] Innings_No [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average number of extra runs made as noballs? [/INST]
SELECT AVG(T1.Extra_Runs) FROM Extra_Runs AS T1 INNER JOIN Extra_Type AS T2 ON T1.Extra_Type_Id = T2.Extra_Id WHERE T2.Extra_Name = 'noballs';
[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 player's ID of the top five players, by descending order, in terms of bowling skill. [/INST]
SELECT Player_Id FROM Player ORDER BY Bowling_skill DESC LIMIT 5;
[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 before 10/16/1975, and have a bowling skill of less than 3? [/INST]
SELECT COUNT(*) FROM Player WHERE DOB < '1975-10-16' AND Bowling_skill < 3;
[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: What is the name of the youngest player? [/INST]
SELECT Player_Name FROM Player ORDER BY DOB DESC LIMIT 1;
[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: Tally the player IDs of "Man of the Series" awardees for the seasons from 2011 to 2015. [/INST]
SELECT Man_of_the_Series FROM Season WHERE 2011 < Season_Year < 2015;
[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: What is the total number of runs scored by the batsmen during the 2nd inning of the match ID 335988? [/INST]
SELECT SUM(Runs_Scored) FROM Batsman_Scored WHERE Match_Id = 335988 AND Innings_No = 2;
[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: Between match nos. 335989 and 337000, how many times did a batsman score more than 3 runs during over no. 1, ball no. 1, and inning no. 1 of the matches? [/INST]
SELECT SUM(CASE WHEN Runs_Scored > 3 THEN 1 ELSE 0 END) FROM Batsman_Scored WHERE 335989 < Match_Id < 337000 AND Innings_No = 1 AND Over_Id = 1 AND Ball_Id = 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: Among the South African players, how many were born before 4/11/1980? [/INST]
SELECT SUM(CASE WHEN T1.DOB < '1980-4-11' THEN 1 ELSE 0 END) FROM Player AS T1 INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_Id WHERE T2.Country_Name = 'South Africa';
[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: Write down the name of players whose bowling skill is Legbreak. [/INST]
SELECT T2.Player_Name FROM Bowling_Style AS T1 INNER JOIN Player AS T2 ON T1.Bowling_Id = T2.Bowling_skill WHERE T1.Bowling_skill = 'Legbreak';
[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 among the players won both "Man of the Series" and "Orange Cap" in the same season? [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Season AS T2 ON T1.Player_Id = T2.Man_of_the_Series = T2.Orange_Cap;
[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: Write down the player names and IDs of the English umpires. [/INST]
SELECT T1.Umpire_Name, T1.Umpire_Id FROM Umpire AS T1 INNER JOIN Country AS T2 ON T1.Umpire_Country = T2.Country_Id WHERE T2.Country_Name = 'England';
[INST] Here is a database schema: Toss_Decision : Toss_Id [ INTEGER ] primary_key Toss_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 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: Calculate the run rate at the end of 17 overs of the match ID 335987 on 4/18/2008. [/INST]
SELECT CAST(COUNT(CASE WHEN T1.Toss_Name = 'bat' THEN T3.Runs_Scored ELSE NULL END) AS REAL) / SUM(CASE WHEN T1.Toss_Name = 'field' THEN 1 ELSE 0 END) FROM Toss_Decision AS T1 INNER JOIN Match AS T2 ON T1.Toss_Id = T2.Toss_Decide INNER JOIN Batsman_Scored AS T3 ON T2.Match_Id = T3.Match_Id WHERE T2.Match_Id = 335987 AND T2.Match_Date = '2008-04-18' GROUP BY T3.Over_Id HAVING COUNT(T1.Toss_Name = 'field') = 17;
[INST] Here is a database schema: Toss_Decision : Toss_Id [ INTEGER ] primary_key Toss_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 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: Compute the run rate at the end of 16 overs of the match ID 335999. Please include the name of the "Man of_the Match". [/INST]
SELECT CAST(COUNT(CASE WHEN T1.Toss_Name = 'bat' THEN T3.Runs_Scored ELSE NULL END) AS REAL) / SUM(CASE WHEN T1.Toss_Name = 'field' THEN 1 ELSE 0 END) FROM Toss_Decision AS T1 INNER JOIN Match AS T2 ON T1.Toss_Id = T2.Toss_Decide INNER JOIN Batsman_Scored AS T3 ON T2.Match_Id = T3.Match_Id WHERE T2.Match_Id = 335987 AND T2.Match_Date = '2008-04-18' GROUP BY T3.Over_Id HAVING COUNT(T1.Toss_Name = 'field') = 16;
[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: Which year do the majority of the players were born? [/INST]
SELECT DOB FROM Player GROUP BY DOB ORDER BY COUNT(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 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 is the player who received the man of the match award during the last match of Season 9? [/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.Season_Id = 9 ORDER BY T2.Match_Date 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: What is the name of the team that won the first ever match? [/INST]
SELECT T1.Team_Name FROM team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Match_Winner WHERE T2.Season_Id = 1 ORDER BY T2.Match_Date 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 ] Please write me a SQL statement that answers the following question: How many cities are in U.A.E? [/INST]
SELECT SUM(CASE WHEN T2.Country_Name = 'U.A.E' 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: 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: List the names of all the umpires from England. [/INST]
SELECT T1.Umpire_Name FROM Umpire AS T1 INNER JOIN country AS T2 ON T2.Country_Id = T1.Umpire_Country WHERE T2.Country_Name = 'England';
[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: How many players bowl in the legbreak style? [/INST]
SELECT T1.Player_Name 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: 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: Which country is umpire TH Wijewardene from? [/INST]
SELECT T2.Country_Name FROM Umpire AS T1 INNER JOIN country AS T2 ON T2.Country_Id = T1.Umpire_Country WHERE T1.Umpire_Name = 'TH Wijewardene';
[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: What are the names of the venues in Abu Dhabi? [/INST]
SELECT T1.Venue_Name FROM Venue AS T1 INNER JOIN City AS T2 ON T1.City_Id = T2.City_Id WHERE T2.City_Name = 'Abu Dhabi';
[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 youngest player from? [/INST]
SELECT T1.Country_Name FROM Country AS T1 INNER JOIN Player AS T2 ON T1.Country_Id = T2.Country_Name ORDER BY T2.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 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 is the youngest player to have won the Purple Cap? [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Season AS T2 ON T1.Player_Id = T2.Purple_Cap ORDER BY T2.Season_Year - SUBSTR(T1.DOB, 1, 4) 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 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 complete name of the venue, city and country where the last match was held. [/INST]
SELECT T1.Venue_Name, T2.City_Name, T3.Country_Name FROM Venue AS T1 INNER JOIN City AS T2 ON T1.City_Id = T2.City_Id INNER JOIN Country AS T3 ON T2.Country_Id = T3.Country_Id INNER JOIN Match AS T4 ON T1.Venue_Id = T4.Venue_Id ORDER BY T4.Match_Date 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: How many overs were there in each innings of match ID "336011"? [/INST]
SELECT SUM(CASE WHEN Innings_No = 1 THEN 1 ELSE 0 END) AS IN1 , SUM(CASE WHEN Innings_No = 2 THEN 1 ELSE 0 END) AS IN2 FROM Ball_by_Ball WHERE Match_Id = 336011;
[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 ball IDs, scores, and innings numbers in the over ID 20 of match ID "335988". [/INST]
SELECT Ball_Id, Runs_Scored, Innings_No FROM Batsman_Scored WHERE Match_Id = 335988 AND Over_Id = 20;
[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 old is Ishan Kishan in 2022? [/INST]
SELECT 2022 - SUBSTR(DOB, 1, 4) FROM Player WHERE Player_Name = 'Ishan Kishan';
[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: Provide the players' names in both teams of the match that was held in June 2014. [/INST]
SELECT T1.Player_Name 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 SUBSTR(T3.Match_Date, 1, 4) = '2014' AND SUBSTR(T3.Match_Date, 7, 1) = '6' LIMIT 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 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 did Mohammad Hafeez play? [/INST]
SELECT SUM(CASE WHEN T2.Player_Name = 'Mohammad Hafeez' THEN 1 ELSE 0 END) FROM Player_Match AS T1 INNER JOIN Player AS T2 ON T1.Player_Id = T2.Player_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: Among the players from South Africa, provide the players' names who were born in 1984. [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_Id WHERE T2.Country_Name = 'South Africa' AND T1.DOB LIKE '1984%';
[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 ratio of players with batting hands of left and right? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Batting_hand = 'Left-hand bat' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.Batting_hand = 'Right-hand bat' THEN 1 ELSE 0 END) FROM Player AS T1 INNER JOIN Batting_Style AS T2 ON T1.Batting_hand = T2.Batting_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: Who is the eldest player and where did he/she come from? [/INST]
SELECT T1.Player_Name, T2.Country_Name FROM Player AS T1 INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_Id ORDER BY T1.DOB LIMIT 1;
[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: Which bowling skills did the players from Zimbabwea have? [/INST]
SELECT T1.Bowling_skill FROM Bowling_Style AS T1 INNER JOIN Player AS T2 ON T1.Bowling_Id = T2.Bowling_skill INNER JOIN Country AS T3 ON T2.Country_Name = T3.Country_Id WHERE T3.Country_Name = 'Zimbabwea';
[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: List the IDs and names of the umpires from New Zealand. [/INST]
SELECT T1.Umpire_Id, T1.Umpire_Name FROM Umpire AS T1 INNER JOIN Country AS T2 ON T1.Umpire_Country = T2.Country_Id WHERE T2.Country_Name = 'New Zealand';
[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 was the captain-keeper of Rising Pune Supergiants? [/INST]
SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Team AS T3 ON T2.Team_Id = T3.Team_Id INNER JOIN Rolee AS T4 ON T2.Role_Id = T4.Role_Id WHERE T3.Team_Name = 'Rising Pune Supergiants' AND T4.Role_Desc = 'CaptainKeeper' GROUP BY T1.Player_Name;
[INST] Here is a database schema: Extra_Type : Extra_Id [ INTEGER ] primary_key Extra_Name [ TEXT ] Extra_Runs : Match_Id [ INTEGER ] Over_Id [ INTEGER ] Ball_Id [ INTEGER ] Extra_Type_Id [ INTEGER ] Extra_Runs.Extra_Type_Id = Extra_Type.Extra_Id Extra_Runs [ INTEGER ] Innings_No [ INTEGER ] Please write me a SQL statement that answers the following question: Provide match ID which had the extra type of penalty. [/INST]
SELECT T1.Match_Id FROM Extra_Runs AS T1 INNER JOIN Extra_Type AS T2 ON T1.Extra_Type_Id = T2.Extra_Id WHERE T2.Extra_Name = 'penalty';
[INST] Here is a database schema: Team : Team_Id [ INTEGER ] primary_key Team_Name [ TEXT ] Win_By : Win_Id [ INTEGER ] primary_key Win_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: Name the teams played in a match which resulted in a tie in 2015. [/INST]
SELECT T1.Team_Name FROM Team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Team_1 OR T1.Team_Id = T2.Team_2 INNER JOIN Win_By AS T3 ON T2.Win_Type = T3.Win_Id WHERE SUBSTR(T2.Match_Date, 1, 4) = '2015' AND T3.Win_Type = 'Tie' LIMIT 1;
[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: Calculate the average players out in the first innings per match. How many of them were out by the leg before wicket? [/INST]
SELECT CAST(COUNT(T1.Player_Out) AS REAL) / COUNT(T1.Match_Id), SUM(CASE WHEN T2.Out_Name = 'lbw' THEN 1 ELSE 0 END) FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T1.Kind_Out = T2.Out_Id WHERE T1.Innings_No = 2;
[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: Count the matches with a total of two innings. [/INST]
SELECT COUNT(Match_Id) FROM Wicket_Taken WHERE innings_no = 2;
[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 is the country of the city named "Rajkot"? [/INST]
SELECT T1.Country_Name FROM Country AS T1 INNER JOIN city AS T2 ON T1.Country_Id = T2.Country_Id WHERE city_name = 'Rajkot';
[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 are the teams that played in a match with the point of winning margin of 38 on April 30, 2009? [/INST]
SELECT T1.Team_Name FROM Team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Team_1 WHERE T2.win_margin = 38 AND match_date = '2009-04-30';
[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: Give the name of the team of T Kohli in the match ID 335989. [/INST]
SELECT T1.Team_Name FROM Team AS T1 INNER JOIN Player_Match AS T2 ON T1.Team_Id = T2.Team_Id INNER JOIN Player AS T3 ON T2.Player_Id = T3.Player_Id WHERE T2.match_id = 335989 AND T3.player_name = 'T Kohli';
[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: How many venues are located at Centurion, South Africa? [/INST]
SELECT COUNT(T1.Venue_name) FROM Venue AS T1 INNER JOIN City AS T2 ON T1.City_Id = T2.City_Id INNER JOIN Country AS T3 ON T2.Country_Id = T3.Country_Id WHERE T3.country_name = 'South Africa' AND T2.city_name = 'Centurion';
[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 played by Royal Challengers Bangalore, what is the match ID of the match with the highest winning margin? [/INST]
SELECT T2.match_id FROM Team AS T1 INNER JOIN Match AS T2 ON T1.team_id = T2.match_winner WHERE T1.team_name = 'Royal Challengers Bangalore' AND T2.match_date LIKE '2012%' ORDER BY T2.win_margin 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 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: How many times did K Goel played as a player only? [/INST]
SELECT COUNT(T1.Match_Id) FROM Player_Match AS T1 INNER JOIN Player AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Rolee AS T3 ON T1.Role_Id = T3.Role_Id WHERE T2.Player_Name = 'K Goel' AND T3.Role_Id = 3;
[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: What is the average winning margin of the matches held in Newlands? [/INST]
SELECT AVG(T1.win_margin) FROM Match AS T1 INNER JOIN Venue AS T2 ON T1.venue_id = T2.venue_id WHERE T2.venue_name = 'Newlands';
[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 losing team's name in the match ID 336039. [/INST]
SELECT Team_Name FROM Team WHERE Team_Id = ( SELECT CASE WHEN Team_1 = Match_Winner THEN Team_2 ELSE Team_1 END FROM Match WHERE match_id = 336039 );
[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: What is the venue for the match ID 829768? [/INST]
SELECT T1.Venue_Name FROM Venue AS T1 INNER JOIN Match AS T2 ON T1.venue_id = T2.venue_id WHERE T2.match_id = 829768;
[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 second team's name in the match with the lowest winning margin? [/INST]
SELECT T1.team_name FROM Team AS T1 INNER JOIN Match AS T2 ON T1.team_id = T2.team_2 ORDER BY T2.win_margin 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: Among the matches in 2013, what is the percentage of winning of the team "Mumbai Indians"? [/INST]
SELECT CAST(SUM(CASE WHEN T2.Match_Winner = 7 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.Match_Winner) FROM Team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Match_Winner WHERE T2.Match_Date LIKE '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 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 difference between the number of matches where SC Ganguly played as a Captain and those matches where he played other roles? [/INST]
SELECT SUM(CASE WHEN T3.Role_Id = 1 THEN 1 ELSE 0 END) - SUM(CASE WHEN T3.Role_Id > 1 THEN 1 ELSE 0 END) FROM Player_Match AS T1 INNER JOIN Player AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Rolee AS T3 ON T1.Role_Id = T3.Role_Id WHERE T2.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 Please write me a SQL statement that answers the following question: How many players have the bowling skill greater than 2? [/INST]
SELECT COUNT(Player_Name) FROM Player WHERE Bowling_skill > 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 Please write me a SQL statement that answers the following question: How many players were born in 1970? [/INST]
SELECT COUNT(Player_Name) FROM Player WHERE DOB LIKE '1970%';
[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 80s and have bowling skill of 2? [/INST]
SELECT COUNT(Player_Name) FROM Player WHERE DOB LIKE '198%' AND Bowling_skill = 2;
[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: How many matches are there in April, 2008? [/INST]
SELECT COUNT(Match_Id) FROM Match WHERE Match_date LIKE '2008-04%';