This topic is locked

Can I sort by more than one column?

4/2/2007 9:02:07 AM
ASPRunnerPro General questions
G
grinningdog author

I've got a list of people and separate fields for last name and first name. I can sort by LastName but can I also sort by FirstName if there are people with the same last name?
For example currently I have: _list.asp?orderby=aLastName

Jones John

Smith Peter

Smith Alan
But I'd like:

Jones John

Smith Alan

Smith Peter
I've tried some obvious examples but none have worked

V
Vladimir 4/2/2007

Hi,
you have 2 ways:

  1. In ASPRunner on Edit SQL query tab click on change Order by button and choose 2 fields: lastname and firstname.
  2. Add calculated field to your SQL query and use it for ordering:
    select [lastname]+ [firstname] as [lastfirstname], ...

G
grinningdog author 4/2/2007

Thanks Vladimir. I'll probably use the first method for more formal sorting but is there a less formal way of doing it with the url? Like _list.asp?orderby=aLastName&aFirstName or similar?

Sergey Kornilov admin 4/3/2007

select [lastname]+ [firstname] as [lastfirstname], ...


Having Vladimir's advise implemented you can use the following URL:

_list.asp?orderby=aLastFirstName


Currently we don't have any other way to implement multi-column sorting.

G
grinningdog author 4/4/2007

Sergey
Thanks for the clarification.
Regards

Bob