Trace file 95 Percentile alongside min/avg/max

  • Hi

     

    Im trying to show the 95th percentile duration value, per proc , alongside side the min/avg/max duration.

    And Im hitting a brick wall. How on earth do I calculate the percentile per proc. Any words of advise gratefully received

    thank you

     

    simon

  • Simon

    Have you tried the NTILE function?

    John

  • I did try this but the results were garbage 🙁

     


    WITH
    percentiles AS
    (
    SELECT
    NTILE(100) OVER (ORDER BY duration) AS percentile,
    *
    FROM
    trace_table
    )
    SELECT a.textdata2 , a.duration as '95th' ,min(b.duration) as 'min',max(b.duration) as max
    FROM percentiles a
    join trace_table b
    on a.textdata2 = b.textdata2
    where percentile = 95
    group by a.textdata2 ,a.duration
  • Without any sample data, or knowing what is garbage about your results, it's difficult to help you.

    Presumably you're looking for the top 5% of durations for each proc?  In which case, I think you would be better doing NTILE(20) and WHERE percentile = 20.  Either that or leave it as NTILE(100) and have WHERE percentile > 95.

    John

    Edit: depending on what you are actually looking for, Steve's suggestion may be better

  • Percentile_Cont or Percentile_Disc (depending upon which type you want) would probably be the way to go.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply