Home » SQL & PL/SQL » SQL & PL/SQL » replace number in column
replace number in column [message #637255] Wed, 13 May 2015 09:28 Go to next message
hassan08
Messages: 123
Registered: June 2011
Location: egypt
Senior Member
i have data like this
1/200/10/1
1/200/10

i wanna remove 1 from 1/200/10/1
to finally will be 120010

Re: replace number in column [message #637258 is a reply to message #637255] Wed, 13 May 2015 09:40 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and read http://www.orafaq.com/forum/t/174502/
Re: replace number in column [message #637260 is a reply to message #637255] Wed, 13 May 2015 10:23 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Re: replace number in column [message #637274 is a reply to message #637255] Thu, 14 May 2015 06:45 Go to previous messageGo to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

first replace '/' from the value then select data from 2nd position.
now write code for this logic on your own. Smile
Re: replace number in column [message #637280 is a reply to message #637274] Thu, 14 May 2015 07:15 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
a hint. look at rtrim and replace
Re: replace number in column [message #637291 is a reply to message #637280] Thu, 14 May 2015 07:45 Go to previous messageGo to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

@hassan sorry for the wrong hint. dint look at output carefully. "after replacing / select whole data except for the last position. "

hint :- use replace/length/substr
Re: replace number in column [message #637307 is a reply to message #637291] Thu, 14 May 2015 11:39 Go to previous message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

There should be thousand rules to go from "1/200/10/1" to "120010".
It might be "whatever is the input the output is 120010".
So a valid query is:
select '120010' from mytable;

[Updated on: Thu, 14 May 2015 11:40]

Report message to a moderator

Previous Topic: Viewing Object values in select and fill (multiple rows)
Next Topic: Select best 2 value out of 3 three values
Goto Forum:
  


Current Time: Fri Aug 07 09:33:04 CDT 2026