[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 
 
相关推荐
一直学习永不止步8 小时前
LeetCode题练习与总结:H 指数--274
java·数据结构·算法·leetcode·数组·排序·计数排序
bug菌¹5 天前
滚雪球学MySQL[2.3讲]:MySQL数据过滤与排序详解:WHERE条件、ORDER BY排序与LIMIT分页查询
数据库·mysql·排序·order by·where条件·limit分页
Milkha7 天前
论文速读记录 - 202409
nlp·论文笔记·排序
希忘auto10 天前
详解常见排序
java·排序
伟大的车尔尼10 天前
排序题目:对角线遍历 II
排序
ID_云泽11 天前
MySQL自定义排序:使用ORDER BY FIELD实现灵活的数据排序
数据库·mysql·排序
UestcXiye14 天前
Leetcode16. 最接近的三数之和
c++·leetcode·排序·双指针·数据结构与算法
七折困16 天前
列表、数组排序总结:Collections.sort()、list.sort()、list.stream().sorted()、Arrays.sort()
java·集合·数组·排序
小李飞刀李寻欢2 个月前
NLP排序中的基础模型
人工智能·自然语言处理·nlp·排序·排序模型
小李飞刀李寻欢2 个月前
用于NLP领域的排序模型最佳实践
人工智能·自然语言处理·大模型·transformer·torch·模型·排序