Getting Started With SQL Part 2

Photo by Roman Kraft on Unsplash
Basketball ERD
SELECT player.last_name, game.points
FROM player
JOIN game
ON game.player_id = player.id
ORDER BY game.points DESC;
Photo by Everyday basics on Unsplash
FROM table AS tFROM table t
Photo by Alexandre Debiève on Unsplash
# players who have scored over 1000 points for their team
SELECT t.name, p.last_name, SUM(g.points) points
FROM player p
JOIN game g
ON g.player_id = p.id
JOIN team t
ON t.player_id = p.id
GROUP BY t.name, p.last_name
HAVING SUM(g.points) > 1000
ORDER BY points DESC;

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store