Skip to Content
author's profile photo Former Member
Former Member

Sales report by item - Assistance please

Hello all,

I have the bellow sales report.

I would like make some adjustments to it but somehow I get an error on every change done.

Could anyone assist please?

SELECT T4.CardCode,T4.CardName, SUM(T0.Price * T0.Quantity) AS turnover,SUM(T0.Quantity) AS QTY, T2.ItmsGrpNam, T5.GroupName, T1.ItemCode, T1.ItemName

FROM INV1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T2.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN OINV T3 ON T3.DocEntry = T0.DocEntry INNER JOIN OCRD T4 ON T1.CardCode = T4.CardCode INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode

WHERE T4.CardName LIKE '[%0\]%'AND T3.DocDate Between [%1\] AND [%2\]

GROUP BY T4.CardCode, T4.CardName, T2.ItmsGrpNam, T5.GroupName, T1.ItemCode, T1.ItemName

Changes I want to make:

*Cancel the selection of BP (supplier) when running the report. I want it to run on all BP (Suppliers)

So just date defining.

*erase the following columns: Groupname, ItmsGrpNam
*change the columns order:1- Itemcode, 2- Itemname, 3- Cardname, 4- qty, 5- turnover

I usually have no issues editing such queries, but somehow I am doing it all wrong this time.

Help me please 😊 !

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Aug 23, 2016 at 07:06 AM

    Hi,

    Please try this:

    SELECT T1.ItemCode, T1.ItemName, T4.CardCode,T4.CardName, SUM(T0.Price * T0.Quantity) AS turnover,SUM(T0.Quantity) AS QTY, T2.ItmsGrpNam, T5.GroupName

    FROM INV1 T0

    INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode

    INNER JOIN OITB T2 ON T2.ItmsGrpCod = T1.ItmsGrpCod

    INNER JOIN OINV T3 ON T3.DocEntry = T0.DocEntry

    INNER JOIN OCRD T4 ON T1.CardCode = T4.CardCode

    INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode

    WHERE T4.CardName LIKE '[%0]%'

    AND T3.DocDate Between [%1] AND [%2]

    GROUP BY T4.CardCode, T4.CardName, T2.ItmsGrpNam, T5.GroupName, T1.ItemCode, T1.ItemName

    Please note that I have not removed the BP filter. When you run the query, just do not fill in anything in this parameter.

    Regards,

    Johan

    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.