Oracle Using SDO AGGR UNION
From WickyWiki
Example using SDO_AGGR_UNION and SDOAGGRTYPE, the sourcetable kaartblad contains the final result of dividing an area in squares and subsquares. Each resulting subsquare has a squareNr and a subsquareNr. The following query joins union of all subsquares of each squareNr
DROP TABLE Test;
CREATE TABLE Test ( Shape MDSYS.SDO_Geometry, INFORM VARCHAR2(400) );
insert into test(shape, INFORM)
select SDO_AGGR_UNION(SDOAGGRTYPE(t.shape, 0.00000005)), TRIM(TO_CHAR(Substr(t.bladnr,1,2),'00'))
from kaartblad t
group by squareNr
order by squareNr;