newphpcoder Posted May 15, 2013 Share Posted May 15, 2013 Hi Good day!I have 2 tables for my dtr database.first the employees where all the data of employee was save.employees fields:EmployeeIDLastnameFirstnameSubDepartmentattendance_logEMP_IDLOG_TIME (datetime)INDICATORI tried lots of query to get the EmployeeID where no attendance on the date I want to check who are the absentee.I just want to select the EmployeeId where no LOG_TIME with the date 2013-05-02attendance_log table is the table where the time in and out was save.I hope somebody can help me to get only the EmployeeId with no attendance where Sub = 'REG' and Department IN ('QA', 'Engineering', 'Assembly').Thank you Link to comment Share on other sites More sharing options...
niche Posted May 15, 2013 Share Posted May 15, 2013 Please post your code and the errors if any. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 16, 2013 Share Posted May 16, 2013 You can use NOT IN with a subquery, e.g.: SELECT * FROM employees WHERE employeeID NOT IN (SELECT EMP_ID FROM attendance_log WHERE ...) That will return employees that are not in the other query, so you can add your date condition to the subquery to look for employees without attendance logs during a particular time. You can add additional conditions to the where clause to further filter the list of employees. Link to comment Share on other sites More sharing options...
jaseervp@ymail.com Posted May 30, 2013 Share Posted May 30, 2013 select * from employees whereSub = 'REG' and Department IN ('QA', 'Engineering', 'Assembly')and EmployeeID not in (select EMP_ID from attendance_log where trunc(LOG_TIME)='02-05-2013') Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now