SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kond.mohan
Posting Yak Master

India
196 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
Constraint Violating Yak Guru

Romania
434 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
52317 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000