A CTE for IT-positions

Let's practice writing CTEs. You will use the employee table which is built up of fields such as ID, Name, and Position. The task for you is to create a CTE called ITjobs that finds employees starting with A whose job titles start with IT. Your new query will retrieve all IT positions and names from the ITJobs CTE.

To search for a pattern, you have to use the LIKE statement and % representing the search direction. For example, using a WHERE statement with LIKE 'N%' will find patterns starting with N.

Diese Übung ist Teil des Kurses

Hierarchical and Recursive Queries in SQL Server

Kurs anzeigen

Anleitung zur Übung

  • Create the ITjobs CTE.
  • Define the fields of the CTE as ID, Name, and Position.
  • Find the positions starting with IT and the name starting with A.

Interaktive Übung zum Anfassen

Probieren Sie diese Übung aus, indem Sie diesen Beispielcode ausführen.

-- Define the CTE ITjobs by the WITH operator
___ ___ (___, ___, ___) ___ (
    SELECT 
  		___, 
  		___,
  		___
    FROM employee
    -- Find IT jobs and names starting with A
  	WHERE Position LIKE ___ AND Name ___ ___)
    
SELECT * 
FROM ITjobs;