[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I make this query order by month: January, February, March....?

Posted on 2010-11-17
2
Medium Priority
?
406 Views
Last Modified: 2012-05-10
With the current query it orders the months alphabeticaly. How do I make it order correctly?
SELECT

  DATENAME(mm,FilteredNew_application.new_effectivestartdate) as Month
  ,sum(FilteredNew_application.new_gp) as GP
  ,sum(FilteredNew_application.new_approvalamount) as Approval
  ,sum(FilteredNew_application.new_equiptmentcost) as Revenue
  
FROM
  FilteredNew_application
WHERE
  FilteredNew_application.new_primaryvendoridname LIKE N'Dell%'
  AND FilteredNew_application.new_applicationstatusname = N'Vendors Paid'
AND FilteredNew_application.new_effectivestartdate >= N'02/01/2010 00:00:00'

Group by DATENAME(mm,FilteredNew_application.new_effectivestartdate)
Order by DATENAME(mm,FilteredNew_application.new_effectivestartdate)

Open in new window

0
Comment
Question by:varesources
2 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 2000 total points
ID: 34158388
Change the group by and order by. This won't affect your grouping.

Group by DateName(mm, ..date..), Month(..date..)
Order by Month(..date..)
0
 
LVL 1

Author Comment

by:varesources
ID: 34158406
Thank you!
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question