如何从 groupby OLAP Cube 中删除小计?

How to remove subtotals from groupby OLAP Cube?

select Field1,DatePart(Year,aDate) aDate,count(distinct Employee) EmployeeCount from  dbo.myTable with (nolock)   group by cube(Field1,DatePart(Year,aDate))  order by EmployeeCount desc

输出

Field aDate  EmployeeCount
 01-    2012 27166
 NULL   2012 27166
 NULL   NULL 27166 

过滤器显示字段不为空。为什么我在使用 cube 时得到一个 Field NULL 作为 EmployeeCount 输出的一部分?

我明白了。多维数据集包括列为空的小计和总计

有没有一种简单的方法可以删除多维数据集结果中的汇总值

按集合分组使用 group,它允许您 select 聚合级别或集合

select Field1,DatePart(Year,aDate) Year,count(distinct Employee) EmployeeCount from  dbo.aTable with (nolock)  
group by grouping sets((Field1,DatePart(Year,aDate))

this is equivalent to
group by Field1, DatePart(Year,aDate)