Skip to Content

Need some help with SQL

Hi

I have

SELECT T1.[U_NF_LagPlatz1] AS 'Lagerplatz 1', T1.[U_NF_LagPlatz2] AS 'Lagerplatz 2', T0.[ItemCode] AS 'Artikelnr.', T0.[ItemName] AS 'Artikelbeschreibung', T0.[FrgnName] AS 'Zusatzbeschreibung', T0.[OnHand] AS 'Bestand Gesamt'  
FROM  [dbo].[OITM] T0  INNER  JOIN [dbo].[OITW] T1  ON  T1.[ItemCode] = T0.[ItemCode]  INNER JOIN [dbo].[ITT1] T2 ON T0.[ItemCode] = T2.[Code]
WHERE T1.[WhsCode] = 'NFE-1'  AND (T0.[ItemCode] LIKE '%KAA%' OR T2.[Father] LIKE '%KAA%')
ORDER BY T1.[U_NF_LagPlatz1], T0.[ItemCode]

and it basically retruns exactly what I want.

However, some items are listed multiple times. How do I get every item to be listed only once?

Thanks

Franz

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2011 at 04:27 PM

    Hi Franz,

    Try:

    SELECT Distinct T1.[U_NF_LagPlatz1] AS 'Lagerplatz 1', T1.[U_NF_LagPlatz2] AS 'Lagerplatz 2', T0.[ItemCode] AS 'Artikelnr.', T0.[ItemName] AS 'Artikelbeschreibung', T0.[FrgnName] AS 'Zusatzbeschreibung', T0.[OnHand] AS 'Bestand Gesamt'  
    FROM  [dbo].[OITM] T0  INNER  JOIN [dbo].[OITW] T1  ON  T1.[ItemCode] = T0.[ItemCode]  INNER JOIN [dbo].[ITT1] T2 ON T0.[ItemCode] = T2.[Code]
    WHERE T1.[WhsCode] = 'NFE-1'  AND (T0.[ItemCode] LIKE '%KAA%' OR T2.[Father] LIKE '%KAA%')
    ORDER BY T1.[U_NF_LagPlatz1], T0.[ItemCode]

    Thanks,

    Gordon

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.