fix sql query/filter