Sanu

Sanu

  • NA
  • 33
  • 49.4k

Stored Procedure for calculating total no of leaves

Mar 12 2013 12:34 PM

I have 2 tables 'Employee' and 'Leaves'.

Employee Table having fields - Empid, Empname, Designation, Department

and

Leave Table having fields - Empid, LeaveId, Fromdate, Todate, NoOfDays, Reason, LeaveStatus

I want a procedure which will use cursor to loop through employee ids taken from employee table and then calculate the total number of leaves for all 12 months of a given year.

The output should be in a table format having columns

empid, empname, department, year, month1, month2, month3, month4, month5 ..... month12

Sample of leave table below


Answers (1)