LeighWardle
asked on
Special SQL to export customer data to MailChimp
Hi Experts,
I am attempting to export customer data from MS Access to MailChimp.
My MailChimp List uses a Group called "Interests".
So a customer can nominate 0-4 interests: Interest1, Interest2, Interest3, Interest4.
I have a Crosstab query that outputs the customer interests in this form:
The complication is that MailChimp rolls Interests in to a single field, for example:
"Interest1, Interest2, Interest3, Interest4" - if customer is interested in all 4 topics
"Interest1, Interest4" - if customer is interested in these 2 topics
"" - if customer has not specified any interests
Is it possible to generate this type of output using SQL?
Here is a sample MS Access database for testing.
Regards,
Leigh
I am attempting to export customer data from MS Access to MailChimp.
My MailChimp List uses a Group called "Interests".
So a customer can nominate 0-4 interests: Interest1, Interest2, Interest3, Interest4.
I have a Crosstab query that outputs the customer interests in this form:
The complication is that MailChimp rolls Interests in to a single field, for example:
"Interest1, Interest2, Interest3, Interest4" - if customer is interested in all 4 topics
"Interest1, Interest4" - if customer is interested in these 2 topics
"" - if customer has not specified any interests
Is it possible to generate this type of output using SQL?
Here is a sample MS Access database for testing.
Regards,
Leigh
ASKER
Yes, I want to generate a csv file. something like this:
"Email Address","First Name","Last Name","Interests"
x.y@domain.com,John,Doe,"Interest1, Interest4"
.........
Can you show corect csv data from your sample?
ClientID,Interest1,Interst 2,Interest 3,Interest 4
1,,,,
10110103,,2,,
10110104,,2,1,
10110105,,2,,
...
10110109,1,2,,
10110110,,3,1,1
or
1
10110103,2
10110104,2,1
10110105,2
...
10110109,1,2
10110110,3,1,1
ClientID,Interest1,Interst
1,,,,
10110103,,2,,
10110104,,2,1,
10110105,,2,,
...
10110109,1,2,,
10110110,,3,1,1
or
1
10110103,2
10110104,2,1
10110105,2
...
10110109,1,2
10110110,3,1,1
ASKER
Here is the correct csv data from my sample:
"ClientID","<>","Interest1","Interest2","Interest3","Interest4"
"1",1,,,,
"10110103",,,2,,
"10110104",,,2,1,
"10110105",,,2,,
"10110106",,,2,1,
"10110108",,,2,1,
"10110109",,1,2,,
"10110110",,,3,1,1
Change your query to:
Result is included
aaa-MailChimp-Export---Crosstab.txt
TRANSFORM Count(CLIENTS3.ClientID) AS CountOfClientID
SELECT CLIENTS3.ClientID
FROM CLIENTS3 LEFT JOIN ([Item Transactions] LEFT JOIN Items ON [Item Transactions].ItemID = Items.ItemID) ON CLIENTS3.ClientID = [Item Transactions].CustomerID
GROUP BY CLIENTS3.ClientID
PIVOT IIf(IsNull([ItemCategory]),"<>",[ItemCategory]);
and export it as text with master. Don't forget to incliude headings into export.Result is included
aaa-MailChimp-Export---Crosstab.txt
ASKER
Thanks, als315.
As I commented above, the csv file output that I need is something like this:
As I commented above, the csv file output that I need is something like this:
"Email Address","First Name","Last Name","Interests"
x.y@domain.com,John,Doe,"Interest1, Interest4"
.........
In your comment #a40778226 I see sample. Output from my query is exactly as in this comment.
If your comment was wrong, please, show exact expected csv file, based on your sample DB
If your comment was wrong, please, show exact expected csv file, based on your sample DB
ASKER
Hi als315, please accept my apologies for our misunderstanding.
The exact expected csv file, based on my sample DB is:
It would not matter if quotes are included, for example:
The exact expected csv file, based on my sample DB is:
ClientID Interests
1
10110103 Interest2
10110104 "Interest2,Interest3"
10110105 Interest2
10110106 "Interest2,Interest3"
10110108 "Interest2,Interest3"
10110109 "Interest1,Interest2"
10110110 "Interest2,Interest3"
It would not matter if quotes are included, for example:
ClientID Interests
1 ""
10110103 "Interest2"
..........
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks, als315.
You are a Legend!
Regards,
Leigh
You are a Legend!
Regards,
Leigh
Should it be csv file?