asked on
ASKER
ALTER PROCEDURE [dbo].[TiersEmployee]
@site varchar(4),
@EffectiveDate varchar(25),
@employeeid INT,
@CommissionLevelID INT
AS
BEGIN
SELECT CommissionLevelID, [EffectiveDate], [LevelName], active, [siteid], [sitename], fname, lname, EmployeeID, [4] as [Count4], [5] as [Count5], [6] as [Count6], [7] as [Count7], [8] as [Count8], [9] as [Count9], [10] as [Count10]
FROM
(SELECT [LevelName], active, s.[siteid], s.[sitename], e.fname, e.lname, cla.EmployeeID, cla.CommissionLevelID, cld.AttendantCount, cld.Rate, cld.EffectiveDate
FROM [CommissionLevelAssignment] cla
INNER JOIN [CommissionLevelDetail] cld
ON cla.CommissionLevelID = cld.CommissionLevelID
INNER JOIN [CommissionLevel] cl
ON cld.[CommissionLevelID] = cl.[CommissionLevelID]
RIGHT OUTER JOIN [dbo].EMPLOYEES e
ON cla.EmployeeID = e.employeeid
INNER JOIN [SITES] s
ON s.[siteid] = cl.[siteid]
) p
PIVOT
(
MAX(Rate)
FOR AttendantCount IN
( [4], [5], [6], [7], [8], [9], [10])
) AS pvt
WHERE
CommissionLevelID IS NOT NULL
and siteid = @site
and EffectiveDate >= @EffectiveDate
and employeeid IN (@employeeid)
and CommissionLevelID IN (@CommissionLevelID)
ORDER BY [LevelName], [employeeid]
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.
TRUSTED BY
Open in new window
and notOpen in new window