You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND liListenNr=1 GROUP BY liListenNr' at line 3 >>>SELECT liListenNr ,SUM(liPreis*liMenge) AS TotalBetrag,SUM(liMenge) AS TotalStueck, COUNT(*) AS TotalZeilen FROM listenitems WHERE liOwnerId='' AND liUserId= AND liListenNr=1 GROUP BY liListenNr