更新时间:2023-11-18 21:55:10
请尝试这个
与employeeCTE AS
(选择Employeeid,processmonth,
案例推导代码
当"D [13]"则以LoanAdvance的金额结束时,
案例推导码
当"D [14]"则作为强制PF结束时的金额
来自员工)
选择Employeeid,processmonth,MAX(LoanAdvance)AS,LoanAdvance,MAX(MandatoryPF)AS,MandatoryPF
来自employeeCTE
GROUP BY Employeeid,processmonth
让我知道结果.. !!!
Please try this
WITH employeeCTE AS
(SELECT Employeeid,processmonth,
CASE deductioncode
WHEN ''D[13]'' THEN Amount END AS LoanAdvance ,
CASE deductioncode
WHEN ''D[14]'' THEN Amount END AS MandatoryPF
FROM Employee)
SELECT Employeeid,processmonth,MAX(LoanAdvance) AS LoanAdvance,MAX(MandatoryPF)AS MandatoryPF
FROM employeeCTE
GROUP BY Employeeid,processmonth
Let me know the result..!!!
尝试一下
Try This
select a.Employeeid a.processmonth a.Amount "LoanAdvance" a.Amount "MandatoryPF"
from Employee a, Employee b
where
a.Employeeid=b.Employeeid
and
a.deductioncode = 'D[13]'
and
b.deductioncode = 'D[14]'
并告诉我们您得到了什么.
And tell us what u r getting.
SELECT * FROM Employee
pivot(avg(Amount) for deductioncode in([LoanAdvance],[MandatoryPF]))as aaaa
试试这个对我来说很好.
给我答复
祝你好运
Try this it works fine for me.
give me reply
Best Luck