Pho3nix
The Legend
- Joined
- Jul 31, 2009
- Messages
- 30,589
Hi,
I have 2 SQL scripts. 1 works and the other does not.
Have to rewrite this as the server they are working on is SQL 2000
Any help would be appreciated.
Working :
Not working
I have 2 SQL scripts. 1 works and the other does not.
Have to rewrite this as the server they are working on is SQL 2000
Any help would be appreciated.
Working :
Code:
with cte_p as
(
SELECT EmployeeId,[PAL],[AAL],
FROM [dbo].[A1]
PIVOT( SUM(CurrentImpliedBalance)
FOR TypeCode IN ([PAL],[AAL])) AS P
)
select
EmployeeId,SUM([PAL]) AS PAL,SUM([AAL])
from cte_p where EmployeeId = 3039 group by EmployeeId
order by 1
Not working
Code:
Select EmployeeId
,SUM( Case When TypeCode = '[PAL]' Then ISNULL(CurrentImpliedBalance,0) End ) As [PAL]
,SUM( Case When TypeCode = '[AAL]' Then ISNULL(CurrentImpliedBalance,0) End ) As [AAL]
From [A1] As P
where EmployeeId = 3039
Group By EmployeeId
ORDER BY 1