SQL Query Group By Months

Hi All

I have the following query in SQL

SELECT     createdon, projcode, result
FROM         dbo.dmsproj

The createdon column consists Ranging From 2000-12-20 - Current date

Can anybody help me Group These dates into Month Name ie: January, February etc

Thanks

John

pepps11976Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick MatthewsCommented:
John,

What sort of results are you after?

Patrick
0
pepps11976Author Commented:
I need yo create a bar graph out of the data so i need to group all the dates into Months

The raw data looks like this

Createdon                Projcode                   Result
2009-12-07             OPP002                      WIP
2009-12-08             OPP003                      WON
2009-12-09             OPP004                      LOST
2009-12-10             OPP005                      Lost
2009-12-11             OPP006                      WON

there is about 2000 results like this and i need to build a bar graph to show over the years orders we have won lost or are working on.

John
0
sventhanCommented:
to get the month name === >DATENAME(month, createdon)

try something like this...

SELECT      DATENAME(month, createdon),count(*)
FROM         dbo.dmsproj
group by DATENAME(month, createdon)
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

sventhanCommented:
0
pepps11976Author Commented:
Ok Thats goo but how can i add the year onto the end of the month
0
pepps11976Author Commented:
i was going to use excel but i need it in sql so that i can display as dashboard
0
sventhanCommented:
SELECT      DATENAME(month, createdon) + DATENAME(year, createdon), projcode, result,count(*)
FROM         dbo.dmsproj
group by DATENAME(month, createdon) + DATENAME(year, createdon) ,projcode, result

check this out for more reference...

http://www.experts-exchange.com/Programming/Languages/SQL_Syntax/Q_24714876.html?sfQueryTermInfo=1+10+30+datenam+group+month+year
0
pepps11976Author Commented:
Perfect thankyou i will issue points

Just one more quick question it may mean reposting

But if i wanted to do a rolling twelve months from current month back 12 months, is this possible or shall i post another question.

Thanks Again

John
0
sventhanCommented:
< But if i wanted to do a rolling twelve months from current month back 12 months, is this possible or shall i post another question

Yes. its possible. You could use DATEADD function to achieve that result.

Please post another question.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.