2

This Question/Answer seems close to mine, but I think I have a different problem.

Here's my query:

SELECT
PL.PlantName AS 'Plant Name',
M.MachineNumber AS 'Line',
P.Type AS 'Record Type',
P.Reason,
P.ActivityDate,
P.OrderNumber,
P.Bundle,
P.Quantity,
P.ItemLength,
P.Pattern,
P.PartOption,
P.InvCoil,
P.Footage,
P.Material,
P.ScrapCode,
P.EmployeeName,
P.LBperFt,
P.DelayCode,
P.DelayReason,
P.Duration,
P.CostPerLb,
P.ListId,
P.ListText
FROM dbo.Production P WITH (NOLOCK)
JOIN dbo.Plants PL WITH (NOLOCK) ON P.PartnerId = PL.PartnerId
JOIN dbo.Machines M WITH (NOLOCK) ON PL.Id = M.Machine_Maintenance_Plant_Maintenance
WHERE ActivityDate >= '2018-04-01' AND ActivityDate <= '2018-04-07' ORDER BY 'Plant Name';

Before I added the third table, the query was fine. After joining the third table, I'm getting 6 copies of each row returned.

1

This means there is 1 to Many relationship on the third table. You either need to add more in your join to make it 1 to 1 or create a crosswalk table to do the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.