title: SQL Server one column data as row and other one as column
body: <p>Data within the actual table represents the intersection between two categories (for e.g a and b are categories). Data I have has multiple categories. In output table I need to show the intersection between such categories.</p>
  
  <p>This is the actual table data. sample data</p>
  
  <pre><code>col1    Category    IntersectedCategory Count
  ----------------------------------------------
  1       a           g               12
  2       b           f               12
  3       a           a               260
  4       c           I               38
  5       d           h               39
  6       b           g               12
  7       b           h               27
  8       c           c               114
  9       a           h               60
  10      a           d               57
  11      e           e               137
  12      f           h               15
  13      g           I               12
  14      d           g               12
  15      e           f               34
  16      c           b               15
  17      h           h               190
  18      f           f               96
  19      c           d               14
  20      e           d               46
  21      g           f               12
  22      e           g               12
  23      c           f               12
  24      g           g               97
  25      d           I               72
  26      b           b               116
  27      c           h               32
  28      b           I               45
  29      e           h               15
  30      c           g               6
  31      a           b               16
  32      I           I               361
  33      I           f               55
  34      a           e               38
  35      e           I               68
  36      d           d               142
  37      g           h               6
  38      a           f               33
  39      e           b               21
  40      b           d               21
  41      a           c               29
  42      a           I               114
  43      I           h               81
  44      e           c               6
  45      d           f               29
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>list    a   b    
  ----------------
  a       20  5
  b       5   25
  </code></pre>