I have a very large table and I need to pivot it. Something similar to this: (How to transpose/pivot data in hive?) I need to go from here
| ID | Code | cat | count |
| 1 | A | p | e |
| 2 | B | q | f |
| 3 | B | p | f |
| 3 | B | q | h |
| 3 | B | r | j |
| 3 | C | t | k |
to here:
| ID | Code | p | q | r | t |
| 1 | A | e | | | |
| 2 | B | | f | | |
| 3 | B | f | h | j | |
| 3 | C | | | | k |
But, the categories I have are several around (2000) and I don't want to write a separate select for each category. How could I do this?