title: Get the difference between two SELECT statements
body: <p>I am trying to get the difference between 2 <code>select</code> statements.</p>
  
  <p>Here is the first <code>select</code>:</p>
  
  <p><strong>SELECT 1</strong></p>
  
  <pre><code>SELECT *
  FROM h_log_material
  LEFT JOIN h_log_stkpnl
  ON  h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID 
  where 
  h_log_material.WO_ID='E11TMB7M05'
  and h_log_material.mtrl_type='BL'
  </code></pre>
  
  <p><strong>Output is 4917</strong></p>
  
  <p><strong>SELECT 2</strong></p>
  
  <p>Here is second <code>select</code>: </p>
  
  <pre><code>SELECT *
  FROM h_log_material
  LEFT JOIN h_log_stkpnl
  ON  h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID 
  where 
  h_log_material.WO_ID='E11TMB7M05'
  and h_log_material.mtrl_type='BL'
  and h_log_stkpnl.op_id like '%STOCK-IN%'
  </code></pre>
  
  <p><strong>Output is 4870</strong></p>
  
  <p>I would like to get the difference  <strong>SELECT 1 - SELECT 2</strong></p>
  
  <p>As output I need rows which are not in select 2.</p>
  
  <p>I tried this but it returns 0.</p>
  
  <pre><code>SELECT *
  FROM h_log_material
  LEFT JOIN h_log_stkpnl
  ON  h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID 
  where 
  h_log_material.WO_ID='E11TMB7M05'
  and h_log_material.mtrl_type='BL'
  and not exists
  (SELECT *
  FROM h_log_material
  LEFT JOIN h_log_stkpnl
  ON  h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID 
  where 
  h_log_material.WO_ID='E11TMB7M05'
  and h_log_material.mtrl_type='BL'
  and h_log_stkpnl.op_id like '%STOCK-IN%')
  </code></pre>