title: Selecting entries with nearest value less than given value
body: <p>I want to select the entries with the nearest value less than a given value with SQL (No PL/SQL! or such thing).</p>
  
  <p>I got this far:</p>
  
  <pre><code>select max(RUN_ID) from RUN_TABLE where KEY = 'TEST#33' and RUN_ID &lt; 3
  </code></pre>
  
  <p>This returns the row with the highest value less than 3 matching the key but I want to be able to select all columns.</p>
  
  <pre><code>Run_ID  Entity  Key
  1         HK    TEST#11
  2         AB    TEST#22
  2         CK    TEST#33
  3         TB    TEST#22
  3         DB    TEST#33
  </code></pre>
  
  <p>I would like to be able when having the key TEST#22 and maximal RUN_ID 4 to select the row:</p>
  
  <pre><code>3   TB   TEST#22 
  </code></pre>
  
  <p>And when saying maximal RUN_ID 2 to retrieve</p>
  
  <pre><code>2   AB   TEST#22
  </code></pre>