[英]How can i calculate Grand Total.
I need grand total i have total Column and also some records. 我需要总计我有总计列和一些记录。
For example A and B Two columns and these columns amount equal to total. 例如A和B两列,这些列的数量等于合计。
ColA -------20 + ColB----------20 = Col Total------------40
ColA -------10 + ColB----------40 = Col Total------------50
So know i need grand total. 所以知道我需要总计。 Grand total this should amount be 90.How can i do this i am just need grand total.this should calculate total 40 and 50 equal 90.
总计总计应为90.我该怎么做,我只需要总计。应计算总计40和50等于90。
Grand Total = 90
So you have a table that looks like this: 因此,您有一个如下表:
ColA | ColB 20 | 20 10 | 40
And you want to output the sum of all those values. 您想输出所有这些值的总和。
Then I will advise you to sum all the values in the rows and then the values for all those rows this way: 然后,我建议您对行中的所有值求和,然后对所有这些行的值求和:
select sum(colA + colB) from table
Of course, if there are more columns you will have to add them inside the sum
function. 当然,如果有更多列,则必须将它们添加到
sum
函数中。
SELECT SUM(amountColumnName) FROM yourTable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.