Neoview SQL Reference Manual (R2.2)
The result table of the TRANSPOSE query is:
VALCOL2VALCOL1KEYCOL
?11
?102
?1003
d1?4
e1?5
f1?6
?21
?202
?2003
d2?4
e2?5
f2?6
A question mark (?) in a value column indicates no value for the given KEYCOL.
• This query shows how the preceding query can include a GROUP BY clause:
SELECT KEYCOL, VALCOL1, VALCOL2, COUNT(*) FROM mytable
TRANSPOSE A, B, C AS VALCOL1
D, E, F AS VALCOL2
KEY BY KEYCOL
GROUP BY KEYCOL, VALCOL1, VALCOL2;
The result table of the TRANSPOSE query is:
(EXPR)VALCOL2VALCOL1KEYCOL
1?11
1?102
1?1003
1?21
1?202
1?2003
1d2?4
1e2?5
1f2?6
1d1?4
1e1?5
1f1?6
• This query shows how an item in the transpose item list can contain a list of expressions
and that the KEY BY clause is optional:
SELECT * FROM mytable
TRANSPOSE (1, A, 'abc'), (2, B, 'xyz')
AS (VALCOL1, VALCOL2, VALCOL3);
276 SQL Clauses