Posted by admin on 2023-01-29 09:57:38 |
Share: Facebook | Twitter | Whatsapp | Linkedin Visits: 639
A common table expression (CTE) is a defined short result set that endures within the range of a particular statement and that can be called later within that statement, perhaps on many occasions. The following query is describing the CTE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | WITH all_empAS(SELECT empId, BossId, FirstName, LastNameFROM EmpWHERE BossId is NULLUNION ALLSELECT e.empId, e.BossId, e.FirstName, e.LastNameFROM Emp e INNER JOIN all_emp rON e.BossId = r.Id)SELECT * FROM all_emp |