如何根据日期列计算(总和)列值 [英] How to compute(sum) column values according to date column

查看:96
本文介绍了如何根据日期列计算(总和)列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据表,其中有2个日期列和2个金额列

我想分别计算2013年和2014年的金额

注意:日期是mmmddyyyy格式



I have a datatable in which there are 2 date column and 2 amount column
I want to sum the amountpaid for 2013 and 2014 seperately
Note:Date is in mmmddyyyy format

inputmonth     stamp2datetime  amountpaid  stampdutypaid

2/1/2014 0:00   2/21/2014 17:58    550     100
2/1/2013 0:00   2/26/2013 18:29    550     100
2/1/2014 0:00   2/5/2014 11:05     100     360
2/1/2014 0:00   2/14/2014 12:57    5650    28250
2/1/2014 0:00   2/14/2014 13:15    100     300
2/1/2014 0:00   2/20/2014 12:39    770     3950
2/1/2014 0:00   2/18/2014 18:05    1240    6175
2/1/2013 0:00   2/20/2013 12:19    120     600
2/1/2013 0:00   2/20/2013 15:34    100     200
2/1/2013 0:00   2/20/2013 17:51    100     100
2/1/2013 0:00   2/20/2013 17:23    100     250
2/1/2014 0:00   2/21/2014 17:34    790     3950
2/1/2014 0:00   2/28/2014 18:25    2350    7035
2/1/2014 0:00   2/26/2014 16:01    100     15
2/1/2014 0:00   2/28/2014 12:37    4330    12990





sumObject = table.Compute(Sum(amountpaid),inputmonth = 2013​​);

我希望o在datemonth和stamp2datetime为2013的日期列上过滤数据表。



sumObject = table.Compute("Sum(amountpaid)", "inputmonth= 2013");
I want o filter the datatable on date columns where inputmonth and stamp2datetime is 2013.

推荐答案

尝试这个可能会帮助你





SELECT DATEADD (dd,0,DATEDIFF(dd,0,p_date))[dat e],

SUM(p_amount)[sum]

来自付款

WHERE DATEADD(dd,0,DATEDIFF(dd,0,p_date) ))BETWEEN'20130701'和'20130731'

GROUP BY DATEADD(dd,0,DATEDIFF(dd,0,p_date))
try this one it may help u


SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, p_date)) [date],
SUM(p_amount) [sum]
FROM Payments
WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, p_date)) BETWEEN '20130701' AND '20130731'
GROUP BY DATEADD(dd, 0, DATEDIFF(dd, 0, p_date))


这篇关于如何根据日期列计算(总和)列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆