A little help for nested query

For such complex queries, have you considered simply using a raw SQL expression like this: