Solved

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

Posted on 2014-07-31
2
590 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 37

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

752 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