现在sql可以查出数据,但我要求出三列的和,就是一列一个求和

CSDN问答 2021-12-30 11:27:24 阅读数:397

SQL 数据 现在 但我 查出
SELECT A.* FROM IF02 A WHERE a.aae100 = aae100 and a.aab004s = aab004s and a.aab005s = aab005s and a.aaz030 = aaz030 and a.aab999 = aab999 and a.aab004 = aab004 and a.ifa032=ifa032 and a.ifa031=ifa032

sql,写好了,但是我要ifa031,ifa032,aab004s 这三列的求和
我该在这个上面怎么改?




采纳答案:

用sum

SELECT sum(a.ifa031) as '你想要的列名', sum(a.ifa032) as '你想要的列名', sum(a.aab004s) as '你想要的列名' FROM IF02 A WHERE a.aae100 = aae100 and a.aab004s = aab004s and a.aab005s = aab005s and a.aaz030 = aaz030 and a.aab999 = aab999 and a.aab004 = aab004 and a.ifa032=ifa032 and a.ifa031=ifa03


其他答案2:
 SELECT sum(A.ifa031),sum(A.ifa032),sum(A.aab004s) FROM IF02 A WHERE a.aae100 = aae100 and a.aab004s = aab004s and a.aab005s = aab005s and a.aaz030 = aaz030 and a.aab999 = aab999 and a.aab004 = aab004 and a.ifa032=ifa032 and a.ifa031=ifa032 
版权声明:本文为[CSDN问答]所创,转载请带上原文链接,感谢。 https://ask.csdn.net/questions/7619906