I can't wrap my head around this for some reason. I'm trying to get the ID from a table where multiple columns are distinct... basically something like -
Select ID from table where ID in (Select distinct ID, Card, PunchTime, PunchDate)
Though that obviously doesn't work. I want to get the IDs that are unique with all of those fields as the criteria. I can't seem to come up with syntax that works. I'm not sure what else I can say about it, it seems lke it should be simple when I look at it... but I've been bouncing off of it since yesterday and nothing is working. Anyone know which way I should be going? Thank you in advance!
edit: The posted things work but the results weren't what I expected. Here's some saple data:
ID Card PunchDate PunchTime In/Out
================================
1 00123 3/17/2012 13:00 1
2 00123 3/17/2012 17:00 2
3 00123 3/17/2012 17:00 1
4 00123 3/17/2012 20:00 2
5 00456 3/17/2012 14:00 1
6 00456 3/17/2012 17:00 2
The reason I'm trying to do this is that the timekeeping software decides that anything with a card, punchdate, and punchtime that is identical to another is a duplicate, regardless of whether it is an in or out punch and deletes one. My only solution is to eliminate the duplicates and basically make the punches from the first in punch to the last outpunch where they are duplicated. So my goal is to select only the unique values based on card, punchdate, and punchtime. However what I have is not excluding the ID in the matter which is making it a unique value. I have a workaround for this so time isn't particularly an issue, but I would much rather figure out how I can get the right data.
Thank you all again for the fast replies!