Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:43:20+00:00 2026-06-01T08:43:20+00:00

I can’t wrap my head around this for some reason. I’m trying to get

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:43:21+00:00Added an answer on June 1, 2026 at 8:43 am

    UPDATED ANSWER WITH NEW INFORMATION:

    SELECT *
    FROM TABLE
    WHERE NOT EXISTS
    (
        SELECT 1 
        FROM TABLE AS Duplicates
        WHERE Duplicates.Card = TABLE.Card
            AND Duplicates.PunchDate = TABLE.PunchDate
            AND Duplicates.PunchTime = TABLE.PunchTime
            AND Duplicates.ID != TABLE.ID
    )
    

    Basically, this is saying, get all of the records that do not have the same card, punchdate, punchtime (making sure to not count the same row against itself.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can MOSS integrate and get user profiles from multiple Active Directory and/or LDAP stores?
Can anyone tell me what i am doing wrong? I am trying to get
Can anyone help me trying to find out why this doesn't work. The brushes
Does anyone know how can I replace this 2 symbol below from the string
Can somebody tell me how to get mod_rewrite to rename this: our-work-section.php?id=3&title=something to our-work-section/something/3
can you recommend some good ASP.NET tutorials or a good book? Should I jump
Can I get a 'when to use' for these and others? <% %> <%#
Can you suggest some good MVC framework for perl -- one I am aware
Can anybody shed some light on getDay() in Javascript please. Here datepicker is textbox
Can I run this in a Windows command prompt like I can run it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.