Skip to Content

Inventory Report (OINM duplicate return)

Hi,

guys, i have a problem when doing an inventory report.
The query brings the information, but there are many duplicate lines.
I tried to limit in the OINM by the field "TransType (" 59, 20), but even so there are several duplicate lines and with that making it difficult to extract the information.
I ask the specialists for help.

T2."TransType",T2."DocDate", T2."InQty", T2."OutQty", T4."WhsCode", T3."WhsName" AS "Nome do depósito", T1."ItemCode", T1."ItemName", T0."ItmsGrpNam", T1."InvntryUom", T1."U_RSD_PesoBruto", T1."U_RSD_UN_Conversao", T4."AvgPrice" 

FROM  OITB T0  
INNER  JOIN OITM T1  ON  T1."ItmsGrpCod" = T0."ItmsGrpCod"   
INNER  JOIN OINM T2  ON  T2."ItemCode" = T1."ItemCode"   
INNER  JOIN OWHS T3  ON  T3."WhsCode" = T2."Warehouse"   
INNER  JOIN OITW T4  ON  T4."WhsCode" = T3."WhsCode"   
INNER  JOIN OITM T5  ON  T5."ItemCode" = T4."ItemCode"   

WHERE 
T2."TransType" in (59,20) AND
T1."ItemCode" = [%0]

Thankful!

Regards

Junior

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Jul 20, 2020 at 12:00 PM

    Hi Junior,

    Try it

    select top 10 T2."TransType",T2."DocDate", SUM(T2."InQty") AS "InQty", SUM(T2."OutQty") AS "OutQty", T4."WhsCode", T3."WhsName" AS "Nome do depósito", T1."ItemCode", T1."ItemName", T0."ItmsGrpNam", T1."InvntryUom", T1."U_RSD_PesoBruto", T1."U_RSD_UN_Conversao", AVG(T4."AvgPrice") AS "AvgPrice" FROM OITB T0 INNER JOIN OITM T1 ON T1."ItmsGrpCod" = T0."ItmsGrpCod" INNER JOIN OINM T2 ON T2."ItemCode" = T1."ItemCode" INNER JOIN OWHS T3 ON T3."WhsCode" = T2."Warehouse" INNER JOIN OITW T4 ON T4."WhsCode" = T3."WhsCode" INNER JOIN OITM T5 ON T5."ItemCode" = T4."ItemCode" WHERE T2."TransType" in (59,20) AND T1."ItemCode" = '[%0]' GROUP BY T2."TransType",T2."DocDate",T4."WhsCode",T3."WhsName", T1."ItemCode", T1."ItemName", T0."ItmsGrpNam", T1."InvntryUom" ,T1."U_RSD_PesoBruto", T1."U_RSD_UN_Conversao"

    Add a comment
    10|10000 characters needed characters exceeded

    • Greetings Anuj Kumar!


      It helped me a lot with the TOP 10, I put TOP100 to reach my goal.
      There is only one thing I forgot to mention that the field (T4.OnHand) and putting it again I duplicate the information.
      The OITW field (T4.OnHand) is important because I need the accumulated total.
      Do you have any idea?

      Regards,

      Junior.

  • Posted on Jul 21, 2020 at 09:22 AM

    Pls try it

    select  T2."TransType",T2."DocDate", T4."WhsCode", T3."WhsName" AS "Nome do depósito", SUM(T2."InQty") AS "InQty", SUM(T2."OutQty") AS "OutQty",T4."OnHand", T1."ItemCode", T1."ItemName", T0."ItmsGrpNam", T1."InvntryUom", 
     T1."U_RSD_PesoBruto", T1."U_RSD_UN_Conversao", 
     AVG(T4."AvgPrice") AS "AvgPrice" 
    FROM OITB T0 
    INNER JOIN OITM T1 ON T1."ItmsGrpCod" = T0."ItmsGrpCod" 
    INNER JOIN OINM T2 ON T2."ItemCode" = T1."ItemCode" 
    INNER JOIN OWHS T3 ON T3."WhsCode" = T2."Warehouse" 
    INNER JOIN OITW T4 ON T4."WhsCode" = T3."WhsCode" and T4."ItemCode"=T1."ItemCode"
    INNER JOIN OITM T5 ON T5."ItemCode" = T4."ItemCode" 
    WHERE T2."TransType" in (59,20) AND 
     T1."ItemCode" = '[%0]' 
     GROUP BY T2."TransType",T2."DocDate",T4."WhsCode",T3."WhsName", 
     T1."ItemCode", T1."ItemName", T0."ItmsGrpNam", T1."InvntryUom" 
     ,T1."U_RSD_PesoBruto", T1."U_RSD_UN_Conversao"
     ,T4."OnHand"
    
    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.