gpt4 book ai didi

mysql - 如何在sql中获得不同的结果?

转载 作者:行者123 更新时间:2023-11-29 01:38:59 27 4
gpt4 key购买 nike

我正在尝试获得下表的不同结果

id  | name   | created_on
1 | xyz | 2015-07-04 09:45:14
1 | xyz | 2015-07-04 10:40:59
2 | abc | 2015-07-05 10:40:59

我想要不同的 id 最新的 created_on 意味着以下结果

1   | xyz    | 2015-07-04 10:40:59
2 | abc | 2015-07-05 10:40:59

如何通过sql查询得到上面的结果?

最佳答案

试试这个:

Select id, name, max(created_on) as created_on from table group by id

关于mysql - 如何在sql中获得不同的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31220671/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com