Hi
I have a View which I have tried to add in a calculation for LineCost. This meant I had to add in the table Delivery as it holds the linecost
After adding the table I now have a result of 80 rows where in fact there should only be 8 rows returned. I have tried to use different Joins but cannot see to get anything but 80 rows. Could someone point advise what to do please. Thanks
I have a View which I have tried to add in a calculation for LineCost. This meant I had to add in the table Delivery as it holds the linecost
After adding the table I now have a result of 80 rows where in fact there should only be 8 rows returned. I have tried to use different Joins but cannot see to get anything but 80 rows. Could someone point advise what to do please. Thanks
SQL:
SELECT dbo.JourneyHeader.JourneyDate, dbo.Vehicle.Name, dbo.JourneyHeader.DriverName, dbo.JourneyHeader.VehicleName,
dbo.JourneyHeader.JourneyNumber, dbo.JourneyHeader.TotalVolume, dbo.JourneyLine.DropNumber, dbo.OrderHeader.DeliveryAddress,
dbo.Customer.Name AS [Customer Name], dbo.Customer.County, dbo.Customer.PostCode, dbo.JourneyHeader.NoOfStops, dbo.OrderHeader.udfSalesOrderOTIF,
dbo.JourneyHeader.NoOfPacks, dbo.JourneyHeader.udfLoader1, dbo.JourneyHeader.udfLoader2, dbo.JourneyHeader.TransportCost, dbo.JourneyHeader.Reference,
dbo.DeliveryArea.Name AS DeliveryArea,
dbo.OrderHeader.TotalVolume * dbo.Delivery.LineCost AS LineCost
FROM dbo.JourneyHeader INNER JOIN
dbo.JourneyLine ON dbo.JourneyHeader.JourneyID = dbo.JourneyLine.JourneyID INNER JOIN
dbo.Vehicle ON dbo.JourneyHeader.VehicleID = dbo.Vehicle.VehicleID INNER JOIN
dbo.OrderHeader ON dbo.JourneyLine.OrderID = dbo.OrderHeader.OrderID INNER JOIN
dbo.Customer ON dbo.OrderHeader.CustomerID = dbo.Customer.CustomerID INNER JOIN
dbo.Delivery ON dbo.OrderHeader.DeliveryAreaID = dbo.Delivery.DeliveryAreaID INNER JOIN
dbo.DeliveryArea ON dbo.DeliveryArea.DeliveryAreaID = dbo.Delivery.DeliveryAreaID
WHERE (dbo.JourneyHeader.JourneyNumber = 88668)
ORDER BY dbo.JourneyHeader.JourneyNumber