Skip to content
Advertisement

getting “No column was specified for column 2 of ‘d'” in sql server cte?

I have this query, but its not working as it should,

when I run this, I am getting

Msg 8155, Level 16, State 2, Line 1
No column was specified for column 2 of ‘d’.

Can any one tell me what am I doing wrong?

Also, when I run this,

I get

Msg 8155, Level 16, State 2, Line 1
No column was specified for column 1 of ‘d’.
Msg 8155, Level 16, State 2, Line 1
No column was specified for column 2 of ‘d’.

Advertisement

Answer

[edit]

I tried to rewrite your query, but even yours will work once you associate aliases to the aggregate columns in the query that defines ‘d’.


I think you are looking for the following:

First one:

Second one:

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