write a query whose column names are based on another table in sql or hive hql
<p>I have following table A</p>

<pre><code>user_id time   category
Josh    1234   "game"
Tom     5566   "music"
Mary    7788   "reader"
Leon    6666   "game"
Leon    1111   "weather"
...
</code></pre>

<p>I want to generate a new table B which is based on table A, after I get all the category values.</p>

<p>something like this</p>

<pre><code>user_id game music reader weather  ...
josh    1234 0     0       0       ...
tom     0    5566  0       0       ...
Mary    0    0     7788    0       ...
Leon   6666  0     0       1111    ...
</code></pre>

<p>The new table's column names are from table A.</p>

<p>How can I do that in sql or hive hql (something like <code>select * from ...</code> whose output is the new table B.) ?</p>

<p>Thank you.</p>