本文介绍了在编写SQL查询时需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
Hi all
tax type date taxname a1 a2 a3 a4 --------- -------------------- ----------- ---- ------ ---- ---- "No Tax";"2014-01-28 15:17:14";"Inclusive";0.00;132.00;0.00;132.00 "No Tax";"2014-01-29 12:45:02";"Inclusive";0.00;148.00;0.00;148.00 "No Tax";"2014-01-29 14:07:07";"Inclusive";0.00;180.00;0.00;180.00 "No Tax";"2014-01-29 14:17:42";"Inclusive";0.00;50.00;0.00;50.00 "No Tax";"2014-01-29 14:49:39";"Inclusive";0.00;185.00;0.00;185.00 "No Tax";"2014-02-01 11:00:19";"Inclusive";0.00;165.00;0.00;165.00 "No Tax";"2014-02-03 11:52:26";"Inclusive";0.00;66.00;0.00;66.00 "No Tax";"2014-02-03 13:37:09";"Inclusive";0.00;185.00;0.00;185.00 "No Tax";"2014-03-30 17:14:36";"Inclusive";0.00;37.00;0.00;37.00 "VAT 1";"2014-01-07 11:01:01";"Inclusive";1.00;29.70;0.30;30.00 "VAT 1";"2014-01-08 18:44:07";"Inclusive";1.00;178.22;1.78;180.00 "VAT 1";"2014-01-15 15:48:23";"Inclusive";1.00;69.50;0.70;70.20 "VAT 1";"2014-01-16 13:15:37";"Inclusive";1.00;24.75;0.25;25.00 "VAT 1";"2014-01-18 17:35:19";"Inclusive";1.00;247.52;2.48;250.00 "VAT 1";"2014-03-30 13:04:24";"Inclusive";1.00;49.50;0.50;50.00 "VAT 2";"2014-01-01 11:13:54";"Inclusive";2.00;233.33;4.67;238.00 "VAT 2";"2014-01-01 11:55:34";"Inclusive";2.00;98.04;1.96;100.00 "VAT 2";"2014-01-01 12:23:34";"Inclusive";2.00;490.20;9.80;500.00 "VAT 2";"2014-01-01 13:13:19";"Inclusive";2.00;26.47;0.53;27.00 "VAT 2";"2014-01-01 14:16:49";"Inclusive";2.00;93.33;1.87;95.20 "VAT 2";"2014-03-30 19:44:09";"Inclusive";2.00;284.31;5.69;290.00 "VAT 3";"2014-01-01 11:02:49";"Inclusive";5.50;246.45;13.55;260.00 "VAT 3";"2014-01-01 11:04:28";"Inclusive";5.50;184.83;10.17;195.00 "VAT 3";"2014-01-01 11:13:54";"Inclusive";5.50;227.49;12.51;240.00 "VAT 3";"2014-01-01 11:13:54";"Inclusive";5.50;244.93;13.47;258.40我有这张桌子。 正如你所看到的那样,税收类型的价值超过一个。 所以我想做的是我必须显示每种税种的总和(a2) 表示我想要这样的输出
I have this table. As you can see tax type is having more then one value. so what i want to do is i have to display the sum(a2) for each tax type means i want the output like this
"No Tax";"2014-01-28 15:17:14";"Inclusive";0.00;50.000;0.00;700.00 "VAT 2";"2014-01-01 11:13:54";"Inclusive";200.00;244.93;13.47;258.40 "VAT 3";"2014-01-01 11:13:54";"Inclusive";800.00;244.93;13.47;258.40请告诉我如何编写查询 这就是我试过的事情
Please tell me how to write the query This is what i tried
select to_char(td.bill_date,'MM-dd-yyyy') as bill_date,td.tax_name,td.tax_type,td.tax_value, ((td.item_total) -(td.tax_amount)) as SaleValue, (td.tax_amount) as tax_amount, (td.item_total) as Total from tbl_transaction_details td join tbl_transaction_master tm on td.bill_no=tm.bill_no Where to_char(td.bill_date,'MM-dd-yyyy')>='03-01-2014' and to_char(td.bill_date,'MM-dd-yyyy')<='03-02-2014' and td.account='ABCD' and td.menu='ABCD' and tm.card>0 group by td.tax_amount,td.item_total,td.bill_date,td.tax_name,td.tax_type,td.tax_value order by td.bill_date,td.tax_value ASC;请大家,需要你的帮助..
Please guys, need your help..
推荐答案检查以下查询, Check with following query, select Tax,Type,TaxName,SUM(a2) as total from Table_1 group by Tax,Type,TaxName;
为什么group by子句不起作用..... 这将是你的解决方案 Why group by clause is not working..... This will be your solution Select TaxType,TaxName,SUM(a2) as total from Table_Name group by TaxType,TaxName,a2
更多推荐
在编写SQL查询时需要帮助
发布评论