HOw to convert rows into columns dynamically in Teradata.

Database

HOw to convert rows into columns dynamically in Teradata.

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  elseend) as "UP"

from WORK_TBLS_LOADS.Ptable  group by product

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 no fixed states)