SELECT matchid,player FROM goal
WHERE teamid = ‘GER’
SELECT id,stadium,team1,team2
FROM game
where id=1012
SELECT player,teamid,stadium,mdate
FROM game JOIN goal ON (id=matchid)
WHERE teamid = ‘GER’
SELECT team1,team2,player
FROM game JOIN goal ON (id=matchid)
WHERE player like ‘Mario%’
SELECT player, teamid, coach,gtime
FROM goal join eteam on teamid=id
WHERE gtime<=10
SELECT mdate,teamname
FROM game join eteam on team1=eteam.id
WHERE coach=‘Fernando Santos’
SELECT player
FROM game join goal on id=matchid
WHERE stadium=‘National Stadium, Warsaw’
SELECT distinct player
FROM game JOIN goal ON matchid = id
where teamid !=‘GER’ and (team1='GER’or team2=‘GER’)
SELECT teamname,count(player)
FROM eteam JOIN goal ON id=teamid
group BY teamname
SELECT stadium,count(player)
FROM game JOIN goal ON id=matchid
group BY stadium
SELECT matchid,mdate, count(player)
FROM game JOIN goal ON matchid = id
WHERE (team1 = ‘POL’ OR team2 = ‘POL’)
group by matchid,mdate
注意:分组编号和日期
SELECT matchid,mdate, count(player)
FROM game JOIN goal ON matchid = id
WHERE (team1 = ‘GER’ OR team2 = ‘GER’) and teamid=‘GER’
group by matchid,mdate
SELECT mdate,
team1,
sum(CASE WHEN teamid=team1 THEN 1 ELSE 0 END) score1,
team2,
sum(CASE WHEN teamid=team2 THEN 1 ELSE 0 END) score2
FROM game left JOIN goal ON matchid = id
group by mdate,matchid,team1,team2