September 29, 2008 at 10:50 am
I have a employee attendance table with columns Empid, AttendanceDate, Hoursclocked.
Now I want to list all the employees who were not marked their hours between the given two dates. For example I will input 01-09-2008 and 30-09-2008, I should able to get the list employee records that is not present in this employee attendance table.
Thanks is Advance
Sathish
S A T ...
Sathish's Blog
September 29, 2008 at 12:46 pm
You would obtain better help if you followed the procedures recommended in the article in my signature block.
Now assuming that the attendance table includes
A row for each employee, for each working day the AttendanceDate is entered as a date with the time portion defaulted ("1/9/2008 12:00:00 AM") and that the hoursclocked column in your table allows NULL then the following would be adequate
SELECT empid, hours FROM Attendance WHERE AttendanceDate BETWEEN '09-01-2008' AND '09-30-2008' AND Hoursclocked IS NULL
September 30, 2008 at 8:25 am
If you just want employees that have no hours logged in the time frame then bitbuckets solution will work, but if you want a list of dates when an employee logged no hours then you would need a different solution that would work best if you have a dates table. For example employee A only logged hours on 17-09-2008 so you would get all the other dates for employee A.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply