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
 General SQL Server Forums
 New to SQL Server Programming
 Group By Clause

Author  Topic 

aoriju
Posting Yak Master

156 Posts

Posted - 2009-05-13 : 06:43:25
CASE WHEN (DD.Meal_Type ='Non-Veg')
THEN (ISNULL(SUM(DD.Verified_Load),0))
ELSE (ISNULL(SUM(DD.Verified_Load),0)) END AS 'Verified_NonVegLoad'

GROUP BY DM.Dispatch_Id,DD.Meal_Type


Iwant To avoid the DD.Meal_Type from Group By Clause

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-13 : 06:46:33
SUM(CASE WHEN DD.Meal_Type = 'Non-Veg' THEN ISNULL(DD.Verified_Load, 0)
ELSE ISNULL(DD.Verified_Load, 0)
END) AS [Verified_NonVegLoad]
GROUP BY DM.Dispatch_Id



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

aoriju
Posting Yak Master

156 Posts

Posted - 2009-05-13 : 07:09:01
Its Not Working
Error Is Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
Go to Top of Page

aoriju
Posting Yak Master

156 Posts

Posted - 2009-05-13 : 07:13:26
Sorry,Sorry
Its Working
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-13 : 08:03:29
You're welcome.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -