I have the below query/subquery. The subquery by itself does return data so I know that is working. However, I simply want a column with the next change, yet when I run it, no rows are returned, just the message Command(s) completed successfully! But here are my rows?
SELECT Total_2004_SQ-Total_2003_SQ AS NetChange
From (SELECT s.BusinessEntityID, SUM(s2004.SalesQuota) AS Total_2004_SQ,SUM(s2003.SalesQuota) As Total_2003_SQ
FROM Sales.SalesPerson As s
LEFT OUTER JOIN Sales.SalesPersonQuotaHistory AS s2004
ON s.BusinessEntityID = s2004.BusinessEntityID AND YEAR(s2004.QuotaDate) = 2004
LEFT OUTER JOIN Sales.SalesPersonQuotaHistory As s2003
ON s.BusinessEntityID = s2003.BusinessEntityID AND YEAR(s2003.QuotaDate) = 2003
GROUP BY s.BusinessEntityID)
This is on a SQL Server 2008 database.