Nested query: using within outer query results of inner query

I am trying to filter results of outer query based on the results of inner query.
Document structure looks like this:

{  
   "set":1,
   "game":2,
   "point":1,
   "serve":2,
   "pointData":{  
      "match":{  
         "matchId":"MS005"
      },
      "scorer":{  
         "playerId":"222"
      },
      "server":{  
         "playerId":"111"
      },
      "shot":[  
         {  
            "playerId":"111"
         },
         {  
            "playerId":"222"
         },
      ]
   }
}

My goal is (1) to find set and game numbers that scorer and server belongs to player, and then (2) get all shots for that player with set and game numbers from (1)to count how many player shots are per set and game from (1), (3) average results from (2) to get average number of player shots to get the average number of shots in the set and game that player won.

My query for (1):

    SELECT  p.`set` as set_num, p.game as game_num
   FROM CourtTracking p
   WHERE p.pointData.tournament.year = 2019 
	AND p.pointData.match.matchId = 'MS005'
	AND p.`set` != 0
	AND p.isValid = true
	AND p.type = 'atp_point'
	AND p.pointData.server.playerId = '111'
	AND p.pointData.scorer.playerId = '111'
	AND p.pointData.shot IS NOT MISSING
	Group by  p.`set`,  p.game

It gets results like:

[
  {
    "game": 9,
    "set": 1
  },
  {
    "game": 6,
    "set": 2
  },
  {
    "game": 7,
    "set": 1
  }
]

I am stuck on how to nest the query to get all player shots from playerData.shot array from documents that satisfy set and game from the results of query above, so that those shots are grouped by set and game in order to calculate the total number of shots per those set-game combination.

Thank you