HI All,
I too have same query(Need to Convert rows to cols anyone help me how to resolve it.
Input:
Product State population
HSI MP 12
FIN AP 34
FDV UP 23
HSI MP 45
FIN AP 60
FDV UP 50
sel product,
sum( case when state='AP' then population else 0 end) as "AP",
sum( case when state='MP' then population else 0 end) as "MP",
sum( case when state='UP' then population else 0 end) as "UP"
from WORK_TBLS_LOADS.Ptable group by product;
output:
product AP MP UP
FDV 0 0 73
FIN 94 0 0
HSI 0 57 0
Question: I need this query in dynamic way (There is fixed states). Please provide ur input.
↧