select *,
case when SumOfCommGross > 12499 Then SumOfCommGross*.075
else 0 end As BaseCommission
from
(
SELECT DISTINCT
SUM(CommGross) AS SumOfCommGross, AVG(CommGross) AS AvgOfCommGross, COUNT(*) AS CountOfCompletionsListCurrentMonth,
SUM(CommGross / 20) AS Commission, SalesUserName
FROM dbo.vwCompletions_List_Current_Month
WHERE (SalesTeamID = 1) AND (SalesCurrentlyEmployed = 1)
GROUP BY SalesUserName
) salesdata
|