Dubletter i GROUP BY
HejJeg har lavet et view som gerne skulle give mig en liste med unique PLL ID, men når jeg generer listen får jeg alle linjer dobbelt, efter at have indsat D.Extra6 i select og GROUP BY.... er der en frisk SQL gut derude som kan hjælpe?
SELECT A.Firm, A.ItemScan AS ItemNo, D.Text1 AS Text, A.ObjectNo AS Batch, A.BestBeforeDate AS MHT, A.Cnt AS Count, B.Pallet, D.Extra6 AS PR_PLL
FROM dbo.vItemCount AS A WITH (NOLOCK) INNER JOIN
dbo.vPallet AS B WITH (NOLOCK) ON A.Firm = B.Firm AND A.Warehouse = B.Warehouse AND A.Location = B.Pallet LEFT OUTER JOIN
dbo.vItemCountDetail AS C WITH (NOLOCK) ON A.Firm = C.Firm AND A.Recid = C.Recid INNER JOIN
dbo.tItem AS D WITH (NOLOCK) ON A.ItemScan = D.ItemScan
WHERE (A.Firm = 'xxxxxx'')
GROUP BY A.Firm, A.Recid, A.Warehouse, A.LocationType, A.ItemScan, D.Text1, A.ObjectType, A.ObjectNo, A.ProdDate, A.BestBeforeDate, A.DelBeforeDate, B.Inserted, A.Extra1, A.Extra2, A.Extra3, A.Extra4, A.Extra5, A.Cnt, B.Location,
B.LocationType, B.Pallet, D.Extra6, B.Inserted, B.Locked, A.Locked
HAVING (A.LocationType = 'P') AND (B.LocationType = 'L')