Hi,
This is a rather complex request so I figured it's better to put it in a screenshot with steps attached. Any help is much appreciated!
If you provide some DDL and sample data, we could provide a solution for you