• Im not sure why you went searching for other code when you had some that worked as you wanted.

    Unfortunately its very hard to help since you still have not given us any DDL.

    We cant see what you see.