Skip to Content
0
Former Member
Apr 01, 2011 at 01:33 AM

Query Retrieval

23 Views

I'm trying to get some data out through this query, but the line entries are being repated,for ex. on the delivery the 3 items are showing up 9 times. What would be a better query

SELECT DISTINCT dbo.ODLN.DocNum AS Del_No, convert(char(11),ODLN.[DocDate],110) as CreationDate,dbo.DLN1.ItemCode,DLN1.[Dscription] ,RDR1.[U_Per] as Personalize,

OITM.[U_LegacyItem] as LegacyItem,ORDR.[NumAtCard],CAST(RDR1.Text as nvarchar(max)) as PackageID, ODLN.TrackNo,CAST(ORDR.Comments as nvarchar(Max))as Remarks

FROM dbo.ODLN ON dbo.DLN1.DocEntry = dbo.ODLN.DocEntry

INNER JOIN

dbo.ORDR LEFT OUTER JOIN

dbo.DLN1 INNER JOIN

INNER JOIN

dbo.OINV INNER JOIN

dbo.INV1 ON dbo.OINV.DocEntry = dbo.INV1.DocEntry ON dbo.ODLN.DocEntry = dbo.INV1.BaseEntry ON dbo.ORDR.DocEntry = dbo.DLN1.BaseEntry INNER JOIN RIN1 ON

dbo.RIN1.BaseEntry = dbo.OINV.DocNum INNER JOIN dbo.RDR1 ON

dbo.RDR1.DocEntry = dbo.ORDR.DocEntry INNER JOIN DBO.OITM ON

dbo.DLN1.ItemCode = dbo.oitm.Itemcode

WHERE ORDR.[CardCode] ='C01076'

order by odln.docnum