Skip to content
Advertisement

How to replicate nested from statement to nested with statement?

I have created a nested from statement that can be seen below:

I am trying to recreate the same results with a nested with statement, I have attempted the below, but it results in a multi-part identifier could not be bound. How would I solve this issue because I thought I named each query correctly?

Advertisement

Answer

The last FROM statement is still referring to the original tables, not the ones that are defined with the WITH statement.

If you change it from

to

should give you the expected result

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement