title: How to make a SQL query to select rows with dynamic interval
body: <p>I have a table currency history with the following structure:</p>
  
  <pre><code>+----+-------------+---------------+---------------------+
  | id | currency_id | price_usd     | created_at          |
  +----+-------------+---------------+---------------------+
  |  1 |           1 | 8719.79000000 | 2019-11-12 15:52:06 |
  |  2 |           2 |  185.36000000 | 2019-11-12 15:52:06 |
  |  3 |           3 |    0.27157609 | 2019-11-12 15:52:06 |
  |  4 |           4 |  287.40000000 | 2019-11-12 15:52:06 |
  |  5 |           5 |    1.00000000 | 2019-11-12 15:52:06 |
  |  1 |           1 | 8719.79000000 | 2019-11-12 15:58:06 |
  |  2 |           2 |  185.36000000 | 2019-11-12 15:58:06 |
  |  3 |           3 |    0.27157609 | 2019-11-12 15:58:06 |
  |  4 |           4 |  287.40000000 | 2019-11-12 15:58:06 |
  |  5 |           5 |    1.00000000 | 2019-11-12 15:58:06 |
  +----+-------------+---------------+---------------------+
  </code></pre>
  
  <p>And now I need to do some date filters to this table, for example, I need to select 1 row per hour for last 7 days. Column <code>created_at</code> is dynamic. How can I do that in properly way? </p>
  
  <p><strong>UPD</strong>: mysql database, InnoDB. </p>
  
  <p><strong>UPD2</strong>: expected result is:</p>
  
  <pre><code>+----+-------------+---------------+---------------------+
  | id | currency_id | price_usd     | created_at          |
  +----+-------------+---------------+---------------------+
  |  1 |           1 | 8719.79000000 | 2019-11-12 15:52:06 |
  |  2 |           1 | 8719.79000000 | 2019-11-12 16:52:06 |
  |  3 |           1 | 8719.79000000 | 2019-11-12 17:52:06 |
  |  4 |           1 | 8719.79000000 | 2019-11-12 18:52:06 |
  |  5 |           1 | 8719.79000000 | 2019-11-12 19:52:06 |
  |  6 |           1 | 8719.79000000 | 2019-11-12 20:58:06 |
  |  7 |           1 | 8719.79000000 | 2019-11-12 21:58:06 |
  |  8 |           1 | 8719.79000000 | 2019-11-12 22:58:06 |
  |  9 |           1 | 8719.79000000 | 2019-11-12 23:58:06 |
  | 10 |           1 | 8719.79000000 | 2019-11-13 00:58:06 |
  +----+-------------+---------------+---------------------+
  </code></pre>
  
  <p>Interval between rows should be not less than 1 hour</p>