bugfix sql statement