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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need To Sort Records By Two Feilds

Status
Not open for further replies.

alljax

ISP
Nov 24, 2000
10
US
I am currently counting multiple values in the same field and sorting by SiteID # (SitID), but I would like to also sort by month. How can I do this?

Example:

Date
---------------
January
February
March
April
Etc.


I want to be able to sort by Site ID (SitID) and month.

Current script that is sorting by SiteID (SitID):

sql = "SELECT FinLog.LoaSta, Count(FinLog.SitID) AS Records FROM FinLog GROUP BY FinLog.LoaSta, FinLog.SitID HAVING (((FinLog.SitID)='"&SitID&"')) ORDER BY FinLog.LoaSta DESC"

~ Chris
 
Add multiple sort columns using a comma as a delimiter

ORDER BY col1, col2, col3

Hope this helps
-pete
 
Hi Chris,
From what has gone on previously with this issue, I can add that as you are selecting particular SitID's in your SQL statement, there is no point in sorting by this field - sort order of one repeating SitID will be the same - which is why I swapped the ORDER BY field in my e mail. I should have mentioned this in my e mail.
If you add the date field to your query in the ORDER BY clause you will get errors, as you are not grouping by the field, which is why I specified doing this in multiple steps in my e mail.

Did you get any of it to work??

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top