title: Big Query: Get Closest Percentile Value
body: <p>I have a large table of percentiles generated using the PERCENT_RANK() function within Big Query. The table output generates many rows of data that have percentile numbers that are very close to each other. I am looking to only return 10 rows with values that are closets to the 100th, 90th, 80th, 70th etc. percentiles.</p>
  
  <p>More specifically, I am looking for the number that is closest to the 80th percentile (.8) and have the following sample values:</p>
  
  <p>.81876543
  .81123141
  .80121214
  .80012123
  .80001213
  .80001112
  .79999121</p>
  
  <p>In this case .80001112 is the closest to .8.</p>
  
  <p>Is there a SQL function I can use that only returns the ten values closest to those percentiles.</p>