Transposing data in Hive
<p>I have a Hive table with data in the below format</p>

<pre><code>day       class  start_time  count  kpi1  kpi2  kpi3  kpi4  ...  kpi160
-----------------------------------------------------------------------
20161010  abc    00          12     1     0     null  0     ...
</code></pre>

<p>I want to write a hive query to fetch the data in the format below
using some calculations like <code>max</code>, <code>min</code> , and <code>avg</code>.</p>

<pre><code>day       class  start_time  count  kpi_name  kpi_max   kpi_min   kpi_avg
-----------------------------------------------------------------------
20161010  abc    00          12     kpi1      max(kpi1) min(kpi1) avg(kpi1)
20161010  abc    00          12     kpi2      max(kpi2) min(kpi2) avg(kpi2)
</code></pre>

<p>Please suggest a solution to fetch the data in this format.</p>

<p>Thanks.</p>