I have a query which produces a set of summaries using the compute clause.
This is what I want but all the columns in the compute result set have the
column name "sum". I have tried an alias e.g.
compute sum(cola) as cola_alias
but this throws an error. The wierd thing is all the columns have a name of
sum (they are all sums). I thought column names were supposed to be unique.
I can reference them in code by their ordinal position but it's not really
ideal. I guess I am doing something wrong but I am unsure what. Regards,
Chris."Chris" <nospam@.nospam.com> wrote in message
news:OyrOySozHHA.1208@.TK2MSFTNGP05.phx.gbl...
>I have a query which produces a set of summaries using the compute clause.
>This is what I want but all the columns in the compute result set have the
>column name "sum". I have tried an alias e.g.
> compute sum(cola) as cola_alias
> but this throws an error. The wierd thing is all the columns have a name
> of sum (they are all sums). I thought column names were supposed to be
> unique. I can reference them in code by their ordinal position but it's
> not really ideal. I guess I am doing something wrong but I am unsure what.
> Regards, Chris.
>
COMPUTE is deprecated. Use CUBE or ROLLUP instead. They are more powerful
and easier to use.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--sqlsql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment