Why can't recursive CTEs use grouping and other sentences?

I recently learned about recursive common table expressions (CTEs), looking for a way to create a specific representation of some data. After taking time to write how the first iteration of my query will work, I turned it into a CTE to see how it all happens. I was surprised to see that the grouping is not working, so I just replaced it with the equivalent of “Select TOP 1, ORDER BY”. I was again surprised that the “TOP” was not allowed, and came to the conclusion that all these provisions are not allowed in the recursive part of the CTE:

  • Distinct
  • GROUP BY
  • HAVING
  • TOP
  • LEFT
  • RIGHT
  • ENTRY TOGETHER

So, I have 2 questions:

  • To better understand my situation and SQL, why are these conditions not allowed?
  • - , , ?

.

+2
1

: -

  • SQL, ?

CTE, CTE , , SELECT, INSERT, UPDATE DELETE.

CTE , SELECT CTE , . . " CTE" MSDN

, CTE , , , SELECT, INSERT, UPDATE DELETE, , CTE .

2. - , , ?

, , , , , , view/ CTE select. . GROUP BY CTE ,

, , , .

+2

Source: https://habr.com/ru/post/1768941/


All Articles