Exercise: Create table of actors and directors born in 1969

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 the Wise Owl course listed below!

Category ==> SQL  (115 exercises)
Topic ==> Temporary tables and table variables  (10 exercises)
Level ==> Average difficulty
Course ==> Advanced SQL
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

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 create a temporary table of all of the actors and directors born in 1969:

SQL exercise - Temporary tables and table variables (image 1)

The flower children in date of birth order - 10 actors, but only 1 director

To do this, first create a command to select all of the actors born in 1969 into a new temporary table.

Be careful!  Because you're soon going to be adding the directors to this temporary table, check that you cast the actor name column to a data type compatible with the director's name.

Now add a command to insert all of the directors born in 1969 into the temporary table.

Display the contents of the temporary table - it should look as shown at the start of this exercise.

Thought for the day - you could have solved this problem using a UNION ALL query (take a look at the answer to this exercise if you've never created a union query).  Which method do you prefer?

Save the query to create and display the temporary table as Flower children, then close it down.

This page has 0 threads Add post