Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2011-12-01 : 19:20:10
|
| Grouping doesn't allow the use of column aliases in the group by clause.Does this mean that the expression that would be aliased would be calculated twice, once in the select and once in the Group By??If that's the case, are there any suggestion for streamlining this kind of thing?Thanks!--PhB |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-01 : 19:26:05
|
quote: Grouping doesn't allow the use of column aliases in the group by clause.
Yes. You have to use the column name or the full expression in the GROUP BYquote: Does this mean that the expression that would be aliased would be calculated twice, once in the select and once in the Group By??
Noquote: If that's the case, are there any suggestion for streamlining this kind of thing?
use Derived table or CTEselect col_alias, sum(some_col)from ( select col1 + col2 + col3 as col_alias, some_col from some_table) as dgroup by col_alias KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|