Solved

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

Posted on 2014-07-31
2
552 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
ID: 40232042
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
ID: 40232046
Select * from yourtable order by [year],[monthnumber]
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

910 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

23 Experts available now in Live!

Get 1:1 Help Now