Using case statement in ROW_NUMBER() OVER ( ORDER BY ) causes severe performance issues
I have two queries the first one runs in 5 seconds, the second one takes a couple