Wednesday, June 23, 2010

Date wise SQL Query

0 comments
Column Level SQL Query to extract data with date as condition

Select employee_id, employee_name
(Select count(*) from employee_leave el where e.employee_id=el.employee_id
and el.leave_date between e.hire_Date and '2010-06-20 23:59:59')
from tbl_employee e
where e.hire_date between '2010-06-01 00:00:00' and '2010-06-01 23:59:59'
here in the above query for extracting the total leaves the final date has been set from the employee hire date.