|
|
Archives of the TeradataForum
Message Posted: Tue, 28 Jul 2009 @ 19:50:17 GMT
Subj: | | Re: Transpose or Pivot data |
|
From: | | Billingslea, Drew |
Fred,
Try summing you case statements and group by location and unit id
i.e.
Select t.location, t.unit_ID,
sum(Case When t.fault=3 Then t.FltCnt Else 0 End) as Fault3,
sum(Case When t.fault=35 Then t.FltCnt Else 0 End) as Fault35,
sum(Case When t.fault=155 Then t.FltCnt Else 0 End) as Fault155,
sum(Case When t.fault=156 Then t.FltCnt Else 0 End) as Fault156,
From (
Select location, unit_ID, fault, Count(fault) as FltCnt
From database
Where location = 4443
And unit_ID = 3124
And fault=3 OR fault=35 OR fault=155 or fault=156 Group by
location, unit_ID, fault) t
Group by t.location, t.unit_ID
Hth,
drew
| |