SQL Language (MOSC)

MOSC Banner

Use Decode?

edited Mar 14, 2012 11:57PM in SQL Language (MOSC) 9 commentsAnswered ✓
Hi,

I have a table like this

Table Name: CONFIG_STR_T

STR_CODE

----------------

'MBU'

'MBD'

'MBT'

'MIN'

'FRE'

My Requirement: For the rows starting with MB i want the result to be displayed as 'MB' instead of its actual value. For the other records, I want their original values.

REQUIRED OUTPUT:

STR_CODE

----------------

'MB'

'MB'

'MB'

'MIN'

'FRE'

I tried using the following SQL:

select decode(str_code, regexp_like 'MB%', 'MB', str_code) from CONFIG_STR_T;

I am getting error while trying to execute this query. Please let me know which is the best way to get my required output. Also please enlighten on where I went wrong.

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center