pivot / unpivot sql issue
Dear all,
I got a issue about pivot/unpivot. I have a simple sql
I got a issue about pivot/unpivot. I have a simple sql
select
psc_stat.id,psc_stat.code, psc_stat.MCOUPON_USAGE,psc_stat.ECOUPON_USAGE, psc_stat.ETRANSACTION_usage , psc_stat.COLLECTION_RATE
from ETP.RPT_FOR_PSC_STAT psc_stat;
and the result is
ID CODE mcoupon_usage ecoupon_usage etransaction_usage collection_rate
1 HIT 0 20 79 99
2 MTL 0 16 81 97
3 CHT 0 32 66 98
5 DPW 0 15 85 100
6 ACT 0 11 89 100
BTW, I would like to transform the result set like the following
Code HIT MTL CHT DPW ACT
e-coupon 20 16 32 15 11
e-transaction 79 81 66 85 89
m-coupon 0 0 0 0 0
collection rate 98.60 97.40 98.30 100 100
I have studied pivot and unpivot sql but I still can't figure it out.
0