So, I've been dealing with huge dataset and I need to find only the users who are present at the final level of each story for each country. Eg. There are 15 levels in story A in brazil so i need the users only present at level 15 for that story. In story E there are 28 levels so i need only the users present at 28th level in that story for each country.

I'm currently using this query but this fetches users for all the levels.

```
SELECT
  event,
  story,
  country,
  level,
  COUNT(DISTINCT id) uniques
FROM
  `xyz`
WHERE
  (date between "2020-08-01" and "2020-08-07") 
  AND event in ("start")    

GROUP BY
  event,
  story,
  country,
  level
ORDER BY
  country,
  story,
  level

```

I've attached an image with dummy data, highlighting(yellow) the datapoints that needs to be fetched.

With ref to the image: In story A, at Level 15(max) in Brazil 1970 users and in UK 81 users and in US 301 users should be the only output.

[![enter image description here](https://i.stack.imgur.com/5XEwo.png)

[![enter image description here](https://i.stack.imgur.com/fbhFd.png)](https://i.stack.imgur.com/fbhFd.png)