Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2008-04-10 : 05:02:31
|
| this is my sample records in my tableSdate AmountJanuary 2007 250000.00March 2007 300000.00January 2008 350000.00how can i get the amount from February to May 2007 and sum it up like thisDetailsFebruary 2007 250000.00March 2007 300000.00April 2007 300000.00May 2007 300000.00this is all that i want to getTotal Amount: 1,150,000.00i also posted this one in new to sql server section, but im hoping to get others opinion here. thnx |
|
|
Shamee_1321
Starting Member
15 Posts |
Posted - 2008-04-10 : 07:11:44
|
| try thisSELECT SUM(AMOUNT)AS TOTALAMOUNT FROM TABLENAMEWHERE DATEPART(MONTH,SDATE) > 2AND DATEPART(MONTH,SDATE) < 6AND DATEPART(YEAR,SDATE)=2007 |
 |
|
|
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2008-04-10 : 07:35:42
|
| this will only give me a sum of 300,000.00 i still need the amount for march,april,May. april and may amount will be base on the last month who have the amount. thats why the amount of april and may will be 300,000.00 like what i put in my details. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2008-04-10 : 07:49:12
|
| yes.. just hoping to get others opinion here. thnx |
 |
|
|
|
|
|