title: Count number of matching data in columns on the basis of primary key in two tables
body: <p>I have two tables with identical structure and somewhat identical data. As an example, let's consider the following tables.</p>
  
  <p>Table Pri</p>
  
  <pre><code>id | name   | dept | rollno
  1  | Mark   | A    | 4
  2  | Michael| B    | 5
  3  | Norman | C    | 6
  4  | Paul   | D    | 7
  5  | Robert | E    | 8
  </code></pre>
  
  <p>Table Sec</p>
  
  <pre><code>id | name   | dept | rollno
  1  | Mark   | A    | 4
  2  | Michael| B    | 5
  3  | Norman | G    | 7
  4  | Paul   | D    | 8
  5  | Bradley| F    | 9
  </code></pre>
  
  <p>Now, on equating the 'id' between the two tables, I'd like to get a count of various column matches (name/dept/rollno), i.e., rows with 0 column matches, rows with 1 column match, rows with 2 column matches, and identical records (rows with all the matches).</p>
  
  <p>For example, the result for the given data can be displayed as</p>
  
  <pre><code>column_matches| count
  0             | 1
  1             | 1
  2             | 1
  3             | 2
  </code></pre>
  
  <p>I'm on Oracle10g. Any ideas as to how to go about this would be very helpful.</p>