sql查询重复数据取最新一条

sql查询重复数据取最新一条

以上就是执行结果

思路:既然数据都重复,就时间不同,那就取max(时间)就行了吧,然后分个组。

结构如下:

select [去重字段],max(时间字段) from [表名] group by [去重字段] order by [时间字段] desc ;
SELECT distinct(FromUserID),max(create_time) FROM  online_customer_service group by FromUserID  order by create_time desc limit 20;

原创文章,作者:星辰,如若转载,请注明出处:http://www.z88j.com/207.html

(41)
打赏 微信扫一扫 微信扫一扫
上一篇 2021年3月19日 下午3:41
下一篇 2021年6月2日 下午7:17

相关推荐

发表回复

登录后才能评论

评论列表(1条)


Warning: error_log(/www/wwwroot/www.z88j.com/wp-content/plugins/spider-analyser/#log/log-2708.txt): failed to open stream: No such file or directory in /www/wwwroot/www.z88j.com/wp-content/plugins/spider-analyser/spider.class.php on line 2900