1. Learn
  2. /
  3. Courses
  4. /
  5. SQL for Joining Data

Exercise

Intersect

UNION ALL will extract all records from two tables, while INTERSECT will only return records that both tables have in common. In this exercise, you will create a similar query as before, however, this time you will look at the records in common for country code and year for the economies and populations tables.

Note the number of records from the result of this query compared to the similar UNION ALL query result of 814 records.

Instructions

100 XP
  • Use INTERSECT to determine the records in common for country code and year for the economies and populations tables.
  • Again, order by code and then by year, both in ascending order.