Reporting Data
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Reporting Data Expand / Collapse
Author
Message
Posted 2/12/2009 8:49:33 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/12/2009 10:43:58 AM
Posts: 1, Visits: 3
I have a table like this.



Emp| Loc| Work_OT| Rate_OT| Amt_OT| Work_NT| Rate_NT| Amt_NT| Work_NO| Rate_NO| Amt_NO

1 10 10 8 80 10 10 100 10 12 120



I want the result like this.



Emp Loc Work Rate Amount Type

1 10 8 10 80 OT

1 10 10 10 100 NT

1 10 10 12 120 NO



Kindly suggest an SQL. I tried using Union and CASE, But dint work..



Thanks and Regards,


NKrish
Post #14455
Posted 2/20/2009 1:54:53 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 10/19/2009 6:44:26 PM
Posts: 38, Visits: 409
Hi,
I tried the below query and it worked

create volatile table abc1(
emp integer,
loc integer,
work_ot integer,
rate_ot integer,
amt_ot integer,
work_nt integer,
rate_nt integer,
amt_nt integer,
work_no integer,
rate_no integer,
amt_no integer
) primary index ( emp,loc) on commit preserve rows;

insert into abc1(1,10,10,8,80,10,10,100,10,12,120);

sel
emp,
loc,
work_ot as col1,
rate_ot as col2 ,
amt_ot as col3 ,
'OT' as amnt_type
from abc1
union all

sel
emp,
loc,
work_nt as col1 ,
rate_nt as col2,
amt_nt as col3,
'NT' as amnt_type
from abc1
union all

sel
emp,
loc,
work_no as col1,
rate_no as col2,
amt_no as col3,
'NO' as amnt_type
from abc1

I hope you don't have many columns and just 3 sets of work/rate/amt...
Post #14523
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 2:32am

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.094. 7 queries. Compression Disabled.