Percentile Usage
Collapse
X
-
Alternatively, percentile could be calculated using SQL facilities only.
The following example gives 90th percentile of [Value] field in [tbl]
Code:SELECT Max([Value]) AS Percentile FROM (SELECT TOP 90 PERCENT [Value] FROM [tbl] ORDER BY [Value] ASC);
Comment
-
Code:Percentiles 95th 75th 50th 25th FishVal 100 88 67 21 Excel 101.15 88.25 67 22.5
Code:21 7 34 2 67 33 100 89 67 23 88 100 77 16 44 77 11 77 89 123
Comment
-
:)
I know that the results are different.
This happens because dataset is by definition a set of discrete values, so SQL rounds percentile down to existing value while Excel seems to make interpolation.
Wikipedia article says both methods are in use.
Regards,
Fish.
PS: FYI, Excel could operate with up to 8191 values while SQL is limited by RDBMS specifications for max records.Comment
Comment