CASE statements comparing two column values part 2
Similar to the previous exercise, you will construct a query to determine the outcome of Barcelona's matches where they played as the away team. You will learn how to combine these two queries in chapters 2 and 3.
Did their performance differ from the matches where they were the home team?
Questo esercizio fa parte del corso
Data Manipulation in SQL
Istruzioni dell'esercizio
- Complete the
CASEstatement to identify Barcelona's away team games as wins, losses, or ties. - Left join the
teams_spaintableteam_api_idcolumn on thematches_spaintablehometeam_idcolumn. This retrieves the identity of the home team opponent. - Filter the query to only include matches where Barcelona (
awayteam_id = 8634) was the away team.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
-- Select matches where Barcelona was the away team
SELECT
m.date,
t.team_long_name AS opponent,
___ ___ ___ < ___ ___ 'Barcelona win!'
WHEN ___ > ___ ___ 'Barcelona loss :('
___ 'Tie' ___ ___ outcome
FROM matches_spain AS m
LEFT JOIN teams_spain AS t
ON m.hometeam_id = t.team_api_id
-- Filter for Barcelona
WHERE m.___ = ___;