LoslegenKostenlos loslegen

NOT IN and NOT EXISTS

NOT IN and NOT EXISTS do the opposite of IN and EXISTS respectively. They are used to check if the data present in one table is absent in another.

You are interested to know if there are some countries in the Nations table that do not appear in the Cities table. There may be many reasons for this. For example, all the city populations from a country may be too small to be listed, or there may be no city data for a particular country at the time the data was compiled.

You will compare the queries using country codes.

Diese Übung ist Teil des Kurses

Improving Query Performance in SQL Server

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

SELECT WorldBankRegion,
       CountryName
FROM Nations
WHERE Code2 ___ ___ -- Add the operator to compare queries
	(SELECT ___ -- Country code column
	 FROM Cities);
Code bearbeiten und ausführen