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
 Group Records By Year "YYYY"

Author  Topic 

s2002
Starting Member

49 Posts

Posted - 2007-09-24 : 18:07:10
I have 3 Field on my table.
ID (int PK),Name(nvarchar(50),PubDate(DateTime).
"PubDate" may have values between "1/1/1996" "1/1/2007"
NOw How could I group Table Records base on Year of the Field "PubDate"-1996,1997,...,2007-
As I think, First I must Retrieve each Record Year
suppose Record1 (ID=1 Name "Something" PubDate=2007) and then List and Group them.
But I don't whether this function Is available in MSSQL 2005.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-09-24 : 18:08:47
You can adapt Jeff's article to grouping by year: http://weblogs.sqlteam.com/jeffs/archive/2007/09/10/group-by-month-sql.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -