Last active
June 11, 2016 13:47
-
-
Save patpawlowski/2ee0d3e83b4f5f0a338d7a0cdb705029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Written by: Patrick Pawlowski | |
Company: Ticomix | |
Created On: 2016.06.10 | |
Requires: https://gist.github.com/patpawlowski/eac1482fb346175c726fc41821cd9e1e#file-goldmine-contacts-view-sql | |
*/ | |
Select ac.CONTACT, ea.CONTSUPREF + isnull(ea.ADDRESS1, '') EmailAddress | |
from CONTSUPP ac | |
left join CONTSUPP ea on ac.recid = ea.LINKACCT and ea.RECTYPE = 'P' and ea.CONTACT = 'E-mail Address' | |
where ac.RECTYPE = 'C' | |
union | |
Select CONTACT, EmailAddress from contacts | |
order by 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A GoldMine query that uses the Contacts view to create a singe result set of primary contacts and additional contacts and their email address. Other fields can be added but remember to add them to both sides of the union. If you want to add fields that only exist for primary contacts then just add an empty string placeholder in the additional contacts part of the union.