PDA

Click to See Complete Forum and Search --> : [RESOLVED] trying to do a SUM statement in Crystal Reports


seba
Jul 18th, 2008, 04:17 PM
Hello Everyone,

Im trying to do a statement in the "SHOW SQL QUERY" window that will narrow down some data for me. The thing is if I try to enter this statement:


Select
SHD."CODE", Sum(SHD.BVORDQTY), SHD."SHD_DESCRIPTION", BTL."SUB_CODE", I."ONHAND"


The "Sum(SHD.BVORDQTY)" part gets edited out by crystal reports. How can I make sure that this is included? Its really important for me to have this in the report. Do I need to do this somewhere else?

THANKS!


The rest of the statement if any one needs it:





Select SHD."CODE", Sum(SHD.BVORDQTY), SHD."SHD_DESCRIPTION", BTL."SUB_CODE", I."ONHAND"
From "TESTER"."SALES_HISTORY_DETAIL" SHD, "TESTER".BOM_TOP_LEVEL BTL, "TESTER".INVENTORY I
WHERE SHD."INVOICE_DATE" = "20071010"
AND BTL."TOP_CODE" = SHD."CODE"
AND BTL."SEQUENCE" = 01
AND I."CODE" = BTL."SUB_CODE"
Group By SHD."CODE", SHD."SHD_DESCRIPTION", BTL."SUB_CODE", I."ONHAND"

seba
Jul 19th, 2008, 09:22 AM
OK I figured out that in order to do a SUM I need to create a SQL EXPRESSION

But when I do a SUM, I need a GROUP BY clause, yet the SQL QUERY wont allow it ... any ideas ? :eek2: :cry:

seba
Jul 19th, 2008, 09:53 AM
Never mind I got it now, in case any one wants to know:

You have to insert a GROUP in order to get GROUP BY to show up in the query box. Then you suppress the DETAIL section in order to display the groupings