HP Neoview SQL Reference Manual page 274

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

The result table of the TRANSPOSE query is:
A
1
1
1
2
2
2
This query shows that the items in the transpose item list can be any valid scalar expressions:
SELECT KEYCOL, VALCOL, A, B, C FROM mytable
TRANSPOSE A + B, C + 3, 6 AS VALCOL
KEY BY KEYCOL;
The result table of the TRANSPOSE query is:
KEYCOL
1
2
3
1
2
3
This query shows how the TRANSPOSE clause can be used with a GROUP BY clause. This
query is typical of queries used to obtain cross-table information, where A, B, and C are the
independent variables, and D is the dependent variable.
SELECT KEYCOL, VALCOL, D, COUNT(*) FROM mytable
TRANSPOSE A, B, C AS VALCOL
KEY BY KEYCOL
GROUP BY KEYCOL, VALCOL, D;
The result table of the TRANSPOSE query is:
KEYCOL
1
2
3
1
2
3
This query shows how to use COUNT applied to VALCOL. The result table of the
TRANSPOSE query shows the number of distinct values in VALCOL.
SELECT COUNT(DISTINCT VALCOL) FROM mytable
TRANSPOSE A, B, C AS VALCOL
KEY BY KEYCOL
GROUP BY KEYCOL;
274
SQL Clauses
B
C
10
100
10
100
10
100
20
200
20
200
20
200
VALCOL
11
103
6
22
203
6
VALCOL
1
10
100
2
20
200
D
E
d1
e1
d1
e1
d1
e1
d2
e2
d2
e2
d2
e2
A
B
1
10
1
10
1
10
2
20
2
20
2
20
D
d1
d1
d1
d2
d2
d2
F
KEYCOL
f1
1
f1
2
f1
3
f2
1
f2
2
f2
3
C
100
100
100
200
200
200
COUNT(*)
1
1
1
1
1
1
VALCOL
1
10
100
2
20
200

Advertisement

Table of Contents
loading

Table of Contents