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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 CASE within SELECT with GROUP BY/SUM

Author  Topic 

CostLink
Starting Member

2 Posts

Posted - 2001-11-01 : 12:45:14
Hi

this is my first post here, so hello to everyone !

I have this simplified statement:
SELECT [Exchange].[Code],
[Numb_Buy (M)] = CASE WHEN [Type].[Type_ID]=1 THEN SUM([Transaction].[Quantity]) ELSE 0 END,
[Numb_Sell (M)] = CASE WHEN [Type].[Type_ID]=2 THEN SUM([Transaction].[Quantity]) ELSE 0 END
FROM [..]
GROUP BY [Exchange].[Code], [Type].[Type_ID]

Is it possible, without making a query on top of this one, to remove my CASE condition search ([Type].[Type_ID]) from the GROUP BY clause ?

Thanks !
   

- Advertisement -