[英]How to Sum() Distinct Row records
I have a table Purchase_table
i have unique records in it with same Values, so am able to get the unique row using Group by
Function, but my requirement i want so sum those records and show in single line With Total. 我有一个表
Purchase_table
我在其中有具有相同值的唯一记录,因此能够使用“ Group by
功能Group by
来获得唯一行,但是我的要求是将这些记录求和并在与Total单行中显示。
i used this query 我用这个查询
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
output 产量
[![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.