title: How to check Oracle column values are all the same for a specific ID?
body: <p>I am trying to figure out the best way to determine, for a specific ID within an Oracle 11g table that has 5 columns and say 100 rows against this ID, if all the column values are the same for these five columns.</p>
  
  <p>For example:</p>
  
  <p>Table Name: <strong>TABLE_DATA</strong></p>
  
  <p>Columns:</p>
  
  <pre><code>TD_ID   ID      COL1    COL2    COL3    COL4    COL5
  -----------------------------------------------------------------------
  1       1       1       0       3       2       0
  2       1       1       0       3       2       0
  3       1       1       0       3       2       0
  4       1       1       0       3       2       0
  5       1       1       0       3       2       0
  6       1       1       0       3       2       0
  </code></pre>
  
  <p>So based on the above example which is just showing 6 rows for now against the ID:1, I want to check that for all COL1, COL2, COL3, COL4 and COL5 values where ID = 1, tell me if all the values are the same from the very first row right down to the last – <strong>if so, then return ‘Y’ else return ‘N’</strong>.</p>
  
  <p>Given the above example, the result would be ‘Y’ but for instance, if TD_ID = 5 and COL3 = 4 then the result would be ‘N’, as all the column values are not the same, i.e.:</p>
  
  <pre><code>TD_ID   ID      COL1    COL2    COL3    COL4    COL5
  -----------------------------------------------------------------------
  1       1       1       0       3       2       0
  2       1       1       0       3       2       0
  3       1       1       0       3       2       0
  4       1       1       0       3       2       0
  5       1       1       0       4       2       0
  6       1       1       0       3       2       0
  </code></pre>
  
  <p>I’m just not sure what the fastest approach to determine this is, as the table I am looking at may have more than 2000 rows within the table for a specific ID.</p>