title: Getting difference of two counts in SQL
body: <p>I'm doing some QA in Netezza and I need to compare the counts from two separate SQL statements. This is the SQL that I am currently using</p>
  
  <pre><code>SELECT COUNT(*) AS RECORD_COUNT  
  FROM db..EXT_ACXIOM_WUL_FILE  A
  LEFT JOIN (select distinct CURRENTLY_OPTED_IN_FL,mid_key from db..F_EMAIL) B
  ON A.MID_KEY=B.MID_KEY
  MINUS
  SELECT COUNT(*)
  FROM db..EXT_ACXIOM_WUL_FILE  A
  </code></pre>
  
  <p>However, it seems like MINUS doesn't work like that. When the counts match, instead of returning 0, this will return null for Record_count.  I basically the record count to be computed as:</p>
  
  <pre><code>record_count=count1-count2
  </code></pre>
  
  <p>So it is 0 if the counts are equal or the difference otherwise. What is the correct SQL for this?</p>