title: How to optimise SQL Query
body: <p>This query takes 3 seconds to execute, but if you remove the "convert" clause, it is instantly done, and vice versa. Can someone help ?</p>
  
  <pre><code>SELECT DISTINCT 
     N.ID, Groups.IP_Access
  FROM         
     Name AS N 
  INNER JOIN
     Activity AS A ON N.ID = A.ID 
  INNER JOIN
     Groups ON N.ID = Groups.ID
  WHERE     
     ((A.ACTIVITY_TYPE = 'LICENCE') AND 
      (A.PRODUCT_CODE = 'IP') AND 
      (A.THRU_DATE IS NULL) AND 
      (A.SOURCE_CODE = 'ICAS') AND 
      (N.MEMBER_TYPE IN ('MM', 'PM','ST', 'SC', 'SE', 'CA', 'CM', 'AC', 'IN', 'BC', 'NM', 'IS', 'RN', 'WEB','PS', 'PP', 'NP')) AND 
      (N.STATUS IN ('A', 'P')) AND 
      (N.ID &lt;&gt; 1) OR 
      CONVERT(bit, ISNULL(Groups.IP_access, 0)) = 1)  
  </code></pre>