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

Query - Grouping by Item

Am trying to have same items on a particular day be grouped under one total but even after adding sum it is giving me same items of the same day separate...

SELECT T0.[PostDate],T0.[DocNum],T1.[ItemCode], T1.[ItemName], sum(T0.[PlannedQty]) as 'Planned Qty', sum(T0.[CmpltQty]) 'Comp Qty' FROM OWOR T0 inner join OITM T1 on T1.[ItemCode] =T0.[ItemCode] WHERE T0.[PostDate] >=[%0] and T0.[PostDate] <=[%1] and T1.[ItmsGrpCod] in (104,106,107,108,113,116,120) GROUP BY T0.[PostDate], T1.[ItemCode], T1.[ItemName], T0.[PlannedQty], T0.[CmpltQty],T0.[DocNum]

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 13, 2010 at 12:27 PM

    Hi..

    From Group By Remove Planned Qty & Completed Qty because you have made Sum for those fields in Select Query so remove from them group by you will get your desire.

    Regards,

    Bhavank

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 13, 2010 at 12:27 PM

    Try to leave out the docnum if you want only the sums:

    SELECT T0.PostDate,T1.ItemCode, T1.ItemName,
     sum(T0.PlannedQty) as 'Planned Qty', sum(T0.CmpltQty) 'Comp Qty'
     FROM OWOR T0 inner join OITM T1 on T1.ItemCode =T0.ItemCode
     WHERE T0.PostDate >=[%0] and T0.PostDate <=[%1] and T1.ItmsGrpCod in (104,106,107,108,113,116,120)
     GROUP BY T0.PostDate, T1.ItemCode, T1.ItemName, T0.PlannedQty, T0.CmpltQty

    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.