bug 1008: Fixed typo  in sql-query