title: How to compare two rows of a table
body: <p>I have a sample table with input as shown. In actual it has large amounts of data. The input and output as shown:</p>
  <pre><code>    I/P-                                                 O/P-
  
  |ID | Role | Status |                     |ID | Role | Status | Final |
  |:-:|:----:|:------:|                     |:-:|:----:|:------:|:-----:|
  | 1 | ABC  |  Pass  |                     | 1 | ABC  |  Pass  |   0   |
  | 2 | PQR  |  Pass  |                     | 2 | PQR  |  Pass  |   0   |
  | 1 | ABC  |  Fail  |                     | 1 | ABC  |  Fail  |   0   |
  | 3 | PQR  |  Fail  |                     | 3 | PQR  |  Fail  |   0   |               
  | 1 | XYZ  |  Fail  |                     | 1 | XYZ  |  Fail  |   1   |
  | 3 | PQR  |  Fail  |                     | 3 | PQR  |  Fail  |   1   |
  | 3 | XYZ  |  Pass  |                     | 3 | XYZ  |  Pass  |   0   | 
  | 4 | XYZ  |  Fail  |                     | 4 | XYZ  |  Fail  |   1   |
  </code></pre>
  <p>So for a 'ID' (ex. ID=1) if Role is same for two or more records (ex. Role = 'ABC') then will status field. If for any of the selected record 'Status' = 'Pass' then will create a new field named Final with value 0 for all records(if for any of the record Status = 'Pass')
  else will keep it 1(if there is no record with 'Status' = 'Pass'.</p>
  <p>I know this we can do with Case statement while comparing columns. But not sure how to do with rows. Can someone please help me.</p>
  <p>Thanks.</p>