mysql 中关于怎么写 row_number()over(order by) 类似的功能支持
官网说明类似的支持:http://www.mysqltutorial.org/mysql-row_number/
根据说明排序 再根据条件判断是否一致 来决定是否新增 1
SELECT b.* FROM ( SELECT (@row_number := CASE WHEN @region_id = region_id AND @oil_id = oil_id THEN @row_number + 1 ELSE 1 END ) AS rn, id, oil_date, (@region_id := region_id) AS region_id, (@oil_id := oil_id) AS oil_id , last_update_time FROM `bwoil_prod_oil_price` s, (SELECT @row_number:=0) AS t WHERE audit_status=1 AND STATUS =0 ORDER BY region_id,oil_id ,oil_date DESC,last_update_time DESC ) a INNER JOIN `bwoil_prod_oil_price` b ON a.id = b.id WHERE a.rn = 1
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步