Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Percentile Calculation

RSS
Modified on Fri, Jun 25, 2010, 10:53 AM by Administrator Categorized as SQL Server
with MyData as (
    select distinct
         LineCount 
        ,CountLe    = (select count(1) from #a b where b.LineCount <= a.LineCount)
        ,CountTotal = (select count(1) from #a) 
    from 
        #a a (nolock)
    )
select
     LineCount
    ,Percentile = CountLe * 100.0 / CountTotal
from
    MyData
order by 
    LineCount

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.