Hi...can you please post some table/data scripts as per post below.
Also your expected results based on the sample data you provide.
Thanks
Helps us help you
https://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day