Hi
I have a query where I have added in 2 new tables so I can get the PackRef to display. However, is there is no packref it is not showing the result even though there is a row.
therefore I want to see all rows with or without a packref. The code is below. I have played with the joins for the ProductPAck and orderlineitem but either get 6 rows instead of 7 or to many rows completely.
Could someone advise please THanks
I have a query where I have added in 2 new tables so I can get the PackRef to display. However, is there is no packref it is not showing the result even though there is a row.
therefore I want to see all rows with or without a packref. The code is below. I have played with the joins for the ProductPAck and orderlineitem but either get 6 rows instead of 7 or to many rows completely.
Could someone advise please THanks
SQL:
SELECT TOP (100) PERCENT JourneyHeader.JourneyDate, CONVERT(varchar, JourneyHeader.JourneyNumber) AS JourneyNumber, JourneyLine.OrderID,
JourneyHeader.NoOfDrops, JourneyzDropsByProduct.TotalVolume AS m3, dbo.Vehicle.udfVehicleGroup,
dbo.Vehicle.Registration + ' - ' + dbo.Vehicle.Name AS VehicleName, JourneyzDropsByProduct.ProductCode, ProductGroup_1.Name AS [Group],
ProductGroup.Name AS [Sub-group], Customer.CustomerCode, Customer.Name, Customer.City, dbo.ProductPack.PackRef
FROM dbo.JourneyLine AS JourneyLine INNER JOIN
dbo.JourneyHeader AS JourneyHeader ON JourneyLine.JourneyID = JourneyHeader.JourneyID INNER JOIN
dbo.JourneyzDropsByProduct AS JourneyzDropsByProduct ON JourneyHeader.JourneyID = JourneyzDropsByProduct.JourneyID AND
JourneyLine.JourneyLineID = JourneyzDropsByProduct.JourneyLineID INNER JOIN
dbo.Product AS Product ON JourneyzDropsByProduct.ProductID = Product.ProductID INNER JOIN
dbo.ProductGroup AS ProductGroup ON Product.ProductGroupID = ProductGroup.ProductGroupID INNER JOIN
dbo.OrderHeader AS OrderHeader ON JourneyLine.OrderID = OrderHeader.OrderID AND JourneyHeader.JourneyID = OrderHeader.JourneyID INNER JOIN
dbo.Customer AS Customer ON OrderHeader.CustomerID = Customer.CustomerID INNER JOIN
dbo.ProductGroup AS ProductGroup_1 ON ProductGroup.ParentID = ProductGroup_1.ProductGroupID INNER JOIN
dbo.Vehicle ON JourneyHeader.VehicleID = dbo.Vehicle.VehicleID INNER JOIN
dbo.ProductPack ON Product.ProductID = dbo.ProductPack.ProductID INNER JOIN
dbo.OrderLineItem ON OrderHeader.OrderID = dbo.OrderLineItem.OrderID AND dbo.ProductPack.PackID = dbo.OrderLineItem.PackID
WHERE (JourneyHeader.JourneyNumber = 72732) and journeyline.OrderID IN (3338854,3338847,3338787)
ORDER BY JourneyNumber DESC