##Reflection I was stuck for quite a while on the final problem (#13) in the bonus JOIN section.
First, I had trouble distributing the scores correctly across the teams for each record--but I realized I should be using SUM
and not COUNT
.
Next, I could not figure out how to populate the records (rows/games) with a 0-0 tie. With an INNER JOIN
(default JOIN
behavior), only when the joined field appears in both tables will the result table be populated with data. However, there are different types of joins and we needed the one where all games are populated, regardless of whether they appear in the table describing goals (because games that result in a draw wouldn't show up in the goals table). Remembering this, I went for a LEFT JOIN
--including all items from my "left" table (game) and those that match on the joined feild from the "right" table (goal).