A
Aino
I am struggling with a query, and need help
I have (from a previous saved query) these fields:
Field1, Field2, Field3, Time, Info
What I want to return is the maximum and minimum time along with the
corresponding infos, grouped by the first 3 fields:
Field1, Field2, Field3, Min(Time), Max(Time), InfoForMinTime,
InforForMaxTime
Sofar I have
SELECT T1.Field1, T1.Field2, T1.Field3, T1.Info, Min, Max
FROM [Query] AS T1 INNER JOIN
(SELECT Field1, Field2, Field3, Max(Time) AS Max, Min(Time) AS Min
FROM [Query]
GROUP BY Field1, Field2, Field3) as T2
ON T1.Field1= T2.Field1 AND T1.Field2=T2.Field2 AND
T1.Field3=T2.Field3 AND (T1.Time = T2.Max OR T1.Time=T2.Min)
ORDER BY Field1, Field2, Field3;
Obviously, I only get one Info field from this, and twice as many
records as I want, identical 2 and 2 apart from the Info field.
I have (from a previous saved query) these fields:
Field1, Field2, Field3, Time, Info
What I want to return is the maximum and minimum time along with the
corresponding infos, grouped by the first 3 fields:
Field1, Field2, Field3, Min(Time), Max(Time), InfoForMinTime,
InforForMaxTime
Sofar I have
SELECT T1.Field1, T1.Field2, T1.Field3, T1.Info, Min, Max
FROM [Query] AS T1 INNER JOIN
(SELECT Field1, Field2, Field3, Max(Time) AS Max, Min(Time) AS Min
FROM [Query]
GROUP BY Field1, Field2, Field3) as T2
ON T1.Field1= T2.Field1 AND T1.Field2=T2.Field2 AND
T1.Field3=T2.Field3 AND (T1.Time = T2.Max OR T1.Time=T2.Min)
ORDER BY Field1, Field2, Field3;
Obviously, I only get one Info field from this, and twice as many
records as I want, identical 2 and 2 apart from the Info field.