Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Sum amt based on Month wise in sqlserver2008
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kond.mohan
Posting Yak Master

India
213 Posts

Posted - 05/25/2013 :  01:54:34  Show Profile  Reply with Quote
Hi,
i have two fields, one is date field and anoher amt field
my date filed along with date is there
i want to get the amt based on MONTH WISE

date amt
2013-10-25 29877
2013-09-18 232342
2013-07-16 3432
2013-07-14 4399
2012-03-18 4590
2013-09-01 565465

ANYONE KNOWS HELP ME

stepson
Aged Yak Warrior

Romania
545 Posts

Posted - 05/25/2013 :  03:36:31  Show Profile  Reply with Quote

select
	year(Date)*100 + month(Date) as MonthWise
	,sum(Amt) as Amt
from Table
group by year(Date)*100 + month(Date)


Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut
sabinWeb
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 05/25/2013 :  09:37:08  Show Profile  Reply with Quote

SELECT DATEADD(mm,DATEDIFF(mm,0,[date]),0) AS monthDate,SUM(amt) AS Total
FROM table
GROUP BY DATEADD(mm,DATEDIFF(mm,0,[date]),0)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000