次の例では、テーブルTに例: 1つの入力行列、単一のSQL文および例: 1つの入力行列、複数のSQL文のテーブルTと同じ気象データがあります。この例では、観測地点に加えて、大陸用に追加のVARCHAR列があり、行列IDで表わしています。この目的は、大陸のデータごとに1つずつ、計7個のSSCP行列を生成することです。
CALCMATRIXを計2回、1回はLOCALフェーズのため、もう1回はCOMBINEフェーズのために呼び出すSQL文を使用します。
select * from calcmatrix( ON (
select * from calcmatrix( ON (select continent, temperature, air_pressure, rainfall from T) LOCAL ORDER BY continent USING PHASE('LOCAL') )X )
HASH BY continent
LOCAL ORDER BY continent
USING PHASE('COMBINE')
)Y
order by continent, rownum;
次のテーブルの結果セットは、大陸別の気象データのSSCP行列です。
その行列のうち2つのみを次に示します。
| continent | rownum | rowname | temperature | air_pressure | rainfall |
|---|---|---|---|---|---|
| Europe | 1 | temperature | n | n | n |
| Europe | 2 | air_pressure | n | n | n |
| Europe | 3 | rainfall | n | n | n |
| continent | rownum | rowname | temperature | air_pressure | rainfall |
|---|---|---|---|---|---|
| Asia | 1 | temperature | n | n | n |
| Asia | 2 | air_pressure | n | n | n |
| Asia | 3 | rainfall | n | n | n |