I am trying to do joins on two tables and filter on values that are not in my select statement. 

The following query does not work. 

```
select b.[[Product]].[Major Category]]] ,sum(a.BIC_ZCDP) from TEMP_FORECAST_ALL a
join OUT_Dimension_DP_Product b
on right(a.MATERIAL,10) = b.[[Product]].[10D]]]  
join OUT_Dimension_DP_Market c
on a.BIC_ZRMARKET =  c.[[Market]].[Market]]]
group by b.[[Product]].[Major Category]]]
having a.CALMONTH in ('201810','201811','201812') and c.[[Market]].[Region]]] = 'UK'

```

I get the following errors 

> 
> Msg 8121, Level 16, State 1, Line 7
>  Column 'TEMP\_FORECAST\_ALL.CALMONTH' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.
> 
> 
> Msg 8121, Level 16, State 1, Line 7
>  Column 'TEMP\_FORECAST\_ALL.CALMONTH' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.
> 
> 
> Msg 8121, Level 16, State 1, Line 7
>  Column 'TEMP\_FORECAST\_ALL.CALMONTH' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.
> 
> 
> Msg 8121, Level 16, State 1, Line 7
>  Column 'OUT\_Dimension\_DP\_Market.[Market].[Region]' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.
> 
> 
> 

I don't want to add Region and CALMONTH in my group by clause.