Home Forums SQL Server 2005 T-SQL (SS2K5) Help getting total rows from outer select statement RE: Help getting total rows from outer select statement

  • Tried the above mentioned solution already, it doesn't help.

    I am pretty much just interested in a record and it associated 'TotalExp' I want to do a percentage ranking on this column. That is to say, I want the to have a way to see who has the 10% highest ranked values for 'TotalExp'. To calculate this manual that means you need:

    A.) The total number of unique records (this is what I can get very efficiently.

    B.) A numerical ranking of the 'TotalExp' for each record.

    Once you have those two values, you can calculate the percent ranking by using the formula: ( Ranked-TotalExp / TotalRecordsUsed ) * 100

    This is infact what using the TOP N PERCENT does when ordering by 'TotalExp' DESC does, but then the user cannot see what the Percent Ranking is for each individual record. There must be an easy way to do this?? I mean, using the TOP N PERCENT works fast, and its calculating these Percent Rankings just not displaying them, so there must be a way to do this in one easy step.