If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > how to sort by breaking a word

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-04, 01:46
quiver quiver is offline
Registered User
 
Join Date: May 2004
Posts: 2
how to sort by breaking a word

Hi!

I have a strange problem...I get a name(that is a combination of first and last name,seperated by a . ), is it possible that we can sort on either the first or the last name.

Thanks is anticipation....

quiver
Reply With Quote
  #2 (permalink)  
Old 05-21-04, 04:38
RKrick RKrick is offline
Registered User
 
Join Date: Feb 2002
Location: Germany
Posts: 141
It's possible, but you must check if it performs good. Just break the column into pieces. If you have allways the same pattern (fname.lname) you could do something like:

SELECT SUBSTR(your_column, 1, LOCATE('.', your_column)-1) AS fname
,SUBSTR(your_column, LOCATE('.', your_column)+1) AS lname
FROM your_table
ORDER BY 1
or
ORDER BY 2

HTH
__________________
Rodney Krick
Reply With Quote
  #3 (permalink)  
Old 05-22-04, 10:11
quiver quiver is offline
Registered User
 
Join Date: May 2004
Posts: 2
Quote:
Originally Posted by RKrick
It's possible, but you must check if it performs good. Just break the column into pieces. If you have allways the same pattern (fname.lname) you could do something like:

SELECT SUBSTR(your_column, 1, LOCATE('.', your_column)-1) AS fname
,SUBSTR(your_column, LOCATE('.', your_column)+1) AS lname
FROM your_table
ORDER BY 1
or
ORDER BY 2

HTH
Thanks a lot....it worked out perfectly
regards
quiver
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On