Link to home
Start Free TrialLog in
Avatar of armgon
armgonFlag for United States of America

asked on

MSSQL Query for Selecting the SUM of a Specific Group

Any assistance with the following would be greatly appreciated.

I need to get the results of the total merchandise sold (Totmerch) for Inventory Items (Invtid) that has the same ClassId.

I have this query but I cannot get it to work it errors out as follows:
Msg 156, Level 15, State 1, Line 15
Incorrect syntax near the keyword 'group'.


Query:
select

c.classid,
sum(a.TotMerch)
from soshipline a,soshipheader b,inventory c
where
a.invtid=c.invtid and
a.shipperid=b.shipperid

and b.cancelled<>'1'
and b.invcdate>='01/01/2016'
and b.invcdate<='12/31/2016'
and b.invcnbr<>''
order by c.classid
group by c.classid;

Thank you in advance for your help.
ASKER CERTIFIED SOLUTION
Avatar of Megan Brooks
Megan Brooks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of armgon

ASKER

Thank you. Simple fix.