Ich versuche, den folgenden Code von SQL Server Teradata mit UNPIVOT Logik zu konvertieren:Konvertieren von SQL Server UNPIVOT zu TERADATA
insert into
IPData
select
1,
ProductCode || '|' ||
LocationCode || '|' ||
TimeCode || '|' ||
MeasureCode || '|' ||
cast(MeasureVal as varchar(12))
from
(
select
p.SubsectionCode ProductCode,
td_ss.LocationCode,
td_ss.TimeCode,
sum(
case
when td_ss.Life = 'C'
and td_ss.Seasonality = 'AW' then td_ss.DepotStockRetail
else 0
end) StkDep_AW_Act,
sum(
case
when td_ss.Life = 'C'
and td_ss.Seasonality = 'C' then td_ss.DepotStockRetail
else 0
end) StkDep_Cnt_Act,
sum(
case
when td_ss.Life = 'C'
and td_ss.Seasonality = 'SS' then td_ss.DepotStockRetail
else 0
end) StkDep_SS_Act,
sum(
case td_ss.Life
when 'T' then td_ss.DepotStockRetail
else 0
end) StkDep_Trm_Act,
sum(td_ss.DepotStockRetail) StkDep_Tot_Act
from
Stock td_ss
inner join
Product p
on td_ss.Kimball = p.CurrentKimball
and td_ss.SectArea = p.SectArea
and td_ss.SeasonID = p.SeasonID
group by
p.SubsectionCode,
td_ss.LocationCode,
td_ss.TimeCode)x
UNPIVOT
(MeasureVal for MeasureCode in
(StkDep_AW_Act, StkDep_Cnt_Act, StkDep_SS_Act, StkDep_Trm_Act, StkDep_Tot_Act)) as unpvt
where
MeasureVal <> 0;
ich mit dem Teil UNPIVOT
bin zu kämpfen. Ab sofort habe ich keine Daten in irgendeiner der Tabellen, so dass jede Hilfe in Bezug auf UNPIVOT
sehr geschätzt wird.
Es wäre einfacher, zu verstehen, wenn Sie Beispieldaten zur Verfügung gestellt und die gewünschten Ergebnisse. –