Is it possible to Group on a calculated ?
I'm trying the following
SELECT field1, field2 + field3 AS field4, SUM(field5)
FROM Table1
GROUP BY field1, field4
but receive
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'field4'
Initially I presumed that it couldn't group on a calculated field however whilst the following worked
SELECT field1, field2 AS field4
FROM Table1
ORDER BY field4
a corresponding group SELECT failed with the same message as before
SELECT field1, field2 AS field4
FROM Table1
GROUP BY field4
Any clues ?
I'm trying the following
SELECT field1, field2 + field3 AS field4, SUM(field5)
FROM Table1
GROUP BY field1, field4
but receive
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'field4'
Initially I presumed that it couldn't group on a calculated field however whilst the following worked
SELECT field1, field2 AS field4
FROM Table1
ORDER BY field4
a corresponding group SELECT failed with the same message as before
SELECT field1, field2 AS field4
FROM Table1
GROUP BY field4
Any clues ?