0

in this statement

from 
    #base U     
    group by grouping sets 
    (
     (a,b,c,d)  --1
    ,(a,b,c,d,e,f) --2 
    ,(a,b,c,d,e,f,g) --3
    ) 

is possibile in a single set an filter before aggregation ?

(a,b,c,d,e,f) where b <> 0

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

0

An approach could be to put the (a,b,c,d,e,f) grouping with a filter as as a seperate query and then use UNION to merge the results.

PhilS
  • 624
  • 3
  • 5
0

Maybe you can try it .

select ... 
from #base U     
group by grouping sets 
((a,b,c,d), (a,b,c,d,e,f,g)) 
union all 
select ... 
from #base U
where b<>0     
group by a,b,c,d,e,f 

Hope it can help you.

Best Regards,

Rachel