• One small-ish tidbit: you want to be VERY clear about what is expected when the sample set doesn't evenly divide into the chunks you've decided on. In your case 99 doesn't divide evenly into 100 parts, so one of the NTILE groupings will have fewer 1 members than others (the smaller ones will be "to the end").

    Example:

    --in this case the NTILE grouping has 5 members

    with nteCTE1 as (

    select ntile(20) over (order by BMI desc) NT, * from dbo.test)

    select * from ntecte1 where nt=1;

    --in this case the NTILE grouping has 4 members

    with nteCTE2 as (

    select ntile(20) over (order by BMI) NT, * from dbo.test)

    select * from ntecte2 where nt=20

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?