Hi, We have requirement where we will get as below

The data will be like
Now I need to get in Header as 3300054 as it has status as 3 remaining records in Item like 3300059 and 3300085 with respective values as those have status 1.
If you observe here the key for the three records is Groupcode, like this we can have multiple values of Group code and multiple recORDS. how can we achieve this.
Target structure-
