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
544 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 ==> | More exotic joins (5 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.
If you haven't already done so, run the script in the above folder to generate the Doctor Who database.
The database contains details of companions, and the episodes each appeared in:
Each companion can appear in one or more episodes.
Use this to list the names of the companions who haven't featured in any episodes. You should find there's one of them, but we won't spoil the surprise by saying who it is!
Create a query based on the companions table, with an outer join to the episode companion table.
Save this query as outre.sql (that's neither a misspelling nor a funny joke), and close it down.
You can find other training resources for the subject of this exercise here:
From: | Devender |
When: | 16 Jan 24 at 09:32 |
/*Use this to list the names of the companions who haven't
featured in any episodes. You should find there's one of them,
but we won't spoil the surprise by saying who it is!
*/
use DoctorWho
select cn.companionname --et.episodetype
from
tblCompanion cn full outer join tblEpisodeCompanion ci
on cn.CompanionId= ci.CompanionId
full outer join tblEpisode et
on et.EpisodeId=ci.EpisodeId
where episodetype is null
From: | Aravindh_sql |
When: | 27 May 22 at 09:33 |
SELECT
tblCompanion.CompanionName AS Companion,
tblEpisode.EpisodeType
FROM tblCompanion
LEFT JOIN
tblEpisodeCompanion
ON
tblCompanion.CompanionId = tblEpisodeCompanion.CompanionId
LEFT JOIN
tblEpisode
ON
tblEpisodeCompanion.EpisodeId = tblEpisode.EpisodeId
WHERE tblEpisode.EpisodeType IS NULL
ANSWER
-- Companion= Sarah Jane Smith
From: | FloridaMan |
When: | 26 Sep 21 at 01:28 |
select *
from
[dbo].[tblEpisode] e
left join [dbo].[tblEpisodeCompanion] ec
on e.EpisodeId = ec.EpisodeId
--where e.EpisodeId is null
full outer join [dbo].[tblCompanion] c
on ec.CompanionId = c.CompanionId
From: | waltz |
When: | 09 May 21 at 11:23 |
SELECT cm.[CompanionId],[CompanionName]
FROM [dbo].[tblCompanion] AS cm left outer JOIN [dbo].[tblEpisodeCompanion] AS Ec
ON cm.CompanionId = Ec.CompanionId
except
(SELECT cm.[CompanionId],[CompanionName]
FROM [dbo].[tblCompanion] AS cm inner JOIN [dbo].[tblEpisodeCompanion] AS Ec
ON cm.CompanionId = Ec.CompanionId);
GO
From: | walteragwe |
When: | 20 Jan 21 at 03:43 |
SELECT cm.[CompanionId],[CompanionName]
FROM [dbo].[tblCompanion] AS cm left outer JOIN [dbo].[tblEpisodeCompanion] AS Ec
ON cm.CompanionId = Ec.CompanionId
except
(SELECT cm.[CompanionId],[CompanionName]
FROM [dbo].[tblCompanion] AS cm inner JOIN [dbo].[tblEpisodeCompanion] AS Ec
ON cm.CompanionId = Ec.CompanionId);
GO
From: | grao |
When: | 07 Nov 17 at 01:34 |
I am not getting any results. Is this the right code?
use doctorwho
Select companionname
from tblCompanion as c
left outer join tblEpisodeCompanion as e
on c.CompanionId=e.EpisodeCompanionId
where e.EpisodeCompanionId =null
From: | DbEnthusiast |
When: | 19 Dec 20 at 16:11 |
SELECT C.CompanionName,C.WhoPlayed,EC.*
FROM [dbo].[tblCompanion] C
LEFT JOIN [dbo].[tblEpisodeCompanion] EC ON C.CompanionId = EC.CompanionId
WHERE EC.EpisodeCompanionId IS NULL OR EC.CompanionId IS NULL
From: | Phithel |
When: | 18 Oct 18 at 18:57 |
USE DoctorWho
SELECT
C.[CompanionName],
E.[Title]
FROM
[dbo].[tblCompanion] AS C
LEFT OUTER JOIN [dbo].[tblEpisodeCompanion] AS EC
ON C.CompanionId = EC.CompanionId
LEFT OUTER JOIN [dbo].[tblEpisode] AS E
ON EC.EpisodeId = E.EpisodeId
WHERE
E.Title IS NULL
I got Sarah Jane Smith
From: | linjom |
When: | 19 Apr 18 at 07:21 |
select c.CompanionName,c.WhoPlayed,E.Episodeid,E.EpisodeCompanionId
from tblCompanion as C
left join tblEpisodeCompanion as E
on c.CompanionId = E.CompanionId
where (E.EpisodeCompanionId is null or E.EpisodeId is null)
Result i got Sarah Jane Smith Elisabeth Sladen NULL NULL
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.