Thursday, April 22, 2010

Monthly Count at Column Level

0 comments
Below is the easiest way to Calculate monthly leaves and late comings by an individual employee for the year 2010 at column level

Select  emp_id , Date_format(e.registration_date,'%m-%y')
, (Select count(leave_id) from emp leave el     
where e.emp_id=el.em_id
and Date_format(e.registration_date,'%m-%y')=Date_format(el.leave_date,'%m-%y')TotalLeaves

, (Select count(leave_id)
from emp_attendence ea
where e.emp_id=ea.emp_id
and Date_format(e.registration_date,'%m-%y')=Date_format(el.leave_date,'%m-%y')TotalLatecomings

from employee e
where e.registration_date between '2010-04-01 00:00:00' and '2010-12-31 23:59:59'

0 comments: