• You have to change the nest after the time key change too so it should work like this:

    SELECT e.FirstName + ' ' + e.LastName AS FullName, fsq.CalendarYear, fsq.CalendarQuarter, fsq.SalesAmountQuota, frs.SalesAmount,

    CASE WHEN fsq.SalesAmountQuota > frs.SalesAmount THEN 1 ELSE CASE WHEN fsq.SalesAmountQuota = frs.SalesAmount THEN 0 ELSE - 1 END END AS Trend

    FROM dbo.FactSalesQuota AS fsq INNER JOIN

    DimEmployee AS e ON fsq.EmployeeKey = e.EmployeeKey LEFT OUTER JOIN

    (SELECT f.EmployeeKey, t.CalendarYear, t.CalendarQuarter, SUM(f.SalesAmount) AS SalesAmount

    FROM FactResellerSales AS f INNER JOIN

    DimDate AS t ON f.DueDateKey = t.DateKey

    GROUP BY f.EmployeeKey, t.CalendarYear, t.CalendarQuarter) AS frs ON fsq.EmployeeKey = frs.EmployeeKey