Re: Help with query on Audit Trail
- From: John Winterbottom <john.wb@xxxxxxxxx>
- Date: Thu, 26 Jul 2007 23:03:18 -0400
In Access 2000 you could do
select a.SR, sum(a.duration) as SumOfDuration
from
(
select m1.SR, datediff("d",m1.DateTime,
(
select min(m2.DateTime) from myTable as m2
where m2.SR = m1.SR
and m2.DateTime > m1.DateTime
)) as duration
from myTable as m1
where m1.NewValue = '2nd Line'
) as a
group by a.SR
krieshen@xxxxxxxxx wrote:
Hi,.
The entity I work with has a 'lifetime' as follows:
Visualized*:
Start:2-1-2007 16:49 End:6-3-2007 11:34
|--------------|--------------|------------|-------------|-----------|--------------|
Incomp In progr 2nd Clsd In progr 2nd Clsd
*note: when you see the data table, you'll understand this better
If I split these phases you get;
I am only interested int he 2nd line phases:
8-2-2007 14-2-2007
|-------------------|
2nd Line Closed |--------------------|
2nd Line Closed
I have the following table:
SR# DateTime OldValue NewValue
1-414 2-1-2007 16:49 Incomplete In Progress
1-414 3-1-2007 16:53 In Progress 2nd Line
1-414 8-2-2007 10:04 2nd Line Closed
1-414 14-2-2007 8:41 Closed In Progress
1-414 14-2-2007 16:35 In Progress 2nd Line
1-414 6-3-2007 11:34 2nd Line Closed
status.From this table I would like to query the duration of the 2nd Line
The way I have tried it is:
I have:
1. queried all records with NewValue 2nd Line renaming the DateTime
field to
DateTimeNew
2. queried all records with OldValue 2nd Line renaming the DateTime
field to
DateTimeOld
3. created a new query based on the queries of step 1 and 2. In this
query I
have linked the other two queries on SR# and taken the
DateDiff("d";[DateTimeOld];[DateTimeNew]) where there are 2nd Line
values.
The query is not adequate, it only works when there is only one value
of 2nd
Line in the column OldValue or NewValue, i.e. the concerning entity
was only
once in the 2nd Line and twice as represented in the table data
above.
I have split the DateTime field in Date and Time...
As you can see, the 1st and last record are actually incorrect.
The output of the query is:
SR# DaySpentTimeSpent DateNew DateOld TimeNew TimeOld
1-414 -6 6:31 14-2-2007 8-2-2007 16:35:00 10:04:00
1-414 20 5:01 14-2-2007 6-3-2007 16:35:00 11:34:00
1-414 36 6:49 3-1-2007 8-2-2007 16:53:00 10:04:00
1-414 62 5:19 3-1-2007 6-3-2007 16:53:00 11:34:00
Any help on this would be greatly appreciated.
Thanks,
K.
- Follow-Ups:
- Re: Help with query on Audit Trail
- From: krieshen
- Re: Help with query on Audit Trail
- References:
- Help with query on Audit Trail
- From: krieshen
- Help with query on Audit Trail
- Prev by Date: Re: Automation and Word 2007
- Next by Date: Re: Double-clicking a shared MDB doesn't open it
- Previous by thread: Help with query on Audit Trail
- Next by thread: Re: Help with query on Audit Trail
- Index(es):
Relevant Pages
|