When Deptno is not null Then Cast ( DEPTNO as Nvarchar(max)) When Region is not null Then Region When Country is not null then Country

我们能否分割字符串并在case sql语句中使用。

我需要产生这样的结果

我正在使用这样的一个查询来生成

 select  
     Case When Deptno is not null Then  Cast( DEPTNO as Nvarchar(max)) When Region  is not null Then Region When Country is not null then Country  END   ,
     Count(EmpNo) EmpCount, 
     Sum(Sal) Total
     from emp group by  Country,Region,DEPTNO   with rollup having country is not null order by  Country,region,Deptno,  EmpCount desc