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

Sort fullname by lastname 2

Status
Not open for further replies.

cleanair4me

Technical User
May 16, 2008
61
I have a field called fullname that outputs records with fullname of people.
Here is what I have when I do a simple sql:
Select fullname from tableOne
Code:
John Jones
Bill Aronsen
Sam Baker
George Williams
Dave Smith

I would like to sort in order of last name but cant figure out how to do the sql. Please advise.
 
Don't people have middle initials like

Code:
John M. Doe
 
Dstxaix said:
Don't people have middle initials like
Code:
John M. Doe
Yes, they have, dstxaix...Good catch.


The best way to programmatically deal with that issue is to modify slightly Sem's fine code suggestion:
Code:
...order by substr(fullname, instr(fullname, ' '[B][I],-1[/I][/B])+1)...
The "-1" addition to Sem's code searches for the first blank space from the reverse (right-side) end of the string.

Let us know, CleanAir, if this resolves your need.


[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top