0

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?

David דודו Markovitz
  • 42,900
  • 6
  • 64
  • 88
Shehzaad
  • 25
  • 6

0 Answers0