title: SQL query- ID not exist in another table or exist but with all records are in history?
body: <p>i have table T1</p>
  
  <pre><code>ID
  1
  2
  3
  </code></pre>
  
  <p>and table T2</p>
  
  <pre><code>ID    HISTORY
  1       1
  1       1
  2       1
  2       0 
  </code></pre>
  
  <p>I must select from T1 all records which does not exist in T2 or exists but all records are in history (history flag =1)</p>
  
  <p>So for this my result will be</p>
  
  <pre><code>1
  3
  </code></pre>
  
  <p>What is the correct SQL query for this?
  Thanks</p>