I have also seen some posts on the Internet, but there are still some problems in the actual operation. Please take a look at what the problem is.
demand is the latest record (add_time) of each item (goods_id) in the query tp_inventory_ log table;
the first statement I tried:
select * from (select goods_id, price, add_time from tp_inventory_log order by add_time desc limit 50) as til group by goods_id order by add_time desc limit 25;
shows that the result is
:
the only difference between these two statements is that there are more subquery statements in the first statement than limit 50, but the results are quite different.
1. The result of the second query statement does not show the data from April 23rd; the record with
2.goods_id of 1081 does not show the same result in the two query statements, and the desired result is the 17:14 result obtained by the first query statement.