Monday, April 28, 2008

Case Statement for Pivots

Case statements I created to show some Row information in Columns.


CASE cpl.ProductLineCode WHEN 'LP' THEN cpl.Multiplier ELSE 0 END as LPMultiplier,
CASE cpl.ProductLineCode WHEN 'DP' THEN cpl.Multiplier ELSE 0 END as DPMultiplier,
CASE cpl.ProductLineCode WHEN 'CQ' THEN cpl.Multiplier ELSE 0 END as CQMultiplier,
Totaling amounts

SUM (CASE cpl.ProductLineCode WHEN 'LP' then uf.Amount ELSE 0 END) as LPUplift,
SUM (CASE cpl.ProductLineCode WHEN 'DP' then uf.Amount ELSE 0 END) as DPUplift,
SUM (CASE cpl.ProductLineCode WHEN 'CQ' then uf.Amount ELSE 0 END) as CQUplift

No comments: