The book online gives following definition of this function: Calculates a percentile based on a continuous distribution of the column value in Microsoft SQL Server 2012 Release Candidate 0 (RC 0). The result is interpolated and might not be equal to any of the specific values in the column.

If you are clear with understanding of the function – no need to read further. If you got lost here is the same in simple words – it is lot like finding median with percentile value.

Now let’s have fun following query:

USE AdventureWorks GOSELECT SalesOrderID, OrderQty, ProductID,PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY ProductID)OVER (PARTITION BY SalesOrderID) AS MedianContFROM Sales.SalesOrderDetailWHERE SalesOrderID IN (43670, 43669, 43667, 43663)ORDER BY SalesOrderID DESCGO

The above query will give us the following result:

You can see that I have used PERCENTILE_COUNT(0.5) in query, which is similar to finding median. Let me explain above diagram with little more explanation. The defination of median is as following:

In case of Even Number of elements = In ordered list add the two digits from the middle and devide by 2 In case of Odd Numbers of elements = In ordered list select the digits from the middle

i have one table , example table_student that have 2 file is student_ID and Student_Name . what can i loop file name of table_student , even thought i know table name is table_Student. anyone help me . thank

Pinal Dave is a technology enthusiast and an independent consultant. He has authored 11 SQL Server database books, 21 Pluralsight courses and have written over 3800 articles on the database technology on his blog at a http://blog.sqlauthority.com. Along with 14+ years of hands on experience he holds a Masters of Science degree and a number of database certifications. For any SQL Server Performance Tuning Issue send email at pinal @ sqlauthority.com .

Nupur Dave is a social media enthusiast and and an independent consultant.