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
 SQL Server Development (2000)
 group by on a bit value

Author  Topic 

php95saj
Starting Member

43 Posts

Posted - 2002-06-19 : 05:27:41
I have a stored procedure in which I am using SUM funstion adn so I have use group by. The problems is, I want to select a column which is bit value type and it cannot be used in group by statement. Any ideas as how to get around this problem.

Thanks


macka
Posting Yak Master

162 Posts

Posted - 2002-06-19 : 05:56:06
I'm guessing you are using SQL Server 7.0 as this isn't a problem in 2000.

You need to CAST the bit value to an integer.

SELECT CAST(flag AS INTEGER),SUM(qty)
FROM sales
GROUP BY CAST(flag AS INTEGER)

macka.

Go to Top of Page
   

- Advertisement -