I have the following fields in my database
* Entry Number (unique for every record)
* Company ID
* Pat ID
* Date Seen
* Run Date
All fields can be the same i.e. Company ID, Pat ID, Date Seen and Run Date may be the only one that varies.Entry number will be different every time.
I would like to be able to get hold on the min run date entry number. Due to problems in the database outwith my control I need to have the Entry Number of the min run date. So cant do min(run date), pat id and company etc.
I started off my creating a temp table and created a unique field (Auto number) and order this by run date. I then tried taking the min(unique field) and orginal entry number.
However because the entry number is always different. I am pulling out all run dates and not just the entry number with the min run date.I cant do min of the orginal entry number as I dont know this will correspond to the min run date.
For example I have the following 3 records in the d/b.
yyyymmdd
Entry Number Company ID Pat ID Date Seen Run Date
23 a 1 20050609 20050409
198 a 1 20050609 20050309
789 a 1 20050609 20050909
I would like my query to return entry number 198.
Thanks
* Entry Number (unique for every record)
* Company ID
* Pat ID
* Date Seen
* Run Date
All fields can be the same i.e. Company ID, Pat ID, Date Seen and Run Date may be the only one that varies.Entry number will be different every time.
I would like to be able to get hold on the min run date entry number. Due to problems in the database outwith my control I need to have the Entry Number of the min run date. So cant do min(run date), pat id and company etc.
I started off my creating a temp table and created a unique field (Auto number) and order this by run date. I then tried taking the min(unique field) and orginal entry number.
However because the entry number is always different. I am pulling out all run dates and not just the entry number with the min run date.I cant do min of the orginal entry number as I dont know this will correspond to the min run date.
For example I have the following 3 records in the d/b.
yyyymmdd
Entry Number Company ID Pat ID Date Seen Run Date
23 a 1 20050609 20050409
198 a 1 20050609 20050309
789 a 1 20050609 20050909
I would like my query to return entry number 198.
Thanks