title: Getting a single 90th percentile value of the data
body: <p>I want to find the 90th percentile of the date difference however, the result returns multiple rows of the the percentile data. I only want a <strong>single row stating the 90th percentile</strong>, and I am having problem solving that.</p>
  <p>Here is the sample data.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>OWNER_ID</th>
  <th>CREATED_TIME</th>
  <th>STATUS_ID</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>2020-07-16 08:29:29.000</td>
  <td>NEW</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2022-02-21 04:38:01.000</td>
  <td>PROCESSED</td>
  </tr>
  <tr>
  <td>3</td>
  <td>2022-02-28 14:24:28.000</td>
  <td>1</td>
  </tr>
  <tr>
  <td>3</td>
  <td>2022-02-28 14:27:32.000</td>
  <td>CONVERTED</td>
  </tr>
  <tr>
  <td>4</td>
  <td>2022-02-28 14:33:06.000</td>
  <td>NEW</td>
  </tr>
  <tr>
  <td>4</td>
  <td>2022-02-28 14:33:19.000</td>
  <td>IN_PROCESS</td>
  </tr>
  <tr>
  <td>5</td>
  <td>2022-03-01 12:01:48.000</td>
  <td>NEW</td>
  </tr>
  <tr>
  <td>5</td>
  <td>2022-03-01 12:02:00.000</td>
  <td>IN_PROCESS</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>This is my query for this.</p>
  <pre><code>SELECT
      'percentile count' as name,
      PERCENTILE_CONT(0.9) within group (order by temp.diff) over () as percentile_90
  FROM
  
  (SELECT OWNER_ID,
  DATEDIFF(hour,
  MIN (CASE WHEN STATUS_ID = 'NEW' THEN CREATED_TIME END),
  MAX (CASE WHEN STATUS_ID = 'IN_PROCESS' THEN CREATED_TIME END) ) as diff
  FROM table
  WHERE CREATED_DATE Between DATEADD(DAY, -14, GETDATE()) AND GETDATE()
  AND RESPONSIBLE_ID IN (2731,2727,2702,2730,2701,2699,2696)
  GROUP BY OWNER_ID)temp
  </code></pre>
  <p>The logic of my problem is to first to get the date difference between STATUS_ID = NEW and STATUS_ID = IN_PROCESS for each OWNER_ID. Then I want to know the overall 90th Percentile of the date differences, returning a single result row.</p>
  <p>My desired output is in this format containing just one row:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Name</th>
  <th>90th Percentile</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Percentile count</td>
  <td>100</td>
  </tr>
  </tbody>
  </table>
  </div>