Do you need the SUM() around each case?
-----Original Message----- From: Jeanne Sarfaty Glazer [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 13:15 To: SQL Subject: Re: SQL-Server Query Help (SOLUTION) Thanks to Bob Silverberg for the following solution: SELECT idItem, COUNT(*) AS TotalResponding, SUM(CASE WHEN intValue = 0 THEN 1 ELSE 0 END) AS Count0, SUM(CASE WHEN intValue = 1 THEN 1 ELSE 0 END) AS Count1, SUM(CASE WHEN intValue = 2 THEN 1 ELSE 0 END) AS Count2, SUM(CASE WHEN intValue = 3 THEN 1 ELSE 0 END) AS Count3, SUM(CASE WHEN intValue = 4 THEN 1 ELSE 0 END) AS Count4, SUM(CASE WHEN intValue = 5 THEN 1 ELSE 0 END) AS Count5 FROM xrefTable GROUP BY idItem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Get the mailserver that powers this list at http://www.coolfusion.com Message: http://www.houseoffusion.com/lists.cfm?link=i:6:1728 Archives: http://www.houseoffusion.com/lists.cfm?link=t:6 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:6 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=<:emailid:>.<:userid:>.<:listid:>
