football data
Last updated
Last updated
This tutorial introducesJOIN
which allows you to use data from two or more tables. The tables contain all matches and goals from UEFA EURO 2012 Football Championship in Poland and Ukraine.
The data is available (mysql format) athttp://sqlzoo.net/euro2012.sql
id
mdate
stadium
team1
team2
1001
8 June 2012
National Stadium, Warsaw
POL
GRE
1002
8 June 2012
Stadion Miejski (Wroclaw)
RUS
CZE
1003
12 June 2012
Stadion Miejski (Wroclaw)
GRE
CZE
1004
12 June 2012
National Stadium, Warsaw
POL
RUS
...
matchid
teamid
player
gtime
1001
POL
Robert Lewandowski
17
1001
GRE
Dimitris Salpingidis
51
1002
RUS
Alan Dzagoev
15
1002
RUS
Roman Pavlyuchenko
82
...
id
teamname
coach
POL
Poland
Franciszek Smuda
RUS
Russia
Dick Advocaat
CZE
Czech Republic
Michal Bilek
GRE
Greece
Fernando Santos
...
Show the matchid and player name for all goals scored by Germany. To identify German players, check for:teamid = 'GER'
Show id, stadium, team1, team2 for just game 1012
show the player, teamid, stadium and mdate for every German goal.
Show the team1, team2 and player for every goal scored by a player called Mario player LIKE 'Mario%'
Showplayer
,teamid
,coach
,gtime
for all goals scored in the first 10 minutesgtime <= 10
List the the dates of the matches and the name of the team in which 'Fernando Santos' was the team1 coach.
List the player for every goal scored in a game where the stadium was 'National Stadium, Warsaw'
show the name of all players who scored a goal against Germany.
Show teamname and the total number of goals scored.
Show the stadium and the number of goals scored in each stadium.
For every match involving 'POL', show the matchid, date and the number of goals scored.
For every match where 'GER' scored, show matchid, match date and the number of goals scored by 'GER'
List every match with the goals scored by each team as shown. This will use "CASE WHEN" which has not been explained in any previous exercises.
mdate
team1
score1
team2
score2
1 July 2012
ESP
4
ITA
0
10 June 2012
ESP
1
ITA
1
10 June 2012
IRL
1
CRO
3
...
Notice in the query given every goal is listed. If it was a team1 goal then a 1 appears in score1, otherwise there is a 0. You could SUM this column to get a count of the goals scored by team1.Sort your result by mdate, matchid, team1 and team2.
To get each score, go to goal table, filter useful rows and count the number.