Examples Of Transpose - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Data Type of the TRANSPOSE Result
The data type of each of the value columns is the union compatible data type of the corresponding
expressions in the transpose-item-list. You cannot have expressions with data types that
are not compatible in a transpose-item-list.
For example, in TRANSPOSE (A,X),(B,Y),(C,Z) AS (V1,V2), the data type of V1 is the union
compatible type for A, B, and C, and the data type of V2 is the union compatible type for X, Y,
and Z.
See
"Comparable and Compatible Data Types" (page
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 mining.mytable
( A INTEGER, B INTEGER, C INTEGER, D CHAR(2),
E CHAR(2), F CHAR(2) );
L,M AS V3
L,M AS V3
K
1
2
3
4
5
245).
V1
V2
value-of-A
value-of-X
value-of-B
value-of-Y
value-of-C
value-of-Z
NULL
NULL
NULL
NULL
V3
NULL
NULL
NULL
value-of-L
value-of-M
TRANSPOSE Clause
331

Advertisement

Table of Contents
loading

Table of Contents