โ03-30-2022 11:16 AM
Hello. I am trying to using the Pivot function for email addresses. This is what I have so far:
Select fname, lname, awUniqueID, Email1, Email2
From xxxxxxxx
Pivot (
count(Email) as Test
For Email
In (1 as Email1, 2 as Email2)
)
I get everything I need except Email1 and Email2 have null values instead of actual email addresses. I just need a little push to get me over the edge. Thanks.
โ03-30-2022 11:38 AM
Please add example source data and desired output.
โ03-30-2022 11:38 AM
Please add example source data and desired output.
โ03-30-2022 11:46 AM
source data:
fname lname awUniqueID Email
John Smith 22 jsmith@gmail.com
JODI JONES 22 jsmith@live.com
Desired output:
fname lname awUniqueID Email1 Email2
John Smith 22 jsmith@gmail.com jsmith@live.com
โ03-30-2022 11:47 AM
Oops. The second name in the source data should be John Smith as well.
โ03-30-2022 12:18 PM
Just create a copy of dataframe (or temporary view) rename the Email column to Email2 and than join on with source awUniqueID.
โ03-31-2022 05:50 AM
Thanks Hubert. I did that and it worked. I still want to get 'Pivot' to work as well.
โ04-26-2022 09:48 AM
Hi Kaniz,
Thanks for your message. I was able to make it work with the workaround that Hubert provided. I would eventually like to make it work with the 'Pivot' command. I have not revisited it and tested the 'Pivot' command as I was on vacation for a couple of weeks.
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโt want to miss the chance to attend and share knowledge.
If there isnโt a group near you, start one and help create a community that brings people together.
Request a New Group