sql server 2008 通用表达式CTE

WITH TopSales (SalesPersonID,TerritoryID , NumberOfSales)/*定义*/
AS
(
	SELECT SalesPersonID,TerritoryID, COUNT(*)
	FROM Sales.SalesOrderHeader
	GROUP BY SalesPersonID,TerritoryID
)
	SELECT * FROM TopSales
	WHERE SalesPersonID IS NOT NULL
	ORDER BY NumberOfSales DESC

sql server 2008 通用表达式CTE_第1张图片
 

你可能感兴趣的:(sql server 2008 通用表达式CTE)