title: SQL for each row corresponsing to every other row
body: <p>I have a table which is like this:</p>
  
  <pre><code>Name    day1 day2 day3 day4 day5
  charles    1    0    0    1    1
  bob        1    1    1    0    0
  tom        0    0    0    1    1
  </code></pre>
  
  <p>Constraints : columns are about 1000
  I want an output like :</p>
  
  <pre><code>        charles bob tom 
  charles  3     1    2
  bob      1     3    0
  tom      2     0    2
  </code></pre>
  
  <p>i.e. the number of 1's that are common between each of them. What will the sql be corresponding to this ?</p>