Course Notes
Use this workspace to take notes, store sample queries, and build your own interactive cheat sheet!
You will need to connect your SQL cells to an integration to run a query.
- You can use a sample integration from the dropdown menu. This includes the Course Databases integration, which contains tables you used in our SQL courses.
- You can connect your own integration by following the instructions provided here.
Note: When using sample integrations such as those that contain course data, you have read-only access. You can run queries, but cannot make any changes such as adding, deleting, or modifying the data (e.g., creating tables, views, etc.).
Task One: Barcelona and Real Madrid have been rival teams for more than 80 years. Matches between these two teams are given the name El Clásico (The Classic). In this exercise, you will query a list of matches played between these two rivals.
You will notice in Step 2 that when you have multiple logical conditions in a CASE statement, you may quickly end up with a large number of WHEN clauses to logically test every outcome you are interested in. It's important to make sure you don't accidentally exclude key information in your ELSE clause.
In this exercise, you will retrieve information about matches played between Barcelona (id = 8634) and Real Madrid (id = 8633). Note that the query you are provided with already identifies the Clásico matches using a filter in the WHERE clause.
SELECT DISTINCT team_api_id, team_long_name
FROM soccer.team
WHERE team_long_name LIKE '%Barcelona%' OR team_long_name LIKE '%Real Madrid%'
ORDER BY 2