[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 
 
相关推荐
梁辰兴3 天前
数据结构:排序
数据结构·算法·排序算法·c·插入排序·排序·交换排序
Tisfy3 天前
LeetCode 3027.人员站位的方案数 II:简单一个排序O(n^2)——ASCII图解
leetcode·题解·思维·排序·hard
胡斌附体6 天前
微信小程序 navigateTo 栈超过多层后会失效
微信小程序·小程序·失效·navigateto·自定义导航·relauch
hzhzh~1 个月前
【C++】神秘-希尔排序
c++·希尔排序·排序·sort
Alfred king1 个月前
Leetcode 四数之和
算法·leetcode·职场和发展·数组·排序·双指针
junjunyi1 个月前
【LeetCode 148】算法进阶:排序链表 ( 归并排序、快速排序、计数排序 )
链表·排序·分治·归并
Alfred king1 个月前
面试150 IPO
面试·职场和发展·贪心·数组··排序
今天背单词了吗9802 个月前
算法学习笔记:29.拓扑排序——从原理到实战,涵盖 LeetCode 与考研 408 例题
java·笔记·算法·拓扑排序·排序
NuyoahC2 个月前
HOT100——排序篇Leetcode215. 数组中的第K个最大元素
c++·leetcode·排序算法·排序
初级代码游戏2 个月前
WinUI3入门16:Order自定义排序
自定义·排序·order·winui3