Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: sql - denormalising ?
To do this :
id attribute attr_type
1 rough surface 2 blue color
and use "group by" clause :
select
id,
max(decode(attr_type,'surface' ,attribute,null)) surface,
max(decode(attr_type,'color' ,attribute,null)) color
from <table_name>
group by id
or
2) If table contains exactly 2 rows for each id and column order (color,surface) or (surface,color) is insignificant you can use:
select
id,
min(attiibute) surface_or_color,
max(attiibute) color_or_surface
from <table_name>
group by id
HTH.
"Carsten Jacobs" <carsten.jacobs_at_web.de> wrote :
> Hi,
>
> I have a table with multiple entries (2) for one entity like
>
> id attribute
> ---------------
> 1 yellow
> 1 rough
> 2 blue
> 2 smooth
>
> How can I get a result like
> 1 yellow rough
> 2 blue smooth
>
> Do I need a procedure for that or can I do it with a single sql statement?
Received on Wed Mar 21 2001 - 13:42:37 CST
![]() |
![]() |