USE DataMiningDW
GO

SELECT CAST(Cluster As VARCHAR(20)) AS Cluster,SUM(Distance) AS Distance
FROM OPENQUERY(DMS,'
SELECT 
  Cluster() as [Cluster],
  ClusterDistance() as [Distance]
FROM [CellsC]
NATURAL PREDICTION JOIN
(SELECT * FROM MINING STRUCTURE [Cells].CASES) AS t' ) 
GROUP BY GROUPING SETS 
	(CAST(Cluster as VARCHAR(20))
	,() );
GO

SELECT CAST(Cluster AS VARCHAR(20)) AS Cluster,SUM(Distance) AS Distance
FROM OPENQUERY(DMS,'
SELECT 
  Cluster() as [Cluster],
  ClusterDistance() as [Distance]
FROM [Cells]
NATURAL PREDICTION JOIN
(SELECT * FROM MINING STRUCTURE [Cells].CASES) AS t' ) 
GROUP BY GROUPING SETS 
	(CAST(Cluster as VARCHAR(20))
	,() );
GO