title: Get the nearest date when no row matches exactly
body: <p>I'm trying to get data from the last weekday of the last twelve months out of my DB. It's a database that holds fund valuations which comes from an API. Each valuation has a date associated to it, which also means that there is no data on bank holidays.</p>
  <p>The query I've been trying (I generate the query from PHP) looks like this:</p>
  <pre><code>SELECT date, kurs FROM navkurser
          WHERE
          isin = 'SE0008373951' AND date = '2019-10-30' OR
          isin = 'SE0008373951' AND date = '2020-04-29' OR
          isin = 'SE0008373951' AND date = '2020-05-29'
          etc...
  </code></pre>
  <p>I'm not very experienced with SQL so there's probably a more efficient way to do this query in general...</p>
  <p>Now, this works just fine, except when there is no matching row. In this example, <code>2020-05-29</code> doesn't have any data because it was a bank holiday here. When this happens, I need to fetch the day before that instead. And if that doesn't match any data, I need to get the day before that, and so on...</p>
  <p>So I guess the question is, how do I get the matching row closest (but not exceeding) a certain date, if it doesn't match the supplied date precisely?</p>
  <p>Example data:</p>
  <pre><code>-------------------------------------------------------------
  | date (DATE)   | isin (VARCHAR(50))    | kurs (FLOAT)      |
  -------------------------------------------------------------
  | 2019-10-30    | SE0008373951          | 104.746           |
  | 2020-04-29    | SE0008373951          | 100.106           |
  | 2020-05-28    | SE0008373951          | 109.650           |
  | 2020-06-04    | SE0008373951          | 110.650           |
  -------------------------------------------------------------
  </code></pre>