D
Dave Ramage
Hello...
I am struggling with a query to do the following...
From a table tblData like this:
ID Vehicle Date Ref Cost
1 z1 06/04/2006 11 $22
2 z1 06/04/2006 24 $25
3 z1 06/04/2006 31 $13
4 z1 08/07/2006 9 $45
5 z1 08/07/2006 55 $78
6 x2 10/05/2006 57 $10
7 x2 10/05/2006 61 $33
8 x2 10/05/2006 89 $55
9 x2 10/05/2006 21 $10
10 c3 15/03/2006 15 $97
11 c3 15/03/2006 10 $22
12 c3 15/03/2006 99 $44
13 c3 01/05/2006 83 $7
14 c3 01/05/2006 72 $3
15 c3 01/05/2006 14 $8
...I want to group by Vehicle and Date, and return tblData.* for the record
with Max Cost within that grouping. Therefore, the query should return:
ID Vehicle Date Ref Cost
2 z1 06/04/2006 24 $25
5 z1 08/07/2006 55 $78
8 x2 10/05/2006 89 $55
10 c3 15/03/2006 15 $97
15 c3 01/05/2006 14 $8
Note that each record is a complete record from tblData. tblData is not in
any particular order.
I hope this is clear! Very grateful for any assistance...
Cheers,
Dave
I am struggling with a query to do the following...
From a table tblData like this:
ID Vehicle Date Ref Cost
1 z1 06/04/2006 11 $22
2 z1 06/04/2006 24 $25
3 z1 06/04/2006 31 $13
4 z1 08/07/2006 9 $45
5 z1 08/07/2006 55 $78
6 x2 10/05/2006 57 $10
7 x2 10/05/2006 61 $33
8 x2 10/05/2006 89 $55
9 x2 10/05/2006 21 $10
10 c3 15/03/2006 15 $97
11 c3 15/03/2006 10 $22
12 c3 15/03/2006 99 $44
13 c3 01/05/2006 83 $7
14 c3 01/05/2006 72 $3
15 c3 01/05/2006 14 $8
...I want to group by Vehicle and Date, and return tblData.* for the record
with Max Cost within that grouping. Therefore, the query should return:
ID Vehicle Date Ref Cost
2 z1 06/04/2006 24 $25
5 z1 08/07/2006 55 $78
8 x2 10/05/2006 89 $55
10 c3 15/03/2006 15 $97
15 c3 01/05/2006 14 $8
Note that each record is a complete record from tblData. tblData is not in
any particular order.
I hope this is clear! Very grateful for any assistance...
Cheers,
Dave