Department |achead | location Admin |Telecommunication | usa Admin |Telecommunication | usa Admin |Computers | uae Admin |Computers | uae Admin1 |Micro | usa Admin1 |Micro | usa
Department |achead | Total_Count_Location Admin | null | null Telecommunication | null | null Admin |Telecommunication | 2 Admin |Computers | 2 | Total| 4 Admin1 | null | null Micro | null | null Admin1 |Micro | 2 | Total | 2
SELECT CASE GROUPING([departmant]) WHEN 1 THEN 'Total' ELSE [departmant] END AS 'departmant', CASE GROUPING([achead]) WHEN 1 THEN 'Total' ELSE [achead] END AS 'achead', COUNT([location]) AS 'Total_Count_Location' INTO #TMP2 FROM temptest GROUP BY [departmant], [achead] WITH ROLLUP SELECT CASE achead WHEN 'Total' then '' else departmant end as departmant, achead, Total_Count_Location FROM #TMP2 WHERE departmant!='TOTAL'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)