Atlassian have not added subQuery support to the Jira query language (JQL) but you can do it via saved filters. When you save a filter you will notice it has a filterid in the url and you give it a name. You can’t reference the filterid in JQL without plugins but out of the box JQL allows you to reference the filter by name.
Say you want to find all the bugs closed by your team in the last 4 months.
Filter “Team Y bugs closed in last 4 months”:
project = XXX AND component = "Team Y" AND resolutiondate >= startOfMonth(-4M) AND issuetype in (bug) AND status = closed AND resolution = fixed
The you want to find all the bugs raised by your team which were closed by other teams.
Filter “Bugs raised by Team Y and fixed by other teams”:
project = XXX AND reporter in (Team member Y1, Team member Y2, Team member Y3) AND resolutiondate >= startOfMonth(-4M) AND issuetype in (bug) AND status = closed AND resolution = fixed and filter != "Team Y bugs closed in last 4 months"
If you are sharing the second filter you will want to ensure sharing permissions are also extended for the first filter.