Q:

How to Calculating the time? 

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

A:

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);

