bug 1008: fixed sql-statement