SQL分组排序语句
程序员文章站
2024-03-12 17:26:08
...
product_id是多个重复的,需求是每个product_id只取一条,并且id倒序排列。
SQL语句:SQL语句:
SELECT * from (
SELECT * from shop_product_snapshot GROUP BY product_id,id ORDER BY product_id,id DESC
) AS shop_product_snapshot GROUP by product_id ORDER BY `id` DESC