08-20-2016 08:42 AM - edited 08-20-2016 09:14 AM
I am trying to get distinct records using join and where conditions.
But I got duplicate records while am using join query.
Here's my query can any one please help me into this.
select jobs.Name as jobNumber,swo.Workorder_VIN_Number__c as vin,swo.Workorder_Technician_Names__c as technicianNames,
swo.Name as serviceNumber ,swo.Service_Date__c as serviceDate,swo.Scheduled_Service_Name__c as scheduledServiceName ,
swo.ssId_Accuracy__c as scheduledServiceIdAccuracy,swo.Scheduled_Service_Description__c as scheduledServiceDescription
,swo.Workorder_Dealer_Name__c as dealerName
,swo.Service_Dealership_Code__c as dealerCode,swo.Workorder_Advisor_Name__c as advisorName,Jobs.Jobs_Description__c as jobDescription
from swo join Jobs on
join qrsContact on qrsContact.id=swo.WORKORDER_CONTACT__C and
qrsContact.FirstName=swo.Workorder_Contact_Firstname__c and qrsContact.LastName=swo.Workorder_Contact_Lastname__c
join qrscvo on qrscvo.Contact_Name__c=qrsContact.id
where qrsContact.Email= '___' and qrsContact.MYAUDI__C='__'
and qrsContact.SOURCE__C='___' and qrscvo.Customer_vehicle_Relationship_Status__c ='___' and qrscvo.customer_vehicle_relationship__c = '____'
08-23-2016 09:29 PM
Thanks for the question.
I'm not totally sure what the cause of your problem is - hard to tell without an example of the results returned versus what you expected it to return. Do you mean that there are full rows returned that are identical to each other, or do you mean that some of the original rows from the table were joined multiple times with other rows (i.e. if you put a 'select distinct' instead of a 'select' does that give you the result you hoped for?)
My guess is either: