trying to solve the issue with the sub-query