SQL Server中列字段的总和 [英] Sum of column fields in SQL server
本文介绍了SQL Server中列字段的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张桌子如下: -
Hi,
I have a table as below:-
Date Qty Unit Rate Amount
2013-04-02 00:00:00.000 1 PCS 200.00 200.00
2013-04-02 00:00:00.000 2 PCS 230.00 460.00
2013-04-02 00:00:00.000 3 PCS 200.00 600.00
2013-04-02 00:00:00.000 320 PCS 178.00 56960.00
2013-04-02 00:00:00.000 360 PCS 118.00 42480.00
2013-04-03 00:00:00.000 360 PCS 142.00 51120.00
2013-04-03 00:00:00.000 360 PCS 178.00 64080.00
2013-04-03 00:00:00.000 480 PCS 116.00 55680.00
2013-04-04 00:00:00.000 480 PCS 134.00 64320.00
2013-04-04 00:00:00.000 520 PCS 132.00 68640.00
我想要上表的摘要:
2013-04-02 00:00:00.000 1046PCS 185.20 49136.00
2013-04-03 00: 00:00.000 1100PCS 145.33 113208.00
---
请帮我查询...
I want the SUMMARY of the above table:
2013-04-02 00:00:00.000 1046PCS 185.20 49136.00
2013-04-03 00:00:00.000 1100PCS 145.33 113208.00
---
Please help me with query...
推荐答案
这很简单:
This is quite simple:
select date, sum(qty), unit, avg(rate), sum(amount)
from yourtable
group by date, unit
这篇关于SQL Server中列字段的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文