本文介绍了SQL SERVER SUM查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有以下表格 手机号码MessageStatus总共发送短信总扣除额度 9825589099已交付12 12 9825589099已发送23 23 9825589099已发送25 25 但我想要跟随 手机号码MessageStatus发送的总短信总扣除额度 9825589099交付12 12 9825589099已发送48 48 解决方案 你忘了 GROUP MessageStatus 栏 SELECT MobileNo,MessageStatus,SUM(TotalSMSSent) AS TotalSMSSent,SUM(TotalCreditDeducted) AS TotalCreditDeducted FROM [TableName] WHERE MobileNo = ' 9825589099' GROUP BY MobileNo,MessageStatus I have Following TableMobile NO MessageStatus Total SMS Sent Total Credit Deducted9825589099 Delivered 12 129825589099 Sent 23 239825589099 Sent 25 25But I want As FollowMobile NO MessageStatus Total SMS Sent Total Credit Deducted9825589099 Delivered 12 129825589099 Sent 48 48 解决方案 这篇关于SQL SERVER SUM查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 09:15