Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.
DECLARE @MaxComm decimal (3,2) SET @MaxComm = ( select max(CommissionPercentage) from tblCommissionTiers) SELECT DISTINCT empNum, gross as SALES ,targ.SalesTarget AS TARGET , lowPercentage,highPercentage, CommissionPercentage ,gross*lowPercentage AS LowAmount ,gross*highPercentage AS HighAmount ,(gross*highPercentage) - (gross*lowPercentage) VarHighVsLow ,CASE WHEN gross > targ.SalesTarget THEN ((gross*highPercentage) - (gross*lowPercentage)) * CommissionPercentage WHEN (gross - targ.SalesTarget) > 100.00 THEN (gross - targ.SalesTarget) * @MaxComm ELSE 0 END COMMISSION FROM tblRevenues rev INNER JOIN tblCommissionTiers com ON rev.commissionFlag = com.commissionFlag INNER JOIN [dbo].[tblTargets] Targ ON com.commissionFlag = targ.commissionFlag GROUP BY empNum, gross,targ.SalesTarget , lowPercentage ,highPercentage, CommissionPercentage
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.