Solved

SQL - how to order a query result set by year and month

Posted on 2014-07-31
2
538 Views
Last Modified: 2014-07-31
Good Afternoon Experts,

I have a table that houses data over the period of 5 years.  The fields are
year
monthname
monthnumber
group
secondgroup
section
numbers

Problem:  I need to get a query result that will order the resultset by year then month.  So, in the best of all possible worlds, the result set would be ordered by
2010 jan
2010 feb
2010 Mar
and so on
2011 Jan
2011 Feb
2011 Mar
and so on
2012 Jan
2012 Feb
2012Mar
and so on

Is this possible?

Thank you !
0
Comment
Question by:UserName935
2 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 250 total points
Comment Utility
Order by year and monthnumber.

If Year is actually the name of the column, change it if you can.  You should not use the names of functions, methods, or properties - or any other reserved words as column names in tables.

Short of memorizing long lists of reserved words, the best technique is to use compound names
RptYear, ProjSection.
0
 
LVL 21

Assisted Solution

by:Randy Poole
Randy Poole earned 250 total points
Comment Utility
Select * from yourtable order by [year],[monthnumber]
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now