title: Calculating percentiles in SQL
body: <p>This should be very straightforward, but as a newbie to SQL I am really struggling. I've been recommended to use PERCENTILE_CONT with continuous (non-discrete) data.</p>
  
  <p>The data in question concerns two columns: (1) the IDs for a list of patients and (2) the average number of events per year.</p>
  
  <p>Working from some code I found online, this is where I am up to </p>
  
  <pre><code>SELECT ID,
  percentile_cont (0.25) WITHIN GROUP
  (ORDER BY PPPY ASC) OVER(PARTITION BY ID) as percentile_25,
  percentile_cont (0.50) WITHIN GROUP
  (ORDER BY PPPY ASC) OVER(PARTITION BY ID) as percentile_50,
  percentile_cont (0.75) WITHIN GROUP
  (ORDER BY PPPY ASC) OVER(PARTITION BY ID) as percentile_75
  FROM AE_COUNT;
  </code></pre>
  
  <p>This just seems to report thee columns each with identical values of PPPY. </p>
  
  <p>Any idea where I'm going wrong?</p>