I suggest trying harder to solve this problems before consulting the answers.
My solutions may not follow best practices for such query language, hence take it as it is.
If you encounter errors or want to apply best practices just open the issue.
Hope this could help you:relaxed:.