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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Sum amt based on Month wise in sqlserver2008

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2013-05-25 : 01:54:34
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

545 Posts

Posted - 2013-05-25 : 03:36:31
[code]
select
year(Date)*100 + month(Date) as MonthWise
,sum(Amt) as Amt
from Table
group by year(Date)*100 + month(Date)[/code]

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

52326 Posts

Posted - 2013-05-25 : 09:37:08
[code]
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)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -