title: Set column value if certain record exists in same table
body: <p>How could I create a view for a table with subset of the table's records, all of the table's columns, plus additional "flag" column whose value is set to 'X' if the table contains certain type of record? For example, consider the following relations table <code>Relations</code>, where values for types stand for <code>H'-human, 'D'-dog</code>:</p>
  
  <pre><code> id | type | relation | related
  --------------------------------
   H1 |  H   | knows    | D2 
   H1 |  H   | owns     | D2 
   H2 |  H   | knows    | D1 
   H2 |  H   | owns     | D1
   H3 |  H   | knows    | D1
   H3 |  H   | knows    | D2
   H3 |  H   | treats   | D1
   H3 |  H   | treats   | D2
   D1 |  D   | bites    | H3
   D2 |  D   | bites    | H3
  </code></pre>
  
  <p>There may not be any particular order of records in this table.</p>
  
  <p>I seek to create a view <code>Humans</code> which will contain all human-to-dog <code>knows</code> relations from <code>Relations</code> and  all of the <code>Relations</code>'s columns and additional column <code>isOwner</code> storing <code>'X'</code> if a human in a given relation owns someone:</p>
  
  <pre><code> id | type | relation | related | isOwner
  ------------------------------------------
   H1 |  H   | knows    |    D2   |    X
   H2 |  H   | knows    |    D1   |    X
   H3 |  H   | knows    |    D1   |    
  </code></pre>
  
  <p>but struggling quite a bit with this. Do you know of a way to do it, preferably in one <code>CREATE VIEW</code> call, or any way really?</p>