Anyone know how I can group by, but keep a distinct column? I messed around with UNPIVOT but couldnt find a good explanation to help me write my code. Anyone have a solution?
I have data that looks like this:
acct contact email phone
1 44 abc NULL
1 33 NULL 123
2 2 xxx NULL
2 22 NULL 456
I use
select acct,max(email) as email, max(phone) as phone from my_table
group by acct
to wind up with this:
acct email phone
1 abc 123
2 xxx 456
but my end goal is to group by and create a separate contact column for phone and email like this:
acct contact_email email phone contact_phone
1 44 abc 123 33
2 2 xxx 456 22