如何根据月份和年份id重新发送sql中的数据 [英] How to reterive an data from sql on the basis of month and year id
本文介绍了如何根据月份和年份id重新发送sql中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个问题,
我有一张桌子,包括金额(十进制),MonthId(Int),年(int)
我想要在4(月),2013(年)之间重新计算金额之和3(月),2014(年)通过查询。
请,任何人都可以建议我怎么做..
Hello,
I have an problem that,
I have an table that consist of Amount(decimal),MonthId(Int),Year(int)
and I want to reterive an sum of amount between 4(Month),2013(Year) to 3(Month),2014(Year) through query.
Please,any one can suggest me how to do this..
推荐答案
尝试
从表中选择*,其中(Year> = 2013和Month> = 4)AND (年< = 2014和月< = 3)
您好,
尝试以下解决方案:
Hi,
Try following solution :
select SUM(amt) from
(
sELECT SUM(amount) amt FROM test1 WHERE ([month]>=3 and [year]=2013)
union
select sum(amount) amt from test1 where ([month]<=3 and [year]=2014)
) test
相应地更改年份和月份。
Change your year and month accordingly.
这篇关于如何根据月份和年份id重新发送sql中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文