on 03-26-2015 6:54 PM
Hello,
I have been going in circles trying to figure out how to successfully write a query that essentially provides a mailing and email address list for each contact within a BP. I have found some other discussions with similar questions, but they have not resolved my questions.
Thank you in advance.
Here is where I currently stand:
T0.[CardType],
T0.[GroupCode],
T1.[GroupName],
T2.[FirstName],
T2.[LastName],
T2.[E_MailL],
T3.[Address],
T3.[Street],
T3.[StreetNo],
T3.[Block],
T3.[Building],
T3.[City],
T3.[State],
T3.[ZipCode],
T3.[Country],
T3.[U_XXDUPSRC]
FROM OCRD T0
INNER JOIN OCPR T2 ON T0.CardCode = T2.CardCode
INNER JOIN CRD1 T3 ON T3.Address = T2.Address
[dbo].[OCRG] T1, [dbo].[OCRD] T0
OCPR.[Address] could be either a Bill-To or Ship-To address since CRD1.[Address] is sometimes the same. So a where statement should probably be used such as WHERE T1.AdresType = 'S'. However, if for some reason, there is no associated address (OCPR.[Address] is blank) the contact should appear anyway
One additional piece of information I would like to include is any associated OCQG.[GroupName] and if there are multiples, they should each have their own column if possible.
Hi Bernd,
Try this
Select T0.[CardType],
T0.[GroupCode],
T1.[GroupName],
T2.[FirstName],
T2.[LastName],
T2.[E_MailL],
T3.[Address],
T3.[Street],
T3.[StreetNo],
T3.[Block],
T3.[Building],
T3.[City],
T3.[State],
T3.[ZipCode],
T3.[Country],
T3.[U_XXDUPSRC]
FROM OCRD T0
INNER JOIN OCPR T2 ON T0.CardCode = T2.CardCode
LEFT JOIN CRD1 T3 ON T3.Address = T2.Address
INNER JOIN OCRG T1 ON T1.GroupCode=T0.GroupCode
for OCQG, you need to use a case statement for that
Hope this helps
Regards
JP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Did you get required query?
Thanks & Regards,
Nagarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.