Home » SQL & PL/SQL » SQL & PL/SQL » DECODE
DECODE [message #40323] Fri, 27 September 2002 07:23 Go to next message
premila
Messages: 10
Registered: September 2002
Junior Member
hi,

i'm trying to clean my data in the data warehouse schema. i have a table Employee which has column sex. the data in this field is mixture, some rows have F, while others have Female, how do i use the Decode statement to solve this.

i also have nulls in some of the columns of a table, what can i use to update the whole table at a time instead updating a row at a time.

cheers
Premila
Re: DECODE [message #40324 is a reply to message #40323] Fri, 27 September 2002 07:42 Go to previous message
Jon
Messages: 483
Registered: May 2001
Senior Member
SQL> create table t1 (gender varchar2(10));

Table created.

SQL> insert into t1 values('M');

1 row created.

SQL> insert into t1 values('Male');

1 row created.

SQL> insert into t1 values('F');

1 row created.

SQL> insert into t1 values(null);

1 row created.

SQL> insert into t1 values('Female');

1 row created.

SQL> update t1 set gender=(DECODE(gender,'Female','F','F','F','Male','M','M','M','U'));

5 rows updated.

SQL> select * from t1;

GENDER
----------
M
M
F
U
F
Previous Topic: Submit a Table Name as a Parameter to a Procedure for Processing?
Next Topic: partitioned table working as expected
Goto Forum:
  


Current Time: Sun Apr 28 20:41:37 CDT 2024