Quantcast
Channel: Für Entwickler: SQL Server Forum
Viewing all articles
Browse latest Browse all 1772

Würfel mit einem T-SQL Statement als Basis

$
0
0

Guten Tag,

kann man das Ergebnis einer SQL-Abfrage, die das CUBE Statement beinhaltet in einen Würfel schreiben, so dass dieser WÜrfel dauerhaft besteht?

Bsp.:

USE AdventureWorks2008R2

GO

SELECT

 T.[Group] AS N'Region', T.CountryRegionCode AS N'Country'

GO

SELECT
 T.[Group] AS N'Region', T.CountryRegionCode AS N'Country'
,S.Name AS N'Store', H.SalesPersonID
,SUM(TotalDue) AS N'Total Sales'


FROM
 Sales.Customer AS C

INNER JOIN Sales.Store AS S
ON C.StoreID  = S.BusinessEntityID
INNER JOIN Sales.SalesTerritory AS T
ON C.TerritoryID  = T.TerritoryID
INNER JOIN Sales.SalesOrderHeader AS H
ON C.CustomerID = H.CustomerID
WHERE
 T.[Group] = N'Europe'
AND T.CountryRegionCode IN(N'DE', N'FR')
AND H.SalesPersonID IN(287, 288, 290)
AND SUBSTRING(S.Name,1,4)IN(N'Vers', N'Spa ')

GROUP
 BY CUBE(
T.[Group], T.CountryRegionCode, S.Name, H.SalesPersonID)


ORDER
 BY T.[Group], T.CountryRegionCode, S.Name, H.SalesPersonID;
,S.Name AS N'Store', H.SalesPersonID
,SUM(TotalDue) AS N'Total Sales'


FROM

 Sales.Customer AS C
INNER JOIN Sales.Store AS S
ON C.StoreID  = S.BusinessEntityID
INNER JOIN Sales.SalesTerritory AS T
ON C.TerritoryID  = T.TerritoryID
INNER JOIN Sales.SalesOrderHeader AS H
ON C.CustomerID = H.CustomerID
WHERE
 T.[Group] = N'Europe'
AND T.CountryRegionCode IN(N'DE', N'FR')
AND H.SalesPersonID IN(287, 288, 290)
AND SUBSTRING(S.Name,1,4)IN(N'Vers', N'Spa ')


GROUP BY CUBE(

T.[Group], T.CountryRegionCode, S.Name, H.SalesPersonID)

ORDER

 BY T.[Group], T.CountryRegionCode, S.Name, H.SalesPersonID;

W.


wksh


Viewing all articles
Browse latest Browse all 1772

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>