title: COUNT field incorrect or syntax error
body: <p>What would be the error when I get following error message</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[07002]: [Microsoft][ODBC Driver 11 for SQL Server]COUNT field incorrect or syntax error'...</p>
  </blockquote>
  
  <p>This is the query I'm using</p>
  
  <pre><code>$sql = $pdo-&gt;prepare("SELECT stockamount, stockname, stockbalance.stockid, SUM(ABS(reservationtransaction.stockquantity)) AS reservedamount FROM stockbalance
      JOIN stock ON stockbalance.stockid = stock.stockid
      LEFT JOIN reservationtransaction ON reservationtransaction.articleid = :artid
      WHERE stockbalance.articleid = :artid AND ((changeddate &gt; DATEADD(yy,-1,GETDATE()) AND inventorydate &gt; DATEADD(yy,-1,GETDATE())) OR stockbalance.stockamount &lt;&gt; 0)
      GROUP BY stockbalance.stockid");
  $sql-&gt;bindValue(':artid', $productId);
  $sql-&gt;execute();
  </code></pre>
  
  <p>I have searched questions in SO, but no one was similar or helpful.<br>
  Thanks in advance.</p>
  
  <p><strong>Edit:</strong> This query is working fine when executing it with Microsoft SQL Server Management Studio, but when using PDO, I'm getting the error.</p>