簡體   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