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

Decode Function 1

Status
Not open for further replies.

shaleen7

MIS
Jun 23, 2002
188
US
In my SQL statement I'm replacing any instance of JP with the letter 'X.
SELECT COUNTRYtable, DECODE(COUNTRYtable, 'JP', 'X')
FROM ,~OWNER~. COUNTRYtable
WHERE
COUNTRYtable = 'JP'

but.....

I want to replace all countries listed in my where clause with the letter 'x'.


SELECT COUNTRYtable, DECODE(COUNTRYtable, '?', 'X')
FROM ,~OWNER~. COUNTRYtable
WHERE
COUNTRYtable in 'JP','US','CA','KR'

Is there a similiar function that I can place in the select statement where I can replace ALL countries listed in my where clause with the letter 'x'.

Any suggestions?
Thanks
 
If you need to replace ALL country codes I see no reason for checking this value at all:

SELECT COUNTRYtable, 'X'
FROM ,~OWNER~. COUNTRYtable
WHERE
COUNTRYtable in 'JP','US','CA','KR'

I'm also not sure that DECODE (at least the way you use it) is appropriate for your task.

Regards, Dima
 
Hi,
It is not clear what you want to do.
If all you want is to show 'X' instead of the actual CountryTable value then:
Code:
Select 'X' from 
FROM ~OWNER~. COUNTRYtable
 WHERE 
COUNTRYtable in ('JP','US','CA','KR')

will do it, but I am pretty sure that's not what you are asking..Please post a sample of the output you expect..

[profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top