Glad we could help 😀
But you did the most important part by providing ready to use sample data, by showing what you've tried so far and clearly explain what your expected output need to look like.
Posts like that are the ones I enjoy working on since it not only shows that you put some effort into your question. It also implies that you'll use the answer to learn from it and not only to copy and paste and move on.