[MySQL]order by失效

失效语句:

获取的change_date不是最大值

sql 复制代码
select product_id, new_price, change_date
from (
  select product_id ,new_price, change_date
  from Products 
  order by change_date desc 
) as a
group by product_id 
 

生效语句:

增加distinct使order by生效

sql 复制代码
select product_id, new_price, change_date
from (
  select distinct(product_id) product_id, new_price, change_date
  from Products 
  order by change_date desc 
) as a
group by product_id 
 
相关推荐
T.Ree.3 天前
【数据结构】_排序
数据结构·算法·排序算法·排序
laufing6 天前
OD 算法题 B卷【比赛】
数据结构·排序·逻辑分析
Tipriest_14 天前
【C++20新特性】ranges::sort()使用方法,优势,注意点
算法·leetcode·c++20·排序·sort
阳洞洞17 天前
leetcode 148. Sort List
leetcode·链表·归并排序·递归·排序
winfredzhang19 天前
打造高效数据处理利器:用Python实现Excel文件智能合并工具
python·excel·合并·排序·xlsx
GUIQU.20 天前
【每日一题丨2025年5.12~5.18】排序相关题
算法·排序·每日一题
Espresso Macchiato21 天前
Leetcode 3551. Minimum Swaps to Sort by Digit Sum
leetcode·排序·leetcode medium·leetcode 3551·leetcode周赛450
吗喽对你问好1 个月前
华为5.7机考第一题充电桩问题Java代码实现
java·华为·排序
yxc_inspire1 个月前
常见排序算法记录和理解
算法·排序
Tisfy2 个月前
LeetCode 2563.统计公平数对的数目:排序 + 二分查找
python·算法·leetcode·二分查找·题解·排序