JOIN Quiz

From SQLZOO
Revision as of 12:08, 7 August 2012 by Connor (Talk | contribs)

Jump to: navigation, search

JOIN quiz

game
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
...
goal
matchid teamid player gtime
1001 POL Robert Lewandowski 17
1001 GRE Dimitris Salpingidis 51
1002 RUS Alan Dzagoev 15
1001 RUS Roman Pavlyuchenko 82
...
eteam
id teamname coach
POL Poland Franciszek Smuda
RUS Russia Dick Advocaat
CZE Czech Republic Michal Bilek
GRE Greece Fernando Santos
...

1. Select the code which shows player and mdate for players which scored during 9th June 2012 to 11th June 2012.

SELECT player, mdate FROM goal JOIN eteam ON (teamname=id) WHERE mdate IN ('9 June 2012','10 June 2012','11 June 2012')
SELECT player, mdate FROM goal JOIN game ON (matchid=id) WHERE mdate IN ('9 July 1912','10 July 1912','11 July 1912')
SELECT player, mdate FROM goal JOIN game ON (matchid=id) WHERE mdate IN ('9 June 2012','10 June 2012','11 June 2012')
SELECT player, mdate FROM goal JOIN game ON (matchid=id) WHERE mdate LIKE ('9 June 2012','10 June 2012','11 June 2012')
SELECT stadium, mdate FROM goal JOIN game ON (matchid=id) WHERE mdate IN ('9 June 2012','10 June 2012','11 June 2012')

2. Select the code which shows player, coach and COUNT(*) for players who scored in the first half of a match (0 - 45 minutes).

SELECT player, coach, COUNT(*) FROM goal JOIN eteam ON (id=teamid) WHERE gtime > 0 AND gtime < 45
SELECT player, coach, COUNT(*) FROM goal JOIN eteam ON (id=teamid) WHERE gtime > 0 AND gtime < 45 GROUP BY player
SELECT player, coach, COUNT(*) FROM goal JOIN eteam ON (id=teamid) WHERE gtime < 0 AND gtime > 45 GROUP BY player
SELECT player, coach, COUNT(*) FROM goal JOIN eteam ON (id=teamid) WHERE gtime > 0 AND gtime < 90 GROUP BY player
SELECT player, stadium, COUNT(*) FROM goal JOIN game ON (id=matchid) WHERE gtime > 0 AND gtime < 45 GROUP BY player

3. Select the code which shows players, their team and the amount of goals they scored against Greece(GRE).

SELECT player, COUNT(*), teamid FROM game JOIN goal ON matchid = id WHERE (team1 = "GRE" OR team2 = "GRE") AND teamid != 'GRE' GROUP BY player
SELECT player, COUNT(*), teamid FROM game JOIN goal ON matchid = id WHERE (team1 = "GRE") AND teamid != 'GRE' GROUP BY player
SELECT player, COUNT(*), teamid FROM game JOIN goal ON matchid = id WHERE (team1 = "POL" OR team2 = "POL") AND teamid != 'POL' GROUP BY player
SELECT player, COUNT(*), teamid FROM game JOIN goal WITH matchid = id WHERE (team1 = "GRE" OR team2 = "GRE") AND teamid != 'GRE' GROUP BY player
SELECT player, teamid FROM game JOIN goal ON matchid = id WHERE (team1 = "GRE" OR team2 = "GRE") AND teamid != 'GRE' GROUP BY player

4. Select the result that would be obtained from this code: SELECT teamid, mdate FROM goal JOIN game on (matchid=id) WHERE mdate = '9 June 2012'

Table-A
DEN9 June 2012
GER9 June 2012
Table-B
DEN
GER
Table-C
GRE12 June 2012
CZE12 June 2012
POL12 June 2012
RUS12 June 2012
Table-D
GRE
CZE
POL
RUS
Table-E
POL8 June 2012
GRE8 June 2012
RUS8 June 2012
CZE8 June 2012
Table-A
Table-B
Table-C
Table-D
Table-E

5. Select the code which would show the player and their team for those who have scored against Poland(POL) in National Stadium, Warsaw.

SELECT DISTINCT player, teamid FROM game JOIN goal ON matchid = id WHERE stadium = 'National Stadium, Warsaw' AND mdate IN (SELECT mdate FROM game WHERE team1 = 'GER' OR team2 = 'GER')AND teamid != 'GER'
SELECT DISTINCT player, teamid FROM game JOIN goal ON matchid = id WHERE stadium = 'National Stadium, Warsaw' AND mdate IN (SELECT mdate FROM game WHERE team1 = 'POL' OR team2 = 'POL')AND teamid != 'POL'
SELECT DISTINCT player, teamid FROM game JOIN goal ON matchid = id WHERE stadium = 'National Stadium, Warsaw' AND teamid != 'POL'
SELECT DISTINCT player, teamid FROM game JOIN goal ON matchid = id WHERE stadium = 'Stadion Miejski (Wroclaw)' AND mdate IN (SELECT mdate FROM game WHERE team1 = 'POL' OR team2 = 'POL')AND teamid != 'POL'
SELECT DISTINCT stadium, mdate FROM game JOIN goal ON matchid = id WHERE stadium = 'National Stadium, Warsaw' AND mdate IN (SELECT mdate FROM game WHERE team1 = 'POL' OR team2 = 'POL')AND teamid != 'POL'

6. Select the code which shows the player, their team and the time they scored, for players who have played in Stadion Miejski (Wroclaw) but not against Italy(ITA).

SELECT DISTINCT player, teamid, gtime FROM game JOIN goal ON matchid = id WHERE stadium = 'National Stadium, Warsaw' AND (team1 != 'ITA' AND team2 !='ITA')
SELECT DISTINCT player, teamid, gtime FROM game JOIN goal ON matchid = id WHERE stadium = 'Stadion Miejski (Wroclaw)' AND (team1 != 'ESP' AND team2 !='ESP')
SELECT DISTINCT player, teamid, gtime FROM game JOIN goal ON matchid = id WHERE stadium = 'Stadion Miejski (Wroclaw)' AND (team1 != 'ITA' AND team2 !='ITA')
SELECT DISTINCT teamid, gtime FROM game JOIN goal ON matchid = id WHERE stadium = 'Stadion Miejski (Wroclaw)' AND (team1 != 'ITA' AND team2 !='ITA')
SELECT DISTINCT player, teamid, gtime FROM game JOIN goal ON matchid = id WHERE team1 != 'ITA' AND team2 !='ITA'

7. Select the result that would be obtained from this code: SELECT teamname, COUNT(*) FROM eteam JOIN goal ON teamid = id GROUP BY teamname HAVING COUNT(*) < 3

Table-A
2
2
1
2
Table-B
Netherlands2
Poland2
Republic of Ireland1
Ukraine2
Table-C
Netherlands
Poland
Republic of Ireland
Ukraine
Table-D
Poland76
Table-E
Republic of Ireland1
Table-A
Table-B
Table-C
Table-D
Table-E

Your score is 0 / 0
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense