DECODE [message #40323] |
Fri, 27 September 2002 07:23 |
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 |
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
|
|
|