07-31-2023, 09:50 AM
From this post [How to use ROW_NUMBER in the following procedure?][1]
There are two versions of answers where one uses a `sub-query` and the other uses a `CTE` to solve the same problem.
Now then, what is the advantage of using a `CTE (Common Table Expression)` over a 'sub-query`(thus, more ***readable*** what the query is actually doing)
The only advantage of using a `CTE` over `sub-select` is that I can actually *name* the `sub-query`. Are there any other differences between those two *when a CTE is used as a simple (non-recursive) CTE?*
[1]:
There are two versions of answers where one uses a `sub-query` and the other uses a `CTE` to solve the same problem.
Now then, what is the advantage of using a `CTE (Common Table Expression)` over a 'sub-query`(thus, more ***readable*** what the query is actually doing)
The only advantage of using a `CTE` over `sub-select` is that I can actually *name* the `sub-query`. Are there any other differences between those two *when a CTE is used as a simple (non-recursive) CTE?*
[1]:
[To see links please register here]