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)
 Sorting

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-23 : 09:34:54
Gary Costigan writes "I have built a survey on our website that users check the different boxes and the results go to a SQL table as 1's or 0's when the survey is submitted.

The table consists of 5 columns, and the rows are equal to the number of submitted survey's.

My question to the team is this. I can get the totals of each column by using the SUM aggregate function. How can I get the results displayed in a decending order "most to least" votes by sorting the results of the columns?

ie: Number of total votes per column using the SUM.

Column A....Column B....Column C....Column D....Column E
...2................4..............3................1...........5


Would like to see the results like this.

Column E....Column B....Column C....Column A....Column D
...5...............4..............3................2............1

Can SQL do this? I have been reading through several books this morning and can't seem to find the answer.

Thanks.

Gary"
   

- Advertisement -