D
Dan
I have built a query with a sub-query in it that I thought would calculate
the days between the dates on each record for a given Well# but I am not able
to make it work. Here is the query:
SELECT [Base Wells].[WELL#], [Base Wells].[WELL NAME], [All Daily Production
Data].[DATE-TIME], [All Daily Production Data].STATUS, [All Daily Production
Data].STCODE, [All Daily Production Data].[DATE-TIME]-(SELECT Max([All Daily
Production Data].[DATE-TIME]) FROM [All Daily Production Data] As Dup WHERE
[Base Wells].[Well#] = Dup.[Well#] AND Dup.[DATE-TIME] < [All Daily
Production Data].[DATE-TIME]) AS NumDays
FROM [Base Wells] LEFT JOIN [All Daily Production Data] ON [Base
Wells].[WELL#]=[All Daily Production Data].[WELL#]
WHERE ((([All Daily Production Data].STATUS)="P" Or ([All Daily Production
Data].STATUS)="N") AND (([Base Wells].CLASS)="W"))
ORDER BY [Base Wells].[WELL NAME], [All Daily Production Data].[DATE-TIME];
I also want the last record for a given Well# to show the number of days
between the last record date and the current date. I haven't dealt with that
challenge in this query yet.
When I run the query as it is, Numdays is returning 0. Apparently I am
subtractng the same date rather than the previous date.
Any ideas?
the days between the dates on each record for a given Well# but I am not able
to make it work. Here is the query:
SELECT [Base Wells].[WELL#], [Base Wells].[WELL NAME], [All Daily Production
Data].[DATE-TIME], [All Daily Production Data].STATUS, [All Daily Production
Data].STCODE, [All Daily Production Data].[DATE-TIME]-(SELECT Max([All Daily
Production Data].[DATE-TIME]) FROM [All Daily Production Data] As Dup WHERE
[Base Wells].[Well#] = Dup.[Well#] AND Dup.[DATE-TIME] < [All Daily
Production Data].[DATE-TIME]) AS NumDays
FROM [Base Wells] LEFT JOIN [All Daily Production Data] ON [Base
Wells].[WELL#]=[All Daily Production Data].[WELL#]
WHERE ((([All Daily Production Data].STATUS)="P" Or ([All Daily Production
Data].STATUS)="N") AND (([Base Wells].CLASS)="W"))
ORDER BY [Base Wells].[WELL NAME], [All Daily Production Data].[DATE-TIME];
I also want the last record for a given Well# to show the number of days
between the last record date and the current date. I haven't dealt with that
challenge in this query yet.
When I run the query as it is, Numdays is returning 0. Apparently I am
subtractng the same date rather than the previous date.
Any ideas?