View previous topic :: View next topic |
Author |
Message |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Fri Nov 10, 2006 4:16 pm Post subject: Convert to logical 1 or 0 |
|
|
Column X may have any of these values: 'A', 'B','C' or 'D'. I want to show a logical '1' when columnX = 'B' and '0' for all others. This will work:
Code: |
SELECT
CASE COLX
WHEN 'B' then 1
Else 0
END
|
Is there other way to produce the same result? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12383 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Mon Nov 13, 2006 9:06 am Post subject: |
|
|
Kolusu,
The result from your query is:
Code: |
COL1 COL2
---- ----
A A
B 1
C C
D D
|
The following will work:
Code: |
SELECT COL1,
TRANSLATE(COL1,'1000','BACD')
FROM TABLE;
|
But this is not really exactly I am lookin for. I don't want to list every possible characters (may be unlimited) in the translation string. |
|
Back to top |
|
 |
|
|