SQL Server->> Percentile_cont, Percentile_disc, and Percent_rank functions

Source: Internet
Author: User

Percentile_cont and Percentile_disc are all designed to calculate percentile values, such as calculating the number of a field at a percentile. Their difference is that the former is continuous type, the latter is discrete type. Cont represents CONTINUOUS,DISC on behalf of discrete. Percentile_cont is continuous, meaning that it considers the interval, so the value is the absolute middle value. The Percentile_disc is discrete, so it takes more of an upward or downward tradeoff without considering the interval. Here's an example of MSDN:

 UseAdventureWorks2012; SELECT DISTINCTName asDepartmentname, Percentile_cont (0.5) withinGROUP(ORDER  byPh. Rate) Over(PARTITION byName) asMediancont, Percentile_disc (0.5) withinGROUP(ORDER  byPh. Rate) Over(PARTITION byName) asMediandisc fromHumanResources.Department asDINNER JOINHumanresources.employeedepartmenthistory asDH onDh. DepartmentID=D.departmentidINNER JOINHumanresources.employeepayhistory asph onPh. BusinessEntityID=DH. BusinessEntityIDWHEREDh. EndDate is NULL;

Percent_rank, though also with PERCENT, has nothing to do with the first two. It is in order to calculate the current value as a percentage of the percentile position.

Reference:

PERCENTILE_CONT (Transact-SQL)

PERCENTILE_DISC (Transact-SQL)

PERCENT_RANK (Transact-SQL)

SQL Server->> Percentile_cont, Percentile_disc, and Percent_rank functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.