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)
 Tough Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-08 : 00:37:07
Dave writes "Hi Guys,

I have a table in SQL Server 7.0 that contains a list of memberid's and their preferences. Each preference has a column. A TRUE or FALSE is inserted in each column for each memberid depending on whether that member has selected that preference or not. There are 90 preferences. If I wanted to know how many members had selected a preference called Cars I would use the statement below.

SELECT COUNT(*)
FROM tblPreferences
WHERE Cars='TRUE'

If I want to find that number of members who selected each preference I will have to run this query 90 times, changing the preference name each time. Is there a way I can perform this in 1 query or stored procedure? I'd appreciate any help you could give me?

Kind Regards,
Dave"
   

- Advertisement -