Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pivot Table Help

Status
Not open for further replies.

smpena

Technical User
Apr 15, 2010
1
US
Hello,

How can I setup a pivot table using teradata to go from this:


STATUS REASON DATE
Active UNASSIGNED 4/15/2010
Active UNASSIGNED 4/14/2010
Active UNASSIGNED 4/14/2010
Sus UNASSIGNED 4/15/2010
Active UNASSIGNED 4/14/2010
Active UNASSIGNED 4/13/2010
Susp UNASSIGNED 4/15/2010
----------------------------------------------------------
TO THIS:
----------------------------------------------------------
STATUS REASON 4/13/2010 4/14/2010 4/15/2010
Active UNASSIGNED 1 3 1
Susp UNASSIGNED 2



Thank you,

Scott
 
Hi Scott. Does the code below work or did you want something more automated?

select
status
,reason
,sum(case when data = '2010-04-13'
then 1
else 0
end) as 20100413
,sum(case when data = '2010-04-14'
then 1
else 0
end) as 20100414
,sum(case when data = '2010-04-15'
then 1
else 0
end) as 20100415
from
table
group by
1,2
order by
1,2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top