Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Multiple Sort Help

Status
Not open for further replies.

sgore

Programmer
Jul 22, 2001
30
CA
I need a quick way to sort by two seperate fields in a database.

field1 = month
field2 = day

I would like to sort by month first and print out the month (only once) and then sort the days in that month. One I get to another month I need to repeat the process

Here is the current SQL I have:
mySQL ="select * from practice order by month Ascending"

is there anyway to add the second sort (sort by day ascending) into the SQL statement above?

 
Never mind... I am an idiot....

select * from practice order by month, day ascending
 
Not really.

Tip: When working with certain types of recordsets, you can sort or filter after you have populated the recordset as well.

Once your recordset is populated, you can issue sql statements on the recordset using the sort and filter methods. Like this.

Rs.Sort = "month, day DESCENDING"

OR

Rs.Filter = "month = 'March' AND day = '1'"

Just some food for thought ..

TW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top