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 453017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:07:48+00:00 2026-05-12T22:07:48+00:00

Using MS Access 2007 Table1 ID Date Time 001, 20091111, 141625 001, 20091112, 122345

  • 0

Using MS Access 2007

Table1

ID Date Time

001, 20091111, 141625
001, 20091112, 122345
001, 20091112, 180000
001, 20091113, 100000
001, 20091113, 120000
001, 20091113, 180000
001, 20091113, 160000
...,

From the above table i want to add one more column as a status. Status Should be In or Out.
which Means
For 20091111 – Only one time, So It should be 141625 – In
For 20091112 – 2 times, So It should be 122345 – In, 180000 – Out
For 20091113 – 4 times, So 10000 – In, 120000- Out, 180000 – Out, 160000 – In

Which means

Date with one time means, the time should be In, 
Date with two times means, the First time should be In, Second time should be out
Date with three times means, the first time should be In, Second time should be out,
third time should be In.
Date with four times means, the first time should be In, Second time should be out,
third time should be In, Fourth time should be out.

For Example

Date Time 

20091010 100000
20091010 180000
20091010 120000

It should order the date by ascending, then it will display First one In, Second One is Out, Third One is In.

Output.

Date Time Status

20091010 100000 In
20091010 180000 In
20091010 120000 Out

Expected Output

ID Date Time status

001, 20091111, 141625 In
001, 20091112, 122345 In
001, 20091112, 180000 Out
001, 20091113, 100000 In
001, 20091113, 120000 Out
001, 20091113, 180000 Out
001, 20091113, 160000 In
...,

How to make a access query for this condition?

Need Query Help

  • 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-05-12T22:07:49+00:00Added an answer on May 12, 2026 at 10:07 pm

    0) Set status to Null for all records

    update table1 set status=Null;
    

    1) assign ‘In’ to the first record for each date:

    update Table1 as tab_outer set status='In' where Time=
     (select min(Time) from Table1 as tab_inner 
     where tab_inner.date=tab_outer.date);
    

    2) assign ‘Out’ to the first record for each date that has no status:

    update Table1 as tab_outer set status='Out' where Time=
     (select min(Time) from Table1 as tab_inner 
     where tab_inner.date=tab_outer.date and Time is null);
    

    3) assign ‘In’ to the first record for each date that has no status:

    update Table1 as tab_outer set status='In' where Time=
     (select min(Time) from Table1 as tab_inner 
     where tab_inner.date=tab_outer.date and Time is null);
    

    4) assign ‘Out’ to the first record for each date that has no status:

    update Table1 as tab_outer set status='Out' where Time=
     (select min(Time) from Table1 as tab_inner 
     where tab_inner.date=tab_outer.date and Time is null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Access 2003 Table1 ID Name Value 001 Raja 100 002 Ramu 200 004
Using Access 2003 Date Column datatype is text Table1 Date 20090528 20090529 20090530 20090502
I'm using an access 2007 database to track and report down time and reliability
This is my first time building a UI in Access (using Access 2007), and
I have the following problem in a Database using Access 2007 as front end
I've posted a demo Access db at http://www.derekbeck.com/Database0.accdb . I'm using Access 2007. I
So I wrote a project-management program for a small business using Microsoft Access 2007.
Background info : I was handed a Tool, which was made using MS-Access 2007,
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
Using Access 2003 Database Table1 Intime Outtime WorkTime OverTime 08:00:00 19:00:00 09:00:00 02:00:00 09:00:00

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.