Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Merge lines to get rid of nullvalues?
> A B C
> Key1 "text1" null
> Key1 null 7
> Key2 "text2" null
> Key2 null 3
> Key3 null 9
> Key4 "text4" null
> Key4 null 79
>
> B is a CHAR column and C is a NUM
>
> I want to merge the rows with the same key and put the values in the
> null-fields, like this:
>
> A B C
> Key1 "text1" 7
> Key2 "text2" 3
> Key3 null 9
> Key4 "text4"79
>
> As you can see, it is not always 2 keys, so some fields might still be
> null.
>
Something like this (not tested) should do most of the work. You just have to map chr(255) and 2000000000 to null.
select A, min(BV), min(CV)
from
(
select A, nvl(B, chr(255)) BV, nvl(C,2000000000) CV
from table1
)
Received on Mon Jul 28 2003 - 10:24:45 CDT