• Silly little thing, but we use a case sensitive collation.

    Change "cte" in the actual select near the bottom to be "CTE"