• Can you give the table DDL if possible, some sample input and the desired output?

    In the first link of my signature you find an article that helps you with those things.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP