Code:
SELECT EmpID, amount, CASE isnull(StartDate, '') WHEN '' THEN CONVERT(varchar, cast('06/30/2010' AS datetime), 101) ELSE CONVERT(varchar, StartDate, 101) END AS StartDate, percentage, PayrollCompany, [41] AS Period1, [42] AS Period2 FROM (SELECT t .EmpID, amount, StartDate, percentage, PayrollCompany FROM ESPPPeople e, PeriodInformation p, tmpEmpcontribution t WHERE t .EmpID = e.empID AND t .Period *= p.PeriodID) AS p PIVOT(MAX(EmpID) FOR Period IN ([41], [42])) AS pvt ORDER BY pvt.EmpID, pvt.Period;
Comment