|
-
Apr 11th, 2012, 05:31 AM
#1
Thread Starter
Fanatic Member
Looping through a result set
SQL Server 2008
I need to loop through a result set n times and calculate percentages.
Lets say my result contains one field and looks like :
Code:
Field1
=====
2
2
1
0
Lets say that my parameter "n" = 3.
I must loop through the result set and calculate what the percentages are for the numbers 1 through 3 and return these.
In the above example I would get
One = 25%, Two = 50%, 3= 0%, Unknown = 25%.
I have been looking at this all day and for the life of me cannot figure out how to achieve it .
Any help would be much welcomed.
Last edited by venerable bede; Apr 11th, 2012 at 05:59 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|