How to select the latest price for product? : <p>Here is my table:</p>

<pre><code>+----+------------+-----------+---------------+
| id | product_id |   price   |     date      |
+----+------------+-----------+---------------+
| 1  | 4          | 2000      | 2019-02-10    |
| 2  | 5          | 1600      | 2019-02-11    |
| 3  | 4          | 850       | 2019-02-11    |
| 4  | 5          | 1500      | 2019-02-13    |
+----+------------+-----------+---------------+
</code></pre>

<p>I need to get a list of unique product ids that are the latest (newest, in other word, bigger <code>date</code>) ones. So this is the expected result:</p>

<pre><code>+------------+-----------+---------------+
| product_id |   price   |     date      |
+------------+-----------+---------------+
| 4          | 850       | 2019-02-11    |
| 5          | 1500      | 2019-02-13    |
+------------+-----------+---------------+
</code></pre>

<p>Any idea how can I achieve that?</p>

<hr>

<p>Here is my query:</p>

<pre><code>SELECT id, product_id, price, MAX(date)
FROM tbl
GROUP BY product_id
-- ot selects the max `date` with random price like this:
    +------------+-----------+---------------+
    | product_id |   price   |     date      |
    +------------+-----------+---------------+
    | 4          | 2000      | 2019-02-11    |
    | 5          | 1600      | 2019-02-13    |
    +------------+-----------+---------------+
-- See? Prices are wrong
</code></pre>
