Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | SQL (203 exercises) |
Topic ==> | Calculations (18 exercises) |
Level ==> | Average difficulty |
Subject ==> | SQL training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
This will generate the database that you'll need to use in order to do this exercise (note that the database and script are only to be used for exercises published on this website, and may not be reused or distributed in any form without the prior written permission of Wise Owl).
Write a query to divide countries into these groups:
Continent id | Belongs to | Actual continent (for interest) |
---|---|---|
1 or 3 | Eurasia | Europe or Asia |
5 or 6 | Americas | North and South America |
2 or 4 | Somewhere hot | Africa and Australasia |
7 | Somewhere cold | Antarctica |
Otherwise | Somewhere else | International |
Your query (based only on the tblCountry table) should show the following results:
The first few countries, sorted in reverse alphabetical order by your new column.
Save this query as Continental Drift, then close it down.
You can find other training resources for the subject of this exercise here:
From: | Bhavya59 |
When: | 31 Jul 24 at 11:28 |
SELECT [CountryName]
,CASE
WHEN ContinentID=1 OR ContinentID=3 THEN 'Eurasia'
WHEN ContinentID=5 OR ContinentID=6 THEN 'Americas'
WHEN ContinentID=2 OR ContinentID=4 THEN 'Somewhere hot'
WHEN ContinentID=7 THEN 'Somewhere cold'
ELSE 'Somewhere else'
END
AS CountryLocation
FROM [WorldEvents].[dbo].[tblCountry]
ORDER BY CountryLocation DESC
From: | Yash2211 |
When: | 17 Sep 23 at 12:41 |
select Countryname,
case
when continentid in (1,3) then 'Eurasia'
when continentid in (5,6) then 'Americas'
when continentid in (2,4) then 'somewhere hot'
when continentid in (7) then 'somewhere cold'
else 'somewhere else'
end as 'Countrylocation'
from tblCountry
order by countryLocation desc
From: | Aravindh_sql |
When: | 26 May 22 at 18:27 |
SELECT CountryName ,
CASE
WHEN (ContinentID = 1 or ContinentID = 3 ) THEN 'Eurasia'
WHEN (ContinentID = 5 or ContinentID = 6 ) THEN 'Americas'
WHEN (ContinentID = 2 or ContinentID = 4 ) THEN 'Somewhere hot'
WHEN (ContinentID = 7 ) THEN 'Somewhere Cold'
ELSE 'Somewhere else'
END AS CountryLocation
FROM tblcountry
ORDER BY CountryLocation DESC
From: | esottilaro |
When: | 25 Sep 19 at 15:48 |
Does anyone have the script for Continental Drift?
From: | rasim.setia |
When: | 06 Oct 19 at 19:19 |
-- This should work---
SELECT [CountryName]
,CASE
WHEN [ContinentID] in ('1','3') then 'Eurasia'
When [ContinentID] in ('5','6') then 'Americas'
When [ContinentID] in ('2','4') then 'Somewhere hot'
When [ContinentID] = 7 then 'Somewhere cold'
ELSE 'Somewhere else' END as 'CountryLocation'
FROM [WorldEvents].[dbo].[tblCountry]
order by CountryLocation desc
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.