testing on pure SQLs revealed an error - fix it by using subquery