|
|
Archives of the TeradataForum
Message Posted: Tue, 28 Jul 2009 @ 19:49:34 GMT
Subj: | | Re: Transpose or Pivot data |
|
From: | | Poston, Donna |
Hi Fred, you can use case statements to denormalize the data.
Select location
,unit_id
,sum (case when fault = 3 then 1 else 0 end) (title 'fault 3')
,sum (case when fault = 35 then 1 else 0 end) (title 'fault 35')
,sum (case case when fault = 155 then 1 else 0 end) (title 'fault 155')
,sum (case when fault = 156 then 1 else 0 end) (title 'fault 156')
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
Order by location, unit_ID
| |