views:

241

answers:

2

i have been working on query which uses compute by clause for avg and sum operators . As Microsoft declared this will be a discontinued feature ,what will be the replacement for this feature

+1  A: 

Use ROLLUP which is part of the GROUP BY clause

gbn
+1  A: 

Interestingly (although this might be a bug), the SQL Server 2005 documentation says

The COMPUTE and COMPUTE BY clauses are provided for backward compatibility. Instead, use the following components:

SQL Server 2005 Analysis Services (SSAS) with OLE DB for Analysis Services or Microsoft ActiveX Data Objects Multidimensional (ADO MD). For more information, see Analysis Services Data Access Interfaces (SSAS).

The ROLLUP operator. For more information, see Summarizing Data Using ROLLUP.

but the (later) SQL Server 2008 documentation merely says

The COMPUTE and COMPUTE BY clauses are provided for backward compatibility. Instead, use the following components:

SQL Server 2005 Analysis Services (SSAS) with OLE DB for Analysis Services or Microsoft ActiveX Data Objects Multidimensional (ADO MD). For more information, see Analysis Services Data Access Interfaces (Analysis Services - Multidimensional Data).

I don't know if the omission of ROLLUP in the latter is a mistake, or if that means it's not longer a suggested way forward.

AakashM
If you look at SQL 2008 COMPUTE link http://msdn.microsoft.com/en-us/library/ms181708.aspx it says ROLLUP
gbn