Redshift doesn\'t support DISTINCT aggregates in its window functions. AWS documentation for COUNT states this, and distinct isn\'t supported for any o
While Redshift doesn't support DISTINCT aggregates in its window functions, it does have a listaggdistinct function. So you can do this:
regexp_count(
listaggdistinct(customer_id, ',') over (partition by field2),
','
) + 1
Of course, if you have , naturally occurring in your customer_id strings, you'll have to find a safe delimiter.