JOIN then UNION query
Your goal is to create a report with the following fields:
- season, which outputs either
summer
orwinter
- country
- events, which shows the unique number of events
There are multiple ways to create this report. In this exercise, create the report by using the JOIN
first, UNION
second approach.
As always, feel free to reference your E:R Diagram to identify relevant fields and tables.
Cet exercice fait partie du cours
Reporting in SQL
Instructions
- Setup a query that shows unique
events
bycountry
andseason
for summer events. - Setup a similar query that shows unique
events
bycountry
andseason
for winter events. - Combine the two queries using a
UNION ALL
. - Sort the report by events in descending order.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
-- Query season, country, and events for all summer events
SELECT
____ AS season,
____,
____ AS events
FROM ____ AS s
JOIN ____ AS c
ON ____
GROUP BY ____
-- Combine the queries
____
-- Query season, country, and events for all winter events
SELECT
____ AS season,
____,
____ AS events
FROM ____ AS w
JOIN ____ AS c
ON ____
GROUP BY ____
-- Sort the results to show most events at the top
ORDER BY ____;