SQL | Derived tables and CTEs exercise | Using derived tables

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.

The answer to the exercise will be included and explained if you attend one of more of the courses listed below!

Software ==> SQL  (198 exercises)
Version ==> Any version of SQL Server
Topic ==> Derived tables and CTEs  (13 exercises)
Level ==> Average difficulty
Courses ==> Introduction to SQL  /  Advanced SQL

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

The aim of this exercise is to use a derived table to hold data before joining this another table. Start by selecting only events which end with a letter between N and Z.

Storing information in a derived table

Your query should return 300 results (including the CountryID column will allow us to join to the tblCountry table).

Now turn this select into a derived table called Second_Half_Derived. The layout will be something like this:

--Outer select

SELECT

EventName

FROM

(

--Your select goes here

) AS Second_half_Derived

Now join tblCountry to the derived table as you would for a normal table:

Derived table joined on

This should return 230 results - scroll down for some happier events.

Optionally save this as Deriving results.sql and close it down.

This page has 0 threads Add post