Act fast, special offers end soon! Up to $294 is savings when you get Premium today.
Get offer codes

Common Table Expression in SQL

Screen Link:

Hi guys,

I am currently working on the SQL fundamentals skill path and have noticed a mistake in one of the exercises.
In the common table expression module on the 7th screen.

The table below is the desired output of the course section.
image

I used the code below to get the output which gave me the desired output.
Nevertheless, I got an error that the query does not match the expected results.

My Code:

WITH RECURSIVE
managers_chain(employee_id, path) AS (

SELECT employee_id, last_name || ' ' || first_name AS path 
  FROM employee
 WHERE reports_to IS NULL
 
 UNION ALL
    
 SELECT  e.employee_id
        ,m.path ||' '||'<--' ||last_name||' '|| first_name 
        FROM employee e 
        JOIN managers_chain m 
          ON e.reports_to = m.employee_id 
 
-- TODO: Write the recursive member here
 )
 
 SELECT path
   FROM managers_chain;
   

So, I looked at the answer. The answer was basically the example syntax for recursive functions which does let you pass the assignment once copy and paste it on the screen. However, it does not yield the desired results according to the instructions.

Hey, yeah I just notced the same thing… the correct answer doesnt work, but if copy the “show solution” option, then it lets you pass.

Thanks, folks. This is a content bug on our end. I suspect the author meant to have a different table in the instructions.