Analytics
Enthusiast

## Transpose Columns to Rows

Dear Who Know How,

Currently I have 2 statistic tables:

Table1: Contain of Average value for VAR1 to VAR5
*************************************************************
AVG(VAR1) || AVG(VAR2) || AVG(VAR3) || AVG(VAR4) || AVG(VAR5)
1.43 || 1.73 || 2.03 || 2.33 || 2.63
*************************************************************

Table2: Contain of Minimum value for VAR1 to VAR5
*************************************************************
Min(VAR1) || Min(VAR2) || Min(VAR3) || Min(VAR4) || Min(VAR5)
1.25 || 1.31 || 1.37 || 1.43 || 1.49
*************************************************************

I need to combine Table1 and Table2, and transpose the columns into rows as Table3 like below:

Table3: Final Result
************************
Variables || AVG || Min
VAR1 || 1.43 || 1.25
VAR2 || 1.73 || 1.31
VAR3 || 2.03 || 1.37
VAR4 || 2.33 || 1.43
VAR5 || 2.63 || 1.49
************************

Any one can help?

3 REPLIES
Enthusiast

## Re: Transpose Columns to Rows

Couldn't test, ... but may be something like this ...

SEL 'VAR1' VARIABLES, A.AVAR1 "AVG", M.MVAR1 "MIN" FROM AVGTBL A, MINTBL M
UNION ALL
SEL 'VAR2', A.AVAR2, M.MVAR2 FROM AVGTBL A, MINTBL M
UNION ALL
..... ( repeat for other variables )

SEL 'VAR5', A.AVAR5, M.MVAR5 FROM AVGTBL A, MINTBL M
Enthusiast

## Re: Transpose Columns to Rows

Alternatively you could use the Teradata Datawarehouse Miner, which can generate transposing code for you.
Enthusiast

Dear joedsilva,