January 24, 2018 at 8:55 pm
Comments posted to this topic are about the item The percent ranks
January 24, 2018 at 10:58 pm
Nice question, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
January 25, 2018 at 12:37 am
Good question, timely reminder, thanks Steve.
...
January 25, 2018 at 12:46 am
nice question. Thanks Steve
Manik
You cannot get to the top by sitting on your bottom.
January 25, 2018 at 3:48 am
Knew this one OK. It's Microsoft, the highest percentage is not going to be 100 now is it? 🙂
January 25, 2018 at 6:46 am
Thanks for this question. A short note to the Explanation, the Docs says that the PERCENT_RANK function returns the data type float.
January 25, 2018 at 7:38 am
In the example in the reference given why is the highest rate given a PERCENT_RANK of zero?
This is their rank clause, there is no DESC.PERCENT_RANK() OVER (PARTITION BY Department ORDER BY Rate ) AS PctRank
Is the example incorrect?
January 25, 2018 at 8:24 am
timwell - Thursday, January 25, 2018 7:38 AMIn the example in the reference given why is the highest rate given a PERCENT_RANK of zero?This is their rank clause, there is no DESC.
PERCENT_RANK() OVER (PARTITION BY Department ORDER BY Rate ) AS PctRank
Is the example incorrect?
That is true, but Steve's question had a reverse order by for the result set than for the Percent_Rank(). That "desc" tripped me up.
PERCENT_RANK() OVER (ORDER BY cteLeaders.totalpts)
FROM cteLeaders
ORDER BY cteLeaders.totalpts desc
January 25, 2018 at 9:16 am
jschmidt 17654 - Thursday, January 25, 2018 8:24 AMtimwell - Thursday, January 25, 2018 7:38 AMIn the example in the reference given why is the highest rate given a PERCENT_RANK of zero?This is their rank clause, there is no DESC.
PERCENT_RANK() OVER (PARTITION BY Department ORDER BY Rate ) AS PctRank
Is the example incorrect?
That is true, but Steve's question had a reverse order by for the result set than for the Percent_Rank(). That "desc" tripped me up.
PERCENT_RANK() OVER (ORDER BY cteLeaders.totalpts)
FROM cteLeaders
ORDER BY cteLeaders.totalpts desc
It seems like that should affect the result set but not the PERCENT_RANK.
The example also has DESC for the overall query and not for the PERCENT_RANK. It doesn't use a CTE so maybe that makes a difference?
I am on 2008 R2 so I can't try it. (or ever use it so it's just curiosity at this point....)
January 25, 2018 at 9:44 am
timwell - Thursday, January 25, 2018 9:16 AMjschmidt 17654 - Thursday, January 25, 2018 8:24 AMtimwell - Thursday, January 25, 2018 7:38 AMIn the example in the reference given why is the highest rate given a PERCENT_RANK of zero?This is their rank clause, there is no DESC.
PERCENT_RANK() OVER (PARTITION BY Department ORDER BY Rate ) AS PctRank
Is the example incorrect?
That is true, but Steve's question had a reverse order by for the result set than for the Percent_Rank(). That "desc" tripped me up.
PERCENT_RANK() OVER (ORDER BY cteLeaders.totalpts)
FROM cteLeaders
ORDER BY cteLeaders.totalpts descIt seems like that should affect the result set but not the PERCENT_RANK.
The example also has DESC for the overall query and not for the PERCENT_RANK. It doesn't use a CTE so maybe that makes a difference?I am on 2008 R2 so I can't try it. (or ever use it so it's just curiosity at this point....)
The example in the reference also has "partition by" that breaks up the result set, while the question just had "order by".
January 25, 2018 at 10:15 am
jschmidt 17654 - Thursday, January 25, 2018 9:44 AMThe example in the reference also has "partition by" that breaks up the result set, while the question just had "order by".
Oops. Sorry. My original statement was incorrect. I looked at the last row and missed that there are different ranges within the groups.
January 25, 2018 at 3:48 pm
You've just got to love some of the contradictions found in Microsoft documentation. First, they say (emphasis is mine)...
The range of values returned by PERCENT_RANK is greater than 0 and less than or equal to 1.
In the very next sentence, they say...
The first row in any set has a PERCENT_RANK of 0.
Asking the obvious rhetorical question, is the first row considered to NOT be a part of the range they speak of?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply