繁体   English   中英

如何对不同的行记录求和

[英]How to Sum() Distinct Row records

我有一个表Purchase_table我在其中有具有相同值的唯一记录,因此能够使用“ Group by功能Group by来获得唯一行,但是我的要求是将这些记录求和并在与Total单行中显示。

我用这个查询

select date , invoiceno ,orgname as vendor , 
                    invoice_value as taxable_value ,sum(cgst_value) as cgst ,sum(sgst_value)  as sgst ,
                    sum(igst_value) as igst , invoice_value +cgst_value +sgst_value +igst_value as Invoice_value from purchase_table group by invoiceno union all select 'Total', '','', sum(invoice_value), sum(cgst_value), sum(sgst_value), sum(igst_value), sum(invoice_value +cgst_value +sgst_value +igst_value) from purchase_table group by invoiceno order by date, invoiceno

产量

[![This is the output of my query having Total in many line, i want the output in one line with all unique qroup by records][1]][1]

您只需在查询中输入限制1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM