• I like your function, because you use a CTE.:-D

    I've been learning how and when to use CTE's and this is just another item that has helped me to better understand them.

    This funciton has been done before, but I haven't seen it using a CTE.

    Thanks!