fixed sql query to match field names