Avatar of Angel02
Angel02
 asked on

Using column in the where/having clause but not in group by

I have a query like

Select Category, Sum (Cost), Format([OrderDate],"ww")
from OrderTable
GROUP BY Category, Format([OrderDate],"ww")
--HAVING customer <> 12

Now I want to make sure NOT to include the rows with customer = 12 in calculating the cost column.

I do not want to Group it y customer. But the query does not let me use Customer column in Having clause if I dont use it in group by.

Select Category, Sum (Cost), Format([OrderDate],"ww")
from OrderTable
GROUP BY Category, Format([OrderDate],"ww")
--HAVING customer <> 12
Microsoft AccessSQL

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
SOLUTION
Qlemo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck