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

Report to show value of new sales invoices

Hi - I want to report each month on the value of invoiced sales by new customers. I define a new customer who was added to SAP in a time frame say 1 month. I also want to see what Item Group they have purchased to match against marketing costs.

I have this so far:

SELECT T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam], sum(T2.[LineTotal] - T2.[LineVat]) as Value

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

WHERE T0.[CreateDate] >= [%0] and T1.[DocDate] >= [%1] and T1.[DocDate] <= [%2] and T4.[ItmsGrpCod] <> 126

GROUP BY T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam]

But is doesn't look right. Any ideas are appreciated.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Dec 05, 2014 at 12:33 PM

    Hi Tim,

    Try this

    SELECT datename(mm,t0.CreateDate) as 'Month',T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam], sum(T2.[LineTotal] - T2.[LineVat]) as Value

    FROM OCRD T0

    INNER JOIN OINV T1 ON T0.[CardCode] = T1.[CardCode]

    INNER JOIN INV1 T2 ON T1.[DocEntry] = T2.[DocEntry]

    INNER JOIN OITM T3 ON T2.[ItemCode] = T3.[ItemCode]

    INNER JOIN OITB T4 ON T3.[ItmsGrpCod] = T4.[ItmsGrpCod]

    WHERE WHERE T0.[CreateDate] >= [%0] and T1.[DocDate] >= [%1] and T1.[DocDate] <= [%2] and T4.[ItmsGrpCod] <> 126

    GROUP BY t0.CreateDate,T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam]

    ORDER BY t0.CreateDate

    Regards,

    Manish

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2014 at 02:40 PM

    Hi Tim,

    Please advice your expected result from your query.

    Try:

    SELECT T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam], sum(T2.[LineTotal] - T2.[LineVat]) as Value

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

    WHERE T0.[CreateDate] >= [%0] and T1.[DocDate] >= [%1] and T1.[DocDate] <= [%2] and T4.[ItmsGrpCod] <> 126

    GROUP BY T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam]

    order by T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam]

    Thanks & Regards,

    Nagarajan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2014 at 12:57 AM

    Hi Tim,


    Try:


    SELECT T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam], sum(T1.Linetotal - T1.LineVat) as Value

    FROM OINV T0 INNER JOIN INV1 T1 ON T1.[DocEntry] = T0.[DocEntry] INNER JOIN OITM T3 ON T3.[ItemCode] = T1.[ItemCode] INNER JOIN OITB T4 ON T3.[ItmsGrpCod] = T4.[ItmsGrpCod]

    WHERE T0.[CardCode] in (Select [CardCode] From OCRD Where CreateDate >= [%0]) and T0.[DocDate] >= [%1] and T0.[DocDate] <= [%2] and T4.[ItmsGrpCod] <> 126

    GROUP BY T0.[CardCode], T0.[CardName], T4.[ItmsGrpNam]


    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.