repair select query in customservices