on 2025 Apr 20 2:32 PM
Hello all,
I'm trying to get DISTINCT contact info based on invoices in a specific time frame. Specifically, this is related to the onboarding of the Avalara Tax add-on. I have written a query to get the information I need and it works with the exception that the contact information is not DISTINCT and I cannot figure out how to get it to be. Any help here is appreciated, please! B1 v10 HANA
Here is the query:
SELECT T0."CardCode", T0."CardName", T0."CardType", T0."GroupCode", T0."CmpPrivate", T0."Address", T0."Building", T0."StreetNo", T0."ZipCode", T0."City", T0."County", T0."State1", T0."Country", T0."CntctPrsn", T0."E_Mail", T0."Phone1", T0."LicTradNum", T2."Tel1", T2."U_Ext", T2."E_MailL"
FROM OCRD T0 INNER JOIN OINV T1 ON T0."CardCode" = T1."CardCode" INNER JOIN OCPR T2 ON T1."CntctCode" = T2."CntctCode"
WHERE T1."DocDate" >= '20240101'
Request clarification before answering.
Hi,
Please give this a try:
SELECT distinct T0."CardCode", T0."CardName", T0."CardType", T0."GroupCode"
, T0."CmpPrivate", T0."Address"
, cast(T0."Building" as nvarchar) as "Building"
, T0."StreetNo", T0."ZipCode"
, T0."City", T0."County", T0."State1", T0."Country", T0."CntctPrsn", T0."E_Mail"
, T0."Phone1", T0."LicTradNum", T2."Tel1", T2."U_Ext"
, T2."E_MailL"
FROM OCRD T0 INNER JOIN OINV T1 ON T0."CardCode" = T1."CardCode" INNER JOIN OCPR T2 ON T1."CntctCode" = T2."CntctCode"
WHERE T1."DocDate" >= '20240101'
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
just alter the join to OCPR to be "OCPR T2 ON T1."CntctCode" = T2."CntctCode" AND T1."CardCode" = T2."CardCode".
BR,
Matija
User | Count |
---|---|
95 | |
16 | |
6 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.