Cardinality Of The Transpose Result; Examples Of Transpose - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Cardinality of the TRANSPOSE Result

The items in each transpose-item-list are enumerated from 1 to N, where N is the total
number of items in all the item lists in the transpose sets.
In this example with a single transpose set, the value of N is 3:
TRANSPOSE (A,X),(B,Y),(C,Z) AS (V1,V2)
In this example with two transpose sets, the value of N is 5:
TRANSPOSE (A,X),(B,Y),(C,Z) AS (V1,V2)
The values 1 to N are the key values ki. The items in each transpose-item-list are the
expression values vi.
The cardinality of the result of the TRANSPOSE clause is the cardinality of the source table times
N, the total number of items in all the transpose item lists.
For each row of the source table and for each value in the key values ki, the TRANSPOSE result
contains a row with all the attributes of the source table, the key value ki in the key column, the
expression values vi in the value columns of the corresponding transpose set, and NULL in the
value columns of other transpose sets.
For example, consider this TRANSPOSE clause:
TRANSPOSE (A,X),(B,Y),(C,Z) AS (V1,V2)
KEY BY K
The value of N is 5. One row of the SELECT source table produces this TRANSPOSE result:
columns-of-source
source-row
source-row
source-row
source-row
source-row

Examples of TRANSPOSE

Suppose that MYTABLE has been created as:
CREATE TABLE $db.mining.mytable
( A INTEGER, B INTEGER, C INTEGER, D CHAR(2),
E CHAR(2), F CHAR(2) );
The table MYTABLE has columns A, B, C, D, E, and F with related data. The columns A, B, and
C are type INTEGER, and columns D, E, and F are type CHAR.
A
1
2
Suppose that MYTABLE has only the first three columns: A, B, and C. The result of the
TRANSPOSE clause has three times as many rows (because there are three items in the
transpose item list) as there are rows in MYTABLE:
SELECT * FROM mytable
TRANSPOSE A, B, C AS VALCOL
KEY BY KEYCOL;
L,M AS V3
L,M AS V3
K
1
2
3
4
5
B
C
10
100
20
200
V1
V2
value-of-A
value-of-X
value-of-B
value-of-Y
value-of-C
value-of-Z
NULL
NULL
NULL
NULL
D
d1
d2
V3
NULL
NULL
NULL
value-of-L
value-of-M
E
F
e1
f1
e2
f2
TRANSPOSE Clause
273

Advertisement

Table of Contents
loading

Table of Contents