View previous topic :: View next topic |
Author |
Message |
psmadhusudhan Beginner

Joined: 28 Nov 2006 Posts: 143 Topics: 48
|
Posted: Fri Aug 31, 2007 3:16 am Post subject: Query for formatting the column |
|
|
I have table Employee with two fields
Name[x(20)] and Salary[9(10)]
The data will be as follows
Code: | NAME SALARY
----+----1----+----2----+----
RAKESH- 125000
RAVI- 90000
MADHU SUDHAN- 10000
SOMASHEKAR- 13457 |
I require a query which will format the employee name by removing "-"
which is at end of each name and display the data as follows
Code: | NAME SALARY
----+----1----+----2----+----
RAKESH 125000
RAVI 90000
MADHU SUDHAN 10000
SOMASHEKAR 13457 |
Please help me in achieving this. _________________ Thanks
Madhu Sudhan |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
psmadhusudhan Beginner

Joined: 28 Nov 2006 Posts: 143 Topics: 48
|
Posted: Fri Aug 31, 2007 8:06 am Post subject: |
|
|
Thanks Kolusu.
I have one question, I am not getting mails when a reply is posted for my post even though I am selecting 'Notify me when a reply is posted'.
Can you help me in this. _________________ Thanks
Madhu Sudhan |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Aug 31, 2007 10:30 am Post subject: |
|
|
Quote: |
I have one question, I am not getting mails when a reply is posted for my post even though I am selecting 'Notify me when a reply is posted'.
|
psmadhusudhan,
The feature is working fine. You should be getting the emails to the mail id specified in the Profile.
http://www.mvsforums.com/helpboards/profile.php?mode=editprofile
Make sure you have the right address. If you have the right email address then may be your client is blocking the emails.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
bstillwa Beginner
Joined: 01 Nov 2004 Posts: 23 Topics: 6 Location: NJ
|
Posted: Fri Aug 31, 2007 11:45 am Post subject: |
|
|
I believe that using REPLACE will replace all occurrences of a dash, so if a name contains a dash in other than the last position, then that dash will also be removed. The question was for only removing a trailing dash. _________________ Bev. |
|
Back to top |
|
 |
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Fri Aug 31, 2007 12:02 pm Post subject: |
|
|
Try this:
Code: |
select last_name
,case substr(last_name,length(rtrim(last_name)),1)
when '-' then substr(last_name,1,length(rtrim(last_name)) - 1)
else last_name
end
from tbl_01 |
|
|
Back to top |
|
 |
advoss Beginner
Joined: 23 Aug 2005 Posts: 26 Topics: 0
|
Posted: Fri Aug 31, 2007 12:02 pm Post subject: |
|
|
how about
select left(name,length(name)-1) as name,salary
from table;
or
select substr(name,1,length(name)-1) as name,salary
from table; _________________ Alan Voss |
|
Back to top |
|
 |
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Fri Aug 31, 2007 12:15 pm Post subject: |
|
|
Easier yet is the STRIP function.
Code: |
select last_name
,strip(last_name,t,'-')
from tbl_01
|
(I'm running UDB on AIX and can't test this because STRIP isn't supported, but I think the syntax is correct for DB2 for z/OS) |
|
Back to top |
|
 |
videlord Beginner
Joined: 09 Dec 2004 Posts: 147 Topics: 19
|
Posted: Fri Aug 31, 2007 2:51 pm Post subject: |
|
|
try strip(rtrim(name),t,'-') |
|
Back to top |
|
 |
psmadhusudhan Beginner

Joined: 28 Nov 2006 Posts: 143 Topics: 48
|
Posted: Mon Sep 03, 2007 12:09 am Post subject: |
|
|
Thank you all for your replies  _________________ Thanks
Madhu Sudhan |
|
Back to top |
|
 |
|
|