0

在这份声明中

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
    ) 

聚合之前是否可以在单个集合中使用过滤器?

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

4

2 回答 2

0

一种方法可能是将带有过滤器的 (a,b,c,d,e,f) 分组作为单独的查询,然后使用 UNION 合并结果。

于 2018-12-14T10:59:47.793 回答
0

也许你可以试试。

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 

希望它可以帮助你。

此致,

雷切尔

于 2018-12-26T09:06:29.220 回答