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 |
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 fieldmy date filed along with date is therei want to get the amt based on MONTH WISEdate amt2013-10-25 298772013-09-18 2323422013-07-16 34322013-07-14 43992012-03-18 45902013-09-01 565465ANYONE 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 Amtfrom Tablegroup by year(Date)*100 + month(Date)[/code]Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mutsabinWeb |
|
|
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 TotalFROM tableGROUP BY DATEADD(mm,DATEDIFF(mm,0,[date]),0)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|