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

  • SEARCH
  • Home
  • 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 8856371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:20:32+00:00 2026-06-14T14:20:32+00:00

We have a SQL 2008 table that holds the attendance data in the following

  • 0

We have a SQL 2008 table that holds the attendance data in the following sequence.

 uid   clock                          collectdate                  type

 1    2012-10-30 16:13:07.000          2012-10-30 19:29:58.000     in
 1    2012-10-30 21:18:50.000          2012-10-30 22:29:58.000     in
 2    2012-10-30 16:13:07.000          2012-10-30 19:29:58.000     in
 2    2012-10-30 21:18:50.000          2012-10-30 22:29:58.000     in

The proper sequence will be to have the “Type” column as, in and out. But this is exactly the problem I am facing as the system is being use to manage contractors and part timers who always miss pressing the correct button or not at all on the timeclock before making an in or out punch.

We currently depend on this stored procedure to put the timeclock data in the proper order

    INSERT INTO attendanceTBL (UID,CollectDate,Clockin,Clockout)

SELECT 
UID
,CollectDate
,MAX(case when type  = 'in' then clock end) clockin
,MAX(case when type  = 'Out' then clock end) clockout
From RAWCLOCKTBL
GROUP BY UID,CollectDate 
RETURN 

Is there any way I can move the “clock” value to the same row in the correct sequence while ignoring the “type” column. ie, move the above table to.

uid    clock                          clock            
1      2012-10-30 16:13:07.000        2012-10-30 21:18:50.000
2      2012-10-30 16:13:07.000        2012-10-30 21:18:50.000
  • 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-14T14:20:33+00:00Added an answer on June 14, 2026 at 2:20 pm

    The following query groups the IN and OUT times of a UID for each date and JOINs on the UID and DATE to get the desired output. The LEFT JOIN will ensure to return those entries without an OUT yet (if that is needed).

    SELECT 
        A.UID, 
        CONVERT(DATE, clock) 'ClockDate', 
        min(clock) 'ClockIn', 
        max(clock) 'ClockOut'
    FROM 
        attendanceTBL 
    GROUP BY uid, CONVERT(DATE, clock)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that contains a GEOMETRY data type. SQL Server 2008 ships
I have data in a SQL Server 2008 table that looks like this: I
I have an sql server 2008 db table that holds links to articles. My
I have a table in SQL Server 2008 R2 that holds positions for different
I have simple SQL Server 2008 table that has a column ourdate of type
I have an SQL Server 2008 database with a table that has a column
I use SQL Server 2008 R2 and have a table that I want no
I'm using SQL Server 2008 and I have a table that has a 'Status'
I have a table which contains my ads that can be searched in sql-server-2008.
I have a Microsoft SQL Server 2008 query that returns data from three tables

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.