Guest User

Untitled

a guest
Jul 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. /* Show matchid and player name for all goals scored by Germany */
  2. SELECT matchid, player
  3. FROM goal
  4. WHERE teamid = 'GER'
  5.  
  6. /* Show id, stadium, team1, team2 for just game 1012 */
  7. SELECT id, stadium, team1, team2
  8. FROM game
  9. WHERE id = 1012
  10.  
  11. /* Show player, teamid, stadium and mdate for every German goal */
  12. SELECT player, teamid, stadium, mdate
  13. FROM game JOIN goal ON (id=matchid)
  14. WHERE teamid = 'GER'
  15.  
  16. /* Show team1, team2 and player for every goal scored by a player called Mario */
  17. SELECT team1, team2, player
  18. FROM game JOIN goal ON (id = matchid)
  19. WHERE player LIKE 'Mario%'
  20.  
  21. /* Show player, teamid, coach, gtime for all goals stcored in the first 10 minutes */
  22. SELECT player, teamid, coach, gtime
  23. FROM goal JOIN eteam ON (goal.teamid = eteam.id)
  24. WHERE gtime <= 10
  25.  
  26. /* List the dates of the matches and the name of the team in which Fernando Santos
  27. was the team1 coach */
  28. SELECT mdate, teamname
  29. FROM game JOIN eteam ON (game.team1 = eteam.id)
  30. WHERE coach = 'Fernando Santos'
  31.  
  32. /* List the player for every goal scored in a game where the stadium was
  33. National Stadium, Warsaw */
  34. SELECT player
  35. FROM game JOIN goal ON (game.id = goal.matchid)
  36. WHERE stadium = 'National Stadium, Warsaw'
  37.  
  38. /* More Difficult Questions */
  39. /* Show the name of all players who scored a goal against Germany */
  40.  
  41.  
  42.  
  43. /* Show teamname and the total number of goals scored */
  44. SELECT teamname, COUNT(gtime)
  45. FROM eteam JOIN goal ON (id = teamid)
  46. GROUP BY teamname
  47.  
  48. /* Show the stadium and the number of goals scored in each stadium */
  49. SELECT stadium, COUNT(gtime) AS goals_scored
  50. FROM game JOIN goal ON game.id = goal.matchid
  51. GROUP BY teamid
  52.  
  53. /* For every match involving Poland, show the matchid, date, and number of goals scored */
  54. SELECT matchid, mdate, COUNT(gtime) AS goals_scored
  55. FROM goal JOIN game ON matchid = id
  56. WHERE (team1 = 'POL' OR team2 = 'POL')
  57. GROUP BY matchid, mdate
  58.  
  59. /* For every match where Germany scored, show matchid, match date and the number
  60. of goals scored by Germany */
  61. SELECT matchid, mdate, COUNT(gtime) AS goals_scored
  62. FROM goal JOIN game ON matchid = id
  63. WHERE (teamid = 'GER')
  64. GROUP BY matchid, mdate
Add Comment
Please, Sign In to add comment