title: Nested parentheses in WHERE clause
body: <p>I've been reworking the parentheses on this query for a bit to no avail.  Can someone point me to the particular spot that is likely causing the error?  Here's the error message:</p>
  
  <p><a href="https://i.stack.imgur.com/3nSMX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3nSMX.png" alt="enter image description here"></a></p>
  
  <p>Here's the query:</p>
  
  <pre><code>SELECT 
  tExceptionsAll1.ID, 
  tExceptionsAll1.CardholderName, 
  PCARDS_ILL_DBO_CARD.PERSON_ID, 
  tExceptionsAll1.CardType, 
  tExceptionsAll1.Duration, 
  tExceptionsAll1.ExceptionType, 
  tExceptionsAll1.STL AS [Exp STL], 
  tExceptionsAll1.CL AS [Exp CL], 
  PCARDS_ILL_DBO_CARD.TRANS_LIMIT_AMT AS [Card STL], 
  PCARDS_ILL_DBO_CARD.MONTH_LIMIT_AMT AS [Card CL], 
  tExceptionsAll1.TerminationDate, 
  tExceptionsAll1.DCMNames, 
  tExceptionsAll1.ReminderDate
  FROM PCARDS_ILL_DBO_CARD 
  INNER JOIN tExceptionsAll1 ON (PCARDS_ILL_DBO_CARD.CARD_ID = CLNG(tExceptionsAll1.CardID)) 
        AND (CLNG(PCARDS_ILL_DBO_CARD.PERSON_ID) = tExceptionsAll1.CardholderUIN)
  WHERE (
    ((tExceptionsAll1.STL)&gt;0) 
    And ((tExceptionsAll1.CL)&gt;0) 
    And ((PCARDS_ILL_DBO_CARD.TRANS_LIMIT_AMT)&lt;&gt;tExceptionsAll1.STL) 
    And ((PCARDS_ILL_DBO_CARD.MONTH_LIMIT_AMT)&lt;&gt;tExceptionsAll1.CL) 
    And ((tExceptionsAll1.TerminationDate) Is Null)
  ) 
  OR (
    ((tExceptionsAll1.TempSTL)&gt;0) 
    And ((tExceptionsAll1.TempCL)&gt;0) 
    And ((PCARDS_ILL_DBO_CARD.TRANS_LIMIT_AMT)&lt;&gt;tExceptionsAll1.TempSTL) 
    And ((PCARDS_ILL_DBO_CARD.MONTH_LIMIT_AMT)&lt;&gt;tExceptionsAll1.TempCL) 
    And ((tExceptionsAll1.TerminationDate) Is Null) 
    And ((tExceptionsAll1.ReminderDate) &lt; getdate())
  );
  </code></pre>