tags:

views:

26

answers:

1

I Have a table in Access as below

SI Number        Time
1.14172E+20      13:30:35
1244066650       18:58:48
1244066650       19:03:12
1244066650       19:05:50
01724656007_dsl  22:15:20
01724656007_dsl  22:18:00
01724656007_dsl  22:24:28
1141530407       10:27:49
1141530407       10:29:13

And require output in the same table is

SI Number        Time      Diff
1.14172E+20      13:30:35 
1244066650       18:58:48 
1244066650       19:03:12  0:04:24
1244066650       19:05:50  0:02:38
01724656007_dsl  22:15:20 
01724656007_dsl  22:18:00  0:02:40
01724656007_dsl  22:24:28  0:06:28
1141530407       10:27:49 
1141530407       10:29:13  0:01:24

I require as if 1st record in SI Number column is equals to 2nd record than record 2 of time column -record 1 of time column in Diff column record 2 record 1 will remain blank

Urgent help required Vijay

A: 

Have a look at something like

SELECT  *, 
        DatePart("h",DiffVal)  & ":"& 
        DatePart("n",DiffVal) & ":" & 
        DatePart("s",DiffVal)  AS DiffVals 
FROM    (   
            SELECT  t1.*, 
                    [t1].[Time]-
                    (
                        SELECT  TOP 1 
                                Time 
                        FROM    Table1 
                        WHERE   Table1.SINumber = t1.SINumber 
                        AND     Table1.Time < t1.Time 
                        ORDER BY    Table1.Time DESC
                    ) AS DiffVal 
            FROM    Table1 AS t1
        )  AS Tables;
astander