Created
June 28, 2016 13:02
-
-
Save Fhernd/e21774fbd461c074d70f68bbfcd6f9a8 to your computer and use it in GitHub Desktop.
Ejemplo de uso de jerarquía de datos anidada. [OrtizOL]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT s.BusinessEntityID AS 'ID Vendedor', | |
SUM(S2008.SalesQuota) AS 'Total Quota Ventas 2008', | |
SUM(S2007.SalesQuota) AS 'Total Quota Ventas 2007' | |
FROM Sales.SalesPerson AS S | |
LEFT OUTER JOIN Sales.SalesPersonQuotaHistory AS S2008 | |
ON S.BusinessEntityID = S2008.BusinessEntityID | |
AND YEAR(S2008.QuotaDate) = 2008 | |
LEFT OUTER JOIN Sales.SalesPersonQuotaHistory AS S2007 | |
ON S.BusinessEntityID = S2007.BusinessEntityID | |
AND YEAR(s2007.QuotaDate) = 2007 | |
GROUP BY S.BusinessEntityID; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment