INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Teradata Equivalent to ORACLE UNPIVOT Command

Teradata Equivalent to ORACLE UNPIVOT Command

(OP)
Hello Teradata Experts,

The following query was posted in the Teradata Forum back in 2010, but it didn't receive any replies. I am attempting to do exactly the same thing as part of a large Data Conversion Exercise (25 Tables, 40 Columns per Table). If it could also be done using a Stored Procedure - that would be ideal. Let's assume that I only know the name of the KEY Column - but not any of the others. Note that I do not want to use UNION ALL.
_________________________________________________________________________________________________________________________

To convert the columns to rows , I was trying UNPIVOT in Oracle 11g like given below

KEY C1 C2 C3
--- ----- ----- -----
r1 v1 v2 v3
r2 v1 v2
r3 v1 v3
r4 v1
r5 v2 v3
r6 v2
r7 v3
r8


select key, source, val
from
t UNPIVOT INCLUDE NULLS
( VAL FOR( SOURCE ) IN
( C1 AS 'C1',
C2 AS 'C2',
C3 AS 'C3'
)
)
order by key, source ;


Do we have any function in Teradata like UNPIVOT to achieve the same results ( without using union all) ?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close