We help IT Professionals succeed at work.
Get Started

Can you use a primary and secondary "order by" in SQL to arrange rows in a recordset?

elliottbenzle
on
455 Views
Last Modified: 2012-05-05
I'm using ASP/MS access/dreamweaver.

I have a table which contains two fields, one with the date and one with the time. The order is all mixed up. Right now my SQL orders the data according to the date.

"SELECT * FROM hilliardmicroschedule ORDER BY vardate ASC"

But I'm running into the problem that when the dates are the same the times are still all mixed up. Is there a way to alter the SQL so that it orders by vardate first and then orders by vartime. The resulting recordset should be ordered primarily by date and when the dates are the same it will order by time. I'm assuming the code would look something like this:

"SELECT * FROM hilliardmicroschedule ORDER BY vardate ASC (AND ORDER BY vartime ASC)"

You can see the problem on this page under the first schedule (hilliard micro-mini) where the date order is fine but the times are all mixed up.

http://www.glowfishtw.com/flagfootball/schedules.asp?reg=hilliard

Thanks for any help.
Comment
Watch Question
Just an IT guy :)
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE