Database: game_injury

CREATE TABLE "stadium" (
"id" int,
"name" text,
"Home_Games" int,
"Average_Attendance" real,
"Total_Attendance" real,
"Capacity_Percentage" real,
primary key ("id")
);
CREATE TABLE "game" (
"stadium_id" int,
"id" int,
"Season" int,
"Date" text,
"Home_team" text,
"Away_team" text,
"Score" text,
"Competition" text,
primary key ("id"),
foreign key ("stadium_id") references `stadium`("id")
);
CREATE TABLE "injury_accident" (
"game_id" int,
"id" int,
"Player" text,
"Injury" text,
"Number_of_matches" text,
"Source" text,
primary key ("id"),
foreign key ("game_id") references `game`("id")
);

Question: How many games are held after season 2007?
SQL: SELECT count(*) FROM game WHERE season  >  2007

Question: List the dates of games by the home team name in descending order.
SQL: SELECT Date FROM game ORDER BY home_team DESC

Question: List the season, home team, away team of all the games.
SQL: SELECT season ,  home_team ,  away_team FROM game

Question: What are the maximum, minimum and average home games each stadium held?
SQL: SELECT max(home_games) ,  min(home_games) ,  avg(home_games) FROM stadium

Question: What is the average attendance of stadiums with capacity percentage higher than 100%?
SQL: SELECT average_attendance FROM stadium WHERE capacity_percentage  >  100

Question: What are the player name, number of matches, and information source for players who do not suffer from injury of 'Knee problem'?
SQL: SELECT player ,  number_of_matches ,  SOURCE FROM injury_accident WHERE injury != 'Knee problem'

Question: What is the season of the game which causes the player 'Walter Samuel' to get injured?
SQL: SELECT T1.season FROM game AS T1 JOIN injury_accident AS T2 ON T1.id  =  T2.game_id WHERE T2.player  =  'Walter Samuel'

Question: What are the ids, scores, and dates of the games which caused at least two injury accidents?
SQL: SELECT T1.id ,  T1.score ,  T1.date FROM game AS T1 JOIN injury_accident AS T2 ON T2.game_id  =  T1.id GROUP BY T1.id HAVING count(*)  >=  2

Question: What are the id and name of the stadium where the most injury accidents happened?
SQL: SELECT T1.id ,  T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id JOIN injury_accident AS T3 ON T2.id  =  T3.game_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1

Question: Find the id and name of the stadium where the largest number of injury accidents occurred.
SQL: SELECT T1.id ,  T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id JOIN injury_accident AS T3 ON T2.id  =  T3.game_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1

Question: In which season and which stadium did any player have an injury of 'Foot injury' or 'Knee problem'?
SQL: SELECT T1.season ,  T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.injury  =  'Foot injury' OR T3.injury  =  'Knee problem'

Question: How many different kinds of information sources are there for injury accidents?
SQL: SELECT count(DISTINCT SOURCE) FROM injury_accident

Question: How many games are free of injury accidents?
SQL: SELECT count(*) FROM game WHERE id NOT IN ( SELECT game_id FROM injury_accident )

Question: How many distinct kinds of injuries happened after season 2010?
SQL: SELECT count(DISTINCT T1.injury) FROM injury_accident AS T1 JOIN game AS T2 ON T1.game_id  =  T2.id WHERE T2.season  >  2010

Question: List the name of the stadium where both the player 'Walter Samuel' and the player 'Thiago Motta' got injured.
SQL: SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Walter Samuel' INTERSECT SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Thiago Motta'

Question: Show the name, average attendance, total attendance for stadiums where no accidents happened.
SQL: SELECT name ,  average_attendance ,  total_attendance FROM stadium EXCEPT SELECT T2.name ,  T2.average_attendance ,  T2.total_attendance FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id

Question: Which stadium name contains the substring "Bank"?
SQL: SELECT name FROM stadium WHERE name LIKE "%Bank%"

Question: How many games has each stadium held?
SQL: SELECT T1.id ,  count(*) FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id GROUP BY T1.id

Question: For each injury accident, find the date of the game and the name of the injured player in the game, and sort the results in descending order of game season.
SQL: SELECT T1.date ,  T2.player FROM game AS T1 JOIN injury_accident AS T2 ON T1.id  =  T2.game_id ORDER BY T1.season DESC