首页 > 其他 > 详细

查询分组求和的最大值

时间:2020-09-09 16:44:56      阅读:61      评论:0      收藏:0      [点我收藏+]

求交易总额的最大值两种方法:

SELECT c.merchant_no,SUM(c.transaction_amount) AS tt FROM mer_detail c WHERE c.created_date >"2020-09-01" GROUP BY c.merchant_no ORDER BY tt DESC LIMIT 1;

SELECT MAX(dd.tt) from (SELECT c.merchant_no,SUM(c.transaction_amount) AS tt FROM mer_detail c WHERE c.created_date >"2020-09-01" GROUP BY c.merchant_no ) as dd ;

查询重复数据:

SELECT * FROM clear_mer_detail c GROUP BY c.transaction_no  HAVING COUNT(c.transaction_no)>1  ORDER BY c.created_date DES

 

查询分组求和的最大值

原文:https://www.cnblogs.com/pandaly/p/13638894.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!