Exercise - Soccer Database
Exercise - Soccer Database
DATABASE
EXERCISE
Description of tables:
Table 1: soccer_country
country_id – this is a unique ID for each country
country_abbr – this is the sort’s name of each country
country_name – this is the name of each country
Table 2: soccer_city
city_id – this is a unique ID for each city
city – this is the name of the city
country_id – this is the ID of the country where the cities are located
and only those countries will be available which are in
soccer_country table
Table 3: soccer_venue
venue_id – this is a unique ID for each venue
venue_name – this is the name of the venue
city_id – this is the ID of the city where the venue is located and only
those cities will be available which are in the soccer_city table
aud_capicity – this is the capacity of audience for each venue
Table 4: soccer_team
team_id – this is the ID for each team. Each teams are representing
to a country which are referencing the country_id column of
soccer_country table
team_group – the name of the group in which the team belongs
match_played – how many matches a team played in group stage
won – how many matches a team won
draw – how many matches a team draws
lost – how many matches a team lose
goal_for – how many goals a team conceded
goal_agnst – how many goals a team scored
goal_diff – the difference of goal scored and goal conceded
points – how many points a team achieved from their group stage
matches
group_position – in which position a team finished their group stage
matches
Table 5: playing_position
position_id – this is a unique ID for each position where a player
played
position_desc – this is the name of the position where a player
played
Table 6: player_mast
player_id – this is a unique ID for each player
team_id – this is the team where a player played, and only those
teams which referencing the country_id column of the table
soccer_country
jersey_no – the number which labelled on the jersey for each player
player_name – name of the player
posi_to_play – the position where a player played, and the positions
are referencing the position_id column of playing_position table
dt_of_bir – date of birth of each player
age – approximate age at the time of playing the tournament
playing_club – the name of the club for which a player was playing
at the time of the tournament
Table 7: referee_mast
referee_id – this is the unique ID for each referee
referee_name – name of the referee
country_id – the country, where a referee belongs and the countries are
those which referencing the country_id column of soccer_country table
Table 8: match_mast
match_no – this if the unique ID for a match
play_stage – this indicates that in which stage a match is going on, i.e.
G for Group stage, R for Round of 16 stage, Q for Quarter final stage, S
for Semi Final stage, and F for Final
play_date – date of the match played
results – the result of the match, either win or draw
decided_by – how the result of the match has been decided, either N
for by normally or P for by penalty shootout
goal_score – score for a match
venue_id – the venue where the match played and the venue will be
one of the venue referencing the venue_id column of soccer_venue
table
referee_id – ID of the referee who is selected for the match which
referencing the referee_id column of referee_mast table
audence – number of audience appears to watch the match
plr_of_match – this is the player who awarded the player of a particular
match and who is selected a 23 men playing squad for a team which
referencing the player_id column of player_mast table
stop1_sec – how many stoppage time ( in second) have been added for
the 1st half of play
stop2_sec – how many stoppage time ( in second) have been added for
the 2nd half of play
Table 9: coach_mast
coach_id – this is the unique ID for a coach
coach_name – this is the name of the coach
QUERIES TO SOLVE
1. Write a SQL query to count the number of venues for EURO cup 2016.
Return number of venues.
Ans SELECT COUNT(*) AS number_of_venues FROM soccer_venue;
2. Write a SQL query to count the number of countries participated in the
EURO cup 2016.
Ans SELECT COUNT(DISTINCT team_id) AS number_of_countries FROM player_mast;
3. Write a SQL query to find the number of goals scored in EURO cup
2016 within normal play schedule.
Ans SELECT count(goal_score) from match_details;
4. Write a SQL query to find the number of matches ended with a result.
Ans SELECT COUNT(*) FROM match_mast WHERE results='WIN';
5. Write a SQL query to find the number of matches ended with draws.
Ans SELECT COUNT(*) FROM match_mast WHERE results='DRAW';
6. Write a SQL query to find the date when Football EURO cup 2016
begins.
Ans SELECT play_date from match_mast where match_no =1;
7. Write a SQL query to find the number of self-goals scored in EURO cup
2016.
ANs SELECT count(*) from goal_details where goal_type='o';
8. Write a SQL query to count the number of matches ended with a
results in-group stage.
AnsSELECT count(*) from match_mast where results='win' and play_stage ='G';
9. Write a SQL query to find the number of matches got a result by
penalty shootout.
Ans SELECT count(DISTINCT(match_no))FROM penalty_shootout;
10. Write a SQL query to find the number of matches decided by
penalties in the Round 16.
Ans SELECT count(*) from match_mast where decided_by='p' and play_stage='R';
11. Write a SQL query to find the number of goal scored in every match
within normal play schedule. Sort the result-set on match number.
Return match number, number of goal scored.
Ans
SELECT match_no, COUNT(*) FROM goal_details GROUP BY match_no ORDER BY match_n
o;
12. Write a SQL query to find those matches where no stoppage time
added in the first half of play. Return match no, date of play, and goal
scored.
Ans SELECT match_no,play_date,goal_score from match_mast where stop1_sec=0;
13. Write a SQL query to count the number of matches ending with a
goalless draw in-group stage of play. Return number of matches.
Ans
SELECT COUNT(DISTINCT(match_no)) from match_details where win_lose='D' and goal_s
core='0' and play_stage='G';
14. Write a SQL query to count the number of matches ending with only
one goal win, except those matches, which was decided by penalty
shoot-out. Return number of matches.
Ans SELECT count(goal_score) FROM match_details WHERE win_lose='W' AND decided_by <> 'P' AND goal_score=1;
15. Write a SQL query to count the number of players replaced in the
tournament. Return number of players as "Player Replaced".
Ans SELECT count(*) as "player replaced" from player_in_out where in_out='I';
16. Write a SQL query to count the total number of players replaced
within normal time of play. Return number of players as "Player
Replaced".
Ans SELECT COUNT(*) as "Player
Replaced" FROM player_in_out WHERE in_out='I' AND play_schedule='NG';
17. Write a SQL query to count the number of players replaced in the
stoppage time. Return number of players as "Player Replaced".
AnsSELECT count(*) AS "Player
Replaced" FROM player_in_out WHERE in_out='I' AND play_schedule='ST';
18. Write a SQL query to count the total number of players replaced in
the first half of play. Return number of players as "Player Replaced".
Ans SELECT count(*) AS "Player
Replaced" FROM player_in_out WHERE in_out='I' AND play_schedule='NT' and play_half=
1;
19. Write a SQL query to count the total number of goalless draws have
there in the entire tournament. Return number of goalless draws.
Ans
SELECT COUNT(DISTINCT match_no) FROM match_details WHERE win_lose='D' AND goal_
score=0;
20. Write a SQL query to count the total number of players replaced in
the extra time of play.
Ans SELECT count(*) as "Player
Replaced" from player_in_out where in_out='I' and play_schedule='ET';
21. Write a SQL query to count the number of substitute happened in
various stage of play for the entire Tournament. Sort the result-set in
ascending order by play-half, play-schedule and number of substitute
happened. Return play-half, play-schedule, number of substitute
happened.
Ans
SELECT play_half,play_schedule from player_in_out where play_schedule='ST' order
by play_half;
22. Write a SQL query to count the number of shots taken in penalty
shootout matches. Number of shots as "Number of Penalty Kicks"
Ans. SELECT count(*) as"Number of Penalty kicks" from penalty_shootout;
23. Write a SQL query to count the number of shots scored goal in
penalty shootout matches. Return number of shots scored goal as
"Goal Scored by Penalty Kicks".
AnsSELECT count(*) as "Goal Scored by Penalty
Kicks"from penalty_shootout where score_goal='Y';
24. Write a SQL query to count the number of shots missed or saved in
penalty shootout matches. Return number of shots missed as "Goal
missed or saved by Penalty Kicks".
Ans SELECT count(*) as "Goal missed or saved by Penalty
Kicks"from penalty_shootout where score_goal='N';
25. Write a SQL query to find the players with shot number they taken
in penalty shootout matches. Return match_no, Team, player_name,
jersey_no, score_goal, kick_no.
AnsSELECT c.match_no,a.country_name AS "Team", b.player_name, b.jersey_no, c.score
_goal ,c.kick_no FROM soccer_country a, penalty_shootout c, player_mast b WHERE c.tea
m_id=a.country_id AND c.player_id=b.player_id;
26. Write a SQL query to count the number of penalty shots taken by
the teams. Return country name, number of shots as "Number of
Shots".
Ans SELECT a.country_name, COUNT(*) as "Number of
Shots" FROM soccer_country a, penalty_shootout b WHERE b.team_id = a.country_id GRO
UP BY a.country_name;
27. Write a SQL query to count the number of booking happened in
each half of play within normal play schedule. Return play_half,
play_schedule, number of booking happened.
Ans
SELECT play_half,play_schedule from player_booked where play_schedule='NT' group by
play_half,play_schedule;
28. Write a SQL query to count the number of booking happened in
stoppage time.
ANS SELECT * from player_booked where play_schedule='ST';
29. Write a SQL query to count the number of booking happened in
extra time.
Ans SELECT * from player_booked where play_schedule='ET';
30. Write a SQL query to find the teams played the first match of EURO
cup 2016. Return match number, country name.
Ans SELECT match_no, country_name FROM match_details a,
soccer_country b WHERE a.team_id = b.country_id
AND a.match_no = 1;
31. Write a SQL query to find the winner of EURO cup 2016. Return
country name.
Ans
SELECT country_name as Team FROM soccer_country WHERE country_id IN ( SELECT tea
m_id FROM match_details WHERE play_stage='F' and win_lose='W');
32. Write a SQL query to find the most watched match in the world.
Return match_no, play_stage, goal_score, audience.
AnsSELECT match_no, play_stage, goal_score, audence FROM match_mast WHERE aude
nce=( SELECT max(audence) FROM match_mast);
33. Write a SQL query to find the match number in which Germany
played against Poland. Group the result set on match number. Return
match number.
ANSSELECT match_no FROM match_details WHERE team_id = ( SELECT country_id FROM
soccer_country WHERE country_name = 'Germany' ) OR team_id = ( SELECT country_id F
ROM soccer_country WHERE country_name = 'Poland' ) GROUP BY match_no HAVING CO
UNT(DISTINCT team_id) = 2;
34. Write a SQL query to find the result of the match where Portugal
played against Hungary. Return match_no, play_stage, play_date,
results, goal_score.
AnsSELECT country_name FROM soccer_country WHERE country_id=( SELECT team_id F
ROM match_details WHERE play_stage='F' AND team_id<>( SELECT country_id FROM so
ccer_country WHERE country_name='Portugal'));
35. Write a SQL query to find those players who scored number of goals
in every match. Group the result set on match number, country name
and player name. Sort the result-set in ascending order by match
number. Return match number, country name, player name and
number of matches.
AnsvSELECT gd.match_no, sc.country_name, pm.player_name, COUNT(gd.match_no) FRO
M goal_details gd JOIN soccer_country sc ON gd.team_id = sc.country_id JOIN player_mas
t pm ON gd.player_id = pm.player_id GROUP BY gd.match_no, sc.country_name, pm.play
er_name ORDER BY gd.match_no;
36. Write a SQL query to find the highest audience match. Return
country name of the teams.
AnsSELECT DISTINCT sc.country_name FROM soccer_country sc JOIN goal_
details gd ON sc.country_id = gd.team_id WHERE gd.match_no IN ( SELEC
T match_no FROM match_mast WHERE audence = ( SELECT MAX(audence
) FROM match_mast ) );
37. Write a SQL query to find the second-highest stoppage time, which
had been added, in the second half of play.
Ans
SELECT max(stop2_sec) from match_mast where stop2_sec<>( select max(stop2_sec) fr
om match_mast);
38. Write a SQL query to find the teams played the match where second
highest stoppage time had been added in second half of play. Return
country name of the teams.
AnsSELECT country_name FROM soccer_country WHERE country_id IN (SELECT team_id
FROM match_details WHERE match_no IN ( SELECT match_no FROM match_mast WHERE
stop2_sec = ( SELECT max(stop2_sec) FROM match_mast WHERE stop2_sec <> ( SELECT
max(stop2_sec) FROM match_mast ) ) ) );
39. Write a SQL query to find the teams played the match where second
highest stoppage time had been added in second half of play. Return
match_no, play_date, stop2_sec.
AnsSELECT sc.country_name FROM soccer_country sc JOIN match_details md ON sc.coun
try_id = md.team_id WHERE md.match_no IN ( SELECT mm.match_no FROM match_mast
mm WHERE mm.stop2_sec = ( SELECT MAX(stop2_sec) FROM match_mast WHERE stop2
_sec <> ( SELECT MAX(stop2_sec) FROM match_mast ) ) );
40. Write a SQL query to find the team, which was defeated by Portugal
in EURO cup 2016 final. Return the country name of the team.
AnsSELECT sc.country_name FROM soccer_country sc JOIN match_details md ON sc.coun
try_id = md.team_id WHERE md.play_stage = 'F' AND md.team_id <> ( SELECT country_i
d FROM soccer_country WHERE country_name = 'Portugal' );
41. Write a SQL query to find the club, which supplied the most number
of players to the 2016-EURO cup. Return club name, number of
players.
Ans
42. Write a SQL query to find the player who scored the first penalty of
the tournament. Return player name and Jersey number.
AnsSELECT pm.player_name,pm.jersey_no from player_mast pm join goal_details gd on
pm.player_id=gd.player_id where gd.goal_type='P' and gd.match_no =(select min(match
_no) from goal_details where goal_type='P' and play_stage='G');
43. Write a SQL query to find the player who scored the first penalty in
the tournament. Return player name, Jersey number and country
name.
Ans
44. Write a SQL query to find the goalkeeper for Italy in penalty
shootout against Germany in Football EURO cup 2016. Return
goalkeeper name.
AnsSELECT pm.player_name FROM player_mast pm JOIN penalty_gk pg O
N pm.player_id = pg.player_gk WHERE pg.match_no = ( SELECT pg2.matc
h_no FROM penalty_gk pg2 JOIN soccer_country sc ON pg2.team_id = sc.c
ountry_id WHERE sc.country_name IN ('Italy', 'Germany') GROUP BY pg2.m
atch_no HAVING COUNT(DISTINCT sc.country_id) = 2 ) AND pg.team_id = (
SELECT country_id FROM soccer_country WHERE country_name = 'Italy' );
45. Write a SQL query to find the number of goals Germany scored at
the tournament.
AnsSELECT COUNT(player_id) FROM goal_details WHERE team_id=(SELEC
T country_id FROM soccer_country WHERE country_name='Germany');
46. Write a SQL query to find the players who were the goalkeepers of
England squad in 2016-EURO cup. Return player name, jersey number,
club name.
AnsSELECT player_name, jersey_no, playing_club FROM player_mast WHERE posi_to_pla
y='GK' AND
team_id=(SELECT country_id FROM soccer_country WHERE country_name='England'
);
47. Write a SQL query to find the players under contract to Liverpool
were in the Squad of England in 2016-EURO cup. Return player name,
jersey number, and position to play, age.
AnsSELECT player_name, jersey_no, posi_to_play, age FROM player_mast WHERE
playing_club = 'Liverpool' AND team_id = ( SELECT country_id FROM soccer_country
WHERE country_name = 'England');
48. Write a SQL query to find the players who scored the last goal in the
2nd semi-final, i.e., 50th match in EURO cup 2016. Return player name,
goal time, goal half, country name.
49. Write a SQL query to find the captain of the EURO cup 2016 winning
team from Portugal. Return the captain’s name.
AnsSELECT player_name FROM player_mast WHERE player_id IN ( SELECT player_captai
n FROM match_captain WHERE team_id=( SELECT team_id FROM match_details WHERE p
lay_stage='F' AND win_lose='W' ) );
50. Write a SQL query to count the number of players played for
'France’ in the final. Return 'Number of players shared fields'.
Ans SELECT COUNT(*)+11 as "Number of players shared
fields" FROM player_in_out WHERE match_no=( SELECT match_no FROM match_mast
WHERE play_stage='F') AND in_out='I' AND team_id=( SELECT country_id FROM soccer_c
ountry
WHERE country_name='France');
51. Write a SQL query to find the Germany goalkeeper who didn't
concede any goal in their group stage matches. Return goalkeeper
name, jersey number.
ANSSELECT player_name,jersey_no FROM player_mast WHERE player_id IN( SELECT play
er_gk FROM match_details WHERE play_stage='G' and team_id IN( SELECT country_id FR
OM soccer_country WHERE country_name='Germany'));
52. Write a SQL query to find the runners-up in Football EURO cup 2016.
Return country name.
AnsSELECT country_name FROM soccer_country WHERE country_id=( SELECT team_id F
ROM
match_details WHERE play_stage='F' AND win_lose='L' AND team_id<>( SELECT country
_id FROM
soccer_country WHERE country_name='Portugal'));
53. Write a SQL query to find the maximum penalty shots taken by the
teams. Return country name, maximum penalty shots.
Ans
54. Write a SQL query to find the maximum number of penalty shots
taken by the players. Return country name, player name, jersey
number and number of penalty shots.
Ans
55. Write a SQL query to find those matches where the highest number
of penalty shots taken.
AnsSELECT match_no, COUNT(*) shots FROM penalty_shootout GROUP BY match_no HAV
ING COUNT(*)= (SELECT MAX(shots) FROM (SELECT COUNT(*) shots FROM penalty_shoot
out GROUP BY match_no) inner_result);
56. Write a SQL query to find the match number where highest number
of penalty shots had been taken. Return match number, country name.
AnsSELECT match_no, COUNT(*) shots FROM penalty_shootout GROUP BY match_no HAV
ING COUNT(*)= (SELECT MAX(shots) FROM (SELECT COUNT(*) shots FROM penalty_shoot
out GROUP BY match_no) inner_result);
57. Write a SQL query to find the player of 'Portugal' who taken the
seventh kick against 'Poland'. Return match number, player name and
kick number.
AnsSELECT a.match_no, b.player_name, a.kick_no FROM penalty_shootout a, player_mas
t b WHERE
a. player_id=b.player_id AND kick_no=7 AND match_no= (SELECT match_no
FROM penalty_shootout
WHERE team_id = (SELECT country_id FROM soccer_country WHERE country_name='Por
tugal' )
GROUP BY match_no) GROUP BY match_no, player_name, kick_id;
58. Write a SQL query to find the stage of match where penalty kick
number 23 had been taken. Return match number, play_stage.
AnsSELECT match_no, play_stage FROM match_mast WHERE match_no= (SELECT match
_no FROM
penalty_shootout WHERE kick_id=23);
59. Write a SQL query to find the venues where penalty shoot-out
matches played. Return venue name.
Ans
SELECT venue_name from soccer_venue where venue_id in(select venue_id from match_
mast
where match_no in(SELECT DISTINCT match_no from penalty_shootout));
60. Write a SQL query to find the date when penalty shootout matches
played. Return playing date.
65. Write a SQL query to find the highest individual scorer in EURO cup
2016. Return player name, country name and highest individual scorer.
AnsSELECT player_name,country_name,count(player_name) FROM goal_details gd JOIN
player_mast pm
ON gd.player_id =pm.player_id JOIN soccer_country sc ON pm.team_id = sc.country_id G
ROUP BY
country_name,player_name HAVING COUNT(player_name) >= ALL (SELECT COUNT(playe
r_name) FROM
goal_details gd JOIN player_mast pm ON gd.player_id =pm.player_id
JOIN soccer_country sc ON pm.team_id =
sc.country_id GROUP BY country_name,player_name);
66. Write a SQL query to find the scorer in the final of EURO cup 2016.
Return player name, jersey number and country name.
Ans
SELECT player_name,jersey_no,country_name FROM goal_details a JOIN player_mast b O
N
a.player_id=b.player_id JOIN soccer_country c ON a.team_id=c.country_id WHERE play_st
age='F';
67. Write a SQL query to find the country where Football EURO cup
2016 held. Return country name.
AnsSELECT country_name FROM soccer_country a JOIN soccer_city b ON a.country_id=b.
country_id JOIN soccer_venue c ON b.city_id=c.city_id GROUP BY country_name;
68. Write a SQL query to find the player who scored first goal of EURO
cup 2016. Return player_name, jersey_no, country_name, goal_time,
play_stage, goal_schedule, goal_half.
AnsSELECT a.player_name,a.jersey_no,b.country_name,c.goal_time, c.play_stage,c.goal_
schedule, c.goal_half FROM player_mast a JOIN soccer_country b ON a.team_id=b.countr
y_id JOIN goal_details c ON c.player_id=a.player_id WHERE goal_id=1;
69. Write a SQL query to find the referee who managed the opening
match. Return referee name, country name.
AnsSELECT b.referee_name, c.country_name FROM match_mast a NATURAL JOIN referee
_mast b
NATURAL JOIN soccer_country c WHERE match_no=1;
70. Write a SQL query to find the referee who managed the final match.
Return referee name, country name.
Ans ]SELECT b.referee_name, c.country_name FROM match_mast a NATURAL JOIN refer
ee_mast b NATURAL JOIN soccer_country c WHERE play_stage='F';
71. Write a SQL query to find the referee who assisted the referee in the
opening match. Return associated referee name, country name.
ANSSELECT a.ass_ref_name, b.country_name FROM asst_referee_mast a JOIN soccer_cou
ntry b ON a.country_id = b.country_id JOIN match_details c ON a.ass_ref_id = c.ass_ref W
HERE match_no = 1;
72. Write a SQL query to find the referee who assisted the referee in the
final match. Return associated referee name, country name.
ANsSELECT ass_ref_name, country_name FROM asst_referee_mast a JOIN soccer_country
b ON a.country_id=b.country_id JOIN match_details c ON a.ass_ref_id=c.ass_ref WHERE p
lay_stage='F';
73. Write a SQL query to find the city where the opening match of EURO
cup 2016 played. Return venue name, city.
AnsSELECT a.venue_name, b.city FROM soccer_venue a JOIN soccer_city b ON a.city_id=
b.city_id JOIN
match_mast c ON a.venue_id=c.venue_id WHERE match_no=1;
74. Write a SQL query to find the stadium hosted the final match of
EURO cup 2016. Return venue_name, city, aud_capacity, audience.
ANSSELECT a.venue_name, b.city, a.aud_capacity, c.audence FROM soccer_venue a JOIN
soccer_city b ON a.city_id=b.city_id JOIN match_mast c ON a.venue_id=c.venue_id WHER
E play_stage='F';
75. Write a SQL query to count the number of matches played in each
venue. Sort the result-set on venue name. Return Venue name, city,
and number of matches.
AnsSELECT a.venue_name, b.city, count(c.match_no) FROM soccer_venue a JOIN soccer_c
ity b ON
a.city_id=b.city_id JOIN match_mast c ON a.venue_id=c.venue_id GROUP BY venue_name
,city ORDER BY
venue_name;
76. Write a SQL query to find the player who was the first player to be
sent off at the tournament EURO cup 2016. Return match Number,
country name and player name
Ans
77. Write a SQL query to find those teams that scored only one goal to
the tournament. Return country_name as "Team", team in the group,
goal_for.
Ans ]SELECT country_name as "Team" ,team_group, goal_for FROM soccer_team JOIN so
ccer_country ON soccer_team.team_id=soccer_country.country_id AND goal_for=1;
78. Write a SQL query to count the yellow cards received by each
country. Return country name and number of yellow cards.
AnsSELECT country_name, COUNT(*) FROM soccer_country JOIN player_booked ON
soccer_country.country_id=player_booked.team_id GROUP BY country_name ORDER BY
COUNT(*) DESC;
79. Write a SQL query to count number of goals that has seen. Return
venue name and number of goals.
AnsSELECT match_details.match_no, soccer_country.country_name FROM match_mast J
OIN match_details ON match_mast.match_no=match_details.match_no JOIN soccer_count
ry ON match_details.team_id=soccer_country.country_id WHERE stop1_sec=0;
80. Write a SQL query to find the match where no stoppage time added
in first half of play. Return match number, country name.
Ans
81. Write a SQL query to find the team(s) who conceded the most goals
in EURO cup 2016. Return country name, team group and match
played.
Ans
82. Write a SQL query to find those matches where highest stoppage
time added in 2nd half of play. Return match number, country name,
stoppage time (sec.).
Ans
83. Write a SQL query to find those matches ending with a goalless
draw in-group stage of play. Return match number, country name.
AnsSELECT match_no,country_name FROM match_details JOIN soccer_country ON soccer
_country.country_id=match_details.team_id WHERE win_lose='D' AND goal_score=0 AND
play_stage='G' ORDER BY match_no;
84. Write a SQL query to find those match(s) where the 2nd highest
stoppage time had been added in the second half of play. Return
match number, country name and stoppage time.
Ans
85. Write a SQL query to find the number of matches played a player as
a goalkeeper for his team. Return country name, player name, number
of matches played as a goalkeeper.
AnsSELECT b.country_name,c.player_name,COUNT(a.player_gk) count_gk FROM match_
details a JOIN soccer_country b ON a.team_id=b.country_id JOIN player_mast c ON a.play
er_gk=c.player_id GROUP BY b.country_name,c.player_name ORDER BY country_name,pl
ayer_name,count_gk;
86. Write a SQL query to find the venue that has seen the most number
of goals. Return venue name, number of goals.
Ans
87. Write a SQL query to find the oldest player appeared in a EURO cup
2016 match. Return country name, player name, jersey number and
age.
AnsSELECT a.country_name,b.player_name,b.jersey_no,b.age FROM soccer_country a JOI
N player_mast b ON a.country_id=b.team_id WHERE b.age IN(SELECT MAX(age) FROM pl
ayer_mast);
88. Write a SQL query to find those two teams, scored three goals in a
single game in this tournament. Return match number and country
name.
ANSSELECT a.country_name as Team , b.team_group,b.match_played, b.goal_agnst, b.g
roup_position
FROM soccer_country a JOIN soccer_team b ON a.country_id=b.team_id WHERE goal_ag
nst=4 AND group_position=4 ORDER BY team_group;
89. Write a SQL query to find those teams that finished bottom of their
respective groups after conceding four times in three games. Return
country name, team group and match played.
Ans
90. Write a SQL query to find those players, who contracted to ‘Lyon’
club and participated in the EURO cup 2016 Finals. Return player
name, jersey_no, position to play, age, and country name.
ANs
91. Write a SQL query to find the final four teams in the tournament.
Return country name.
AnsSELECT country_name FROM match_details a JOIN soccer_country b ON a.team_id=b
.country_id
WHERE play_stage='S';
92. Write a SQL query to find the captains of the top four teams that
participated in the semi-finals (match 48 and 49) in the tournament.
Return country name, player name, jersey number and position to play.
ANSSELECT country_name, player_name, jersey_no, posi_to_play FROM match_captain a
JOIN soccer_country b ON a.team_id=b.country_id JOIN player_mast c ON a.player_captai
n=c.player_id WHERE match_no IN(48,49);
93. Write a SQL query to find the captains of all the matches in the
tournament. Return match number, country name, player name, jersey
number and position to play.
AnsSELECT match_no,country_name, player_name, jersey_no, posi_to_play FROM match
_captain a JOIN soccer_country b ON a.team_id=b.country_id JOIN player_mast c ON a.pla
yer_captain=c.player_id ORDER BY match_no;
94. Write a SQL query to find the captain and goalkeeper of all the
matches. Return match number, Captain, Goal Keeper and country
name.
95. Write a SQL query to find the player who was selected for the 'Man
of the Match' award in the finals of EURO cup 2016.Return player
name, country name.
AnsSELECT a.player_name, b.country_name FROM player_mast a JOIN match_mast c ON
c.plr_of_match=a.player_id AND c.play_stage='F' JOIN soccer_country b ON a.team_id=b.
country_id;
96. Write a SQL query to find the substitute players who came into the
field in the first half of play within normal play schedule. Return
match_no, country_name, player_name, jersey_no and time_in_out.
ANSSELECT match_no, country_name, player_name, jersey_no, time_in_out FROM player
_in_out a JOIN
player_mast b ON a.player_id=b.player_id JOIN soccer_country c ON b.team_id=c.countr
y_id WHERE
a.in_out='I' AND a.play_schedule='NT' AND a.play_half=1 ORDER BY match_no;
97. Write a SQL query to prepare a list for the player of the match
against each match. Return match number, play date, country name,
player of the Match, jersey number.
Ans SELECT match_no,play_date,country_name, player_name AS "Player of the
Match",jersey_no FROM match_mast a JOIN player_mast b ON a.plr_of_match=b.player_id
JOIN soccer_country c ON b.team_id=c.country_id;
98. Write a SQL query to find the player who taken the penalty shot
number 26. Return match number, country name, player name.
AnsSELECT match_no, country_name, player_name FROM penalty_shootout a JOIN playe
r_mast b ON
a.player_id=b.player_id JOIN soccer_country c ON b.team_id=c.country_id WHERE kick_id
=26;
99. Write a SQL query to find the team against which the penalty shot
number 26 had been taken. Return match number, country name.
Ans
100. Write a SQL query to find the captain who was also the goalkeeper.
Return match number, country name, player name and jersey
number.
Ans ]SELECT match_no, country_name, player_name, jersey_no FROM match_captain a J
OIN soccer_country b ON a.team_id=b.country_id JOIN player_mast c ON a.player_captain
=c.player_id AND posi_to_play='GK' ORDER BY match_no;
101. Write a SQL query to find the number of captains who was also the
goalkeeper. Return number of captains.
AnsSELECT count(DISTINCT player_name) FROM match_captain a JOIN soccer_country b
ON a.team_id=b.country_id JOIN player_mast c ON a.player_captain=c.player_id AND pos
i_to_play='GK';
102. Write a SQL query to find the players along with their team booked
number of times in the tournament. Show the result according to
the team and number of times booked in descending order. Return
country name, player name, and team booked number of times.
116. Write a SQL query to find those referees who booked most number
of players. Return referee name, number of matches.
Ans
117. Write a SQL query to find those players of each team who wore
jersey number 10. Return country name, player name, position to play,
age and playing club.
Ans
118. Write a SQL query to find those defenders who scored goal for their
team. Return player name, jersey number, country name, age and
playing club.
Ans
119. Write a SQL query to find those players who accidentally scores
against his own team. Return player name, jersey number, country
name, age, position to play, and playing club.
ANS