I have a Marketing Cloud query that returns records from synchronized data extensions. The query is looking for recent appointments scheduled. The query returns duplicate appointments (where the record is exactly the same as another). What I am trying to do return only one record. Not sure why it is returning more than one record for the same Salesforce event. Happy for any insight into my query.
SELECT Distinct
o.CreatedDate,
o.StageName,
e.Id,
e.OwnerId,
e.Subject,
e.WhoId,
e.StartDateTime,datediff(minute,GETDATE(),e.StartDateTime)/60 AS HoursCountDown,
e.IsDeleted,
e.WEGP1_MeetingResult__c,
e.WEGP1_MeetingType__c,
e.ActivityDateTime as StartDate,
e.WhatId,
c.Classification__c,
u.Name as FromName,
u.Email as FromEmail
FROM [Event_Salesforce] e
JOIN [Opportunity_Salesforce] as o on o.OwnerId = e.OwnerId
Left JOIN [Contact_Salesforce] as c on c.Id = e.WhoId
JOIN [User_Salesforce] as u on u.Id = e.OwnerId
WHERE o.CreatedDate >= DATEADD(DAY, -1, GETDATE())
and e.WhoId is not null
and e.ActivityDateTime is not null
and e.IsDeleted = 'False'
and e.WEGP1_MeetingType__c = 'Needs Analysis'
and (e.[StartDateTime] > CONVERT(DATE, GETDATE())) AND (e.[StartDateTime] < CONVERT(DATE, DATEADD(DAY, 15, GETDATE())))