Len Boorman
Back in gainfull employme
- Local time
- Today, 08:57
- Joined
- Mar 23, 2000
- Messages
- 1,927
I have a query that does not do what I expect and I do not understand why.
The sql below seems straightforward to me
SELECT Max(qry_Dist_List_Select_1.Rev_Date) AS MaxOfRev_Date
FROM qry_Dist_List_Select_1;
Okay so it is querying a query but that is not unusual.
qry_Dist_List_Select_1 queries two tables that have a one to many link with referential entegrity enforced. Basically the first table is a list of documents and the second table a list of revisions and dates.
So what I want is to select the max rev date for a document so that I get the Max revision. Before you say use the actual revision number I should point out that in this case I need the latest active revision. An active revision has a date. It is possible in this database to assign a revision to a document and not assign a date. This is then a pending revision and being worked on.
So back to question.
I have the following date against a specific document
Rev Date
0 27/11/03
1 27/11/03
2 05/01/04
So why does query select max date as 27/11/03 ?
Now when I use
SELECT Last(qry_Dist_List_Select_1.Rev_Date) AS LastOfRev_Date
FROM qry_Dist_List_Select_1;
I get the correct selection regardless of the sequencing of the first query output.
All comments appreciated.
Len B
The sql below seems straightforward to me
SELECT Max(qry_Dist_List_Select_1.Rev_Date) AS MaxOfRev_Date
FROM qry_Dist_List_Select_1;
Okay so it is querying a query but that is not unusual.
qry_Dist_List_Select_1 queries two tables that have a one to many link with referential entegrity enforced. Basically the first table is a list of documents and the second table a list of revisions and dates.
So what I want is to select the max rev date for a document so that I get the Max revision. Before you say use the actual revision number I should point out that in this case I need the latest active revision. An active revision has a date. It is possible in this database to assign a revision to a document and not assign a date. This is then a pending revision and being worked on.
So back to question.
I have the following date against a specific document
Rev Date
0 27/11/03
1 27/11/03
2 05/01/04
So why does query select max date as 27/11/03 ?
Now when I use
SELECT Last(qry_Dist_List_Select_1.Rev_Date) AS LastOfRev_Date
FROM qry_Dist_List_Select_1;
I get the correct selection regardless of the sequencing of the first query output.
All comments appreciated.
Len B