Professional Documents
Culture Documents
employee_code,rpt_name,dept_name,birth_date,join_date,DateAdd(Month,6,Dateadd(YEAR,
25,join_date)) as nsif_year,
dbo.GetAge(join_date,'2017-09-30') from per_employee left join lkp_department on
per_employee.company_id=lkp_department.company_id and
per_employee.div_id=lkp_department.div_id
and per_employee.dept_id=lkp_department.dept_id where per_employee.company_id=1
and emp_status<>'S' and category_id=1 order by nsif_year
***************************************************************
SELECT Employee_code,Emp_Name,ISNULL(sum([1990]),0)
as[1990],ISNULL(sum([1991]),0)as [1991], ISNULL(sum([1992]),0) as
[1992],ISNULL(sum([1993]),0) as [1993],
ISNULL(sum([1994]),0) as [1994],ISNULL(sum([1995]),0) as
[1996],ISNULL(sum([1996]),0) as [1996] ,ISNULL(sum([1997]),0) as
[1997],ISNULL(sum([1998]),0) as [1998],
ISNULL(sum([1999]),0) as [1999],ISNULL(SUM([2000]),0) as
[2000],ISNULL(sum([2001]),0) as [2001],ISNULL(sum([2002]),0) as [2002],
ISNULL(sum([2003]),0) as [2003],ISNULL(sum([2004]),0) as
[2004],ISNULL(sum([2005]),0) as [2005],ISNULL(sum([2006]),0) as
[2006],ISNULL(sum([2007]),0) as [2007],
ISNULL(sum([2008]),0) as [2008],ISNULL(sum([2009]),0) as [2009]
FROM [dbo].nsif_det_temp
PIVOT
(
SUM(Year_Contribution)
FOR [nsif_year] IN ([1990],[1991], [1992],[1993], [1994],[1995],[1996],
[1997],[1998],[1999],[2000],[2001],[2002],[2003],[2004],[2005],[2006],[2007],
[2008],[2009])
) AS P group by Employee_code,Emp_Name
***********************************************************
FOR YEAR 2009 November and December
*****************************************************
select employee_id,sum(paycomp_employer1) from pay_calc_detail_history where
employee_id in(select employee_id from per_employee where
company_id=1 and emp_status<>'S' and category_id=1) and pay_comp_id=45 and
pay_year=2009 and pay_month in(11,12)
group by employee_id order by convert(int,employee_id)
**********************************************************
***********************************************************
FROM YEAR 2010 TO 2017
*******************************************************************
SELECT [employee_id],[2010], [2011],[2012], [2013],[2014],[2015],[2016],[2017]
from
(
select [employee_id],[pay_year],[paycomp_employer1]
***********************************************************************************
*******
PIVOT
(
SUM([paycomp_employer1])
FOR [pay_year] IN ([2010], [2011],[2012], [2013],[2014],[2015],[2016],
[2017])
) AS P group by [employee_code],[joinDate],[2009],[2010], [2011],[2012], [2013],
[2014],[2015],[2016],[2017]
order by convert(int,[employee_code])
****************************************************************************
--select * from EmployeeMaster
--select * from nsifmaster
With employeemaster as
(
Select
E.empid,
E.empname,
N.nsifyear,
N.nsifamount
From
Dbo.employeemaster E
Inner join dbo.nsifmaster N
On E.empid=N.empid
)
Select * from employeemaster
PIVOT
(max(nsifamount)
for nsifyear in ([2008],[2009],[2010])) p;
************************************************************************
SET RECORDS ZERO ABOVE 25YRS AND 6MONTHS -
**********************************************
WHILE @@FETCH_STATUS = 0
BEGIN
if @years=2001
begin
end
if @years=2002
begin
end
if @years=2003
begin
end
if @years=2004
begin
end
if @years=2005
begin
end
if @years=2006
begin
end
if @years=2007
begin
end
if @years=2008
begin
end
if @years=2009
begin
end
if @years=2010
begin
end
if @years=2011
begin
end
if @years=2012
begin
end
if @years=2013
begin
end
if @years=2014
begin
end
if @years=2015
begin
end
if @years=2016
begin
end
FETCH NEXT
FROM @Cursor INTO @EmployeeID
END
CLOSE @Cursor
DEALLOCATE @Cursor
***********************************************************************************
***************************
update NSIF RATE
***********************************************************************************
*
--select * from lkp_NSIF_Gratuity
--SELECT totalyears, totalmonths,MOnthsEntitled,* FROM nsif_test_data a order by
a.totalyears desc
WHILE @@FETCH_STATUS = 0
BEGIN
print '@NSIFRate'
print @NSIFRate
ELSE
BEGIN
UPDATE nsif_test_data SET MonthsEntitled=@NSIFRate where EmpID=@EmployeeID
END
FETCH NEXT
FROM @Cursor INTO @EmployeeID
END
CLOSE @Cursor
DEALLOCATE @Cursor
***************************************************************
********************************************************************************