title: Convert NOT IN to NOT EXISTS SQL firebird
body: <p>I want to convert this not in query to not exists.</p>
  
  <pre><code>SELECT * FROM MYCARD T1
  WHERE T1.IDMONEY = 5 AND T1.IDCARD = 80
  AND EXISTS (
      SELECT IDCARD, YEAR, MONEY 
      FROM MYCARD T2
      WHERE T2.IDCARD = T1.IDCARD 
      AND T2.YEAR = T1.YEAR
      AND T2.MONEY = T1.MONEY
      GROUP BY T2.IDCARD, T2.YEAR, T2.MONEY 
      HAVING COUNT(T2.IDCARD) &gt; 1
  )
  AND T1.ID not in (   -- THIS NOT IN TO NOT EXISTS
      select min(ID)
      from MYCARD
      WHERE IDMONEY = 5
      AND IDCARD = 80
      group by IDCARD, YEAR
  )
  </code></pre>
  
  <p>I want to get values that have ID different that min(ID). This not in works good but I need more optimized query. I tried to use something like this but It seems to be correct but It's not optimized:</p>
  
  <pre><code>AND EXISTS (
      select min(ID)
      from MYCARD
      WHERE IDMONEY = 5
      AND IDCARD = 80
      group by IDCARD, YEAR
      HAVING T1.ID = MIN(ID)
  )
  </code></pre>