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
 General SQL Server Forums
 New to SQL Server Programming
 Monthly report

Author  Topic 

mkgmahi
Starting Member

24 Posts

Posted - 2011-12-22 : 06:02:41
I want to retrieve data monthywise from Jan to dec
and to show the summary for the fields in the table
I have a date column in the table.
What is the function.
How it can to be done...
please advice

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-22 : 06:07:32
GROUP BY DATEADD(mm,DATEDIFF(mm,0,datefield),0) and then take SUM() your required fields.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mkgmahi
Starting Member

24 Posts

Posted - 2011-12-22 : 06:50:46
Thank you,,,, i will try this
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-22 : 10:39:30
try and let us know

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-22 : 10:55:59
Do you have more than 1 year's worth of data?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

mkgmahi
Starting Member

24 Posts

Posted - 2011-12-24 : 01:31:17
Thank you so much visakh. It was was working fine.


But how will i describe each row JAN to dec


x y
1 305
2 355
3 370
4 377
5 410
6 411
7 450
8 480
9 511
10 519
11 540
12 583
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-24 : 02:50:12
where are you showing the data? if its some reporting tool, you can use datefunctions to retrieve the month value

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mkgmahi
Starting Member

24 Posts

Posted - 2011-12-24 : 02:56:44
Hi vishakh,

I have used datename function and its working.

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-24 : 02:58:49
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -