Archives of the TeradataForum
Message Posted: Fri, 26 Mar 2004 @ 17:24:21 GMT
Subj: | | Re: Crosstab SQL |
|
From: | | Burton, Bruce |
like this?
sel product_code,
sum(case when bill_month between '2003-11-01' and '2003-11-30' then bill_amt
else 0 end) as nov_bill_amt,
sum(case when bill_month between '2003-12-01' and '2003-12-31' then bill_amt
else 0 end) as dec_bill_amt
group by product_code
raw data
product_code bill_month bill_amt
prod1 2003-12-15 $5
prod1 2003-11-15 $5
prod2 2003-12-15 $10
prod2 2003-11-15 $10
"pivot" data
product_code nov_bill_amt dec_bill_amt
prod1 5 5
prod2 10 10
|