COUNT DISTINCT and window functions