If I'm understanding your question correctly, I think you'll need to join the table to itself multiple times. Something like this should work using a common table expression
to get the max
customer id per each column where the column isn't null
. Then it joins back to itself to get the value:
with cte as (
select email,
max(case when col1 is not null then customerid end) maxcustomerid1,
max(case when col2 is not null then customerid end) maxcustomerid2,
max(case when col3 is not null then customerid end) maxcustomerid3,
max(case when col4 is not null then customerid end) maxcustomerid4
from yourtable
group by email
)
select t.email,
t1.col1,
t2.col2,
t3.col3,
t4.col4
from cte t
left join yourtable t1 on t.email = t1.email and t.maxcustomerid1 = t1.customerid
left join yourtable t2 on t.email = t2.email and t.maxcustomerid2 = t2.customerid
left join yourtable t3 on t.email = t3.email and t.maxcustomerid3 = t3.customerid
left join yourtable t4 on t.email = t4.email and t.maxcustomerid4 = t4.customerid