You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In which we query the World country profile table.
3 SELECT from Nobel
Additional practice of the basic features using a table of Nobel Prize winners.
4 SELECT within SELECT
In which we form queries using other queries.
5 SUM and COUNT
In which we apply aggregate functions. more the same
6 JOIN
In which we join two tables; game and goals. previously music tutorial
7 More JOIN operations
In which we join actors to movies in the Movie Database.
8 Using Null
In which we look at teachers in departments. previously Scottish Parliament
8 Numeric Examples
In which we look at a survey and deal with some more complex calculations.
9 Self join
In which we join Edinburgh bus routes to Edinburgh bus routes.
2. Tip
2.1. ALL = 모두 반환 <-> distinct 중복제거 1개 반환
2.2. 서브쿼리에서 부모쿼리의 where에서 하나의 행과 나머지 행을 비교하려면 서브쿼리에 all을 붙여 주어야 함 ex) 4-8: SELECT name, continent FROM world x WHERE population > ALL (SELECT population*3 FROM world y WHERE x.continent=y.continent AND x.name <> y.name)
2.3. GROUP BY 는 sum제외한 나머지 항목 해주면 됨 ex) SELECT mdate, team1,
2.4. 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