I have been trying to work on this solution for some time and I just cant figure it out. I will try to explain it as bes as possible. I am doing a number of sql SELECTS and building a temporary table which is working well. In my final select the betwen the temporary table (TempTable) and another table (RSTTable) it is possible to get up to 3 records returned for one record in my temporary table. The RSTTable can return 3 records because of all the data fields other than one of the fields called Type which holds an R, S or T value. Depending on the value of the Type field and the combination of records available the selectedrecord is as follows:
if all three types of records exist (R, S, and T) select the S record
if an R and T record exist select the T record
if an S and T record exist then select the S record
if an R and S record exist then select the S record
if only 1 record exist with any Type select that one reocrd (which the query will only return one records)
So if only one record exist that is not a problem it is when multiple records are returned. This is done with the TempTable having 1,000's of records at a time.
I hope my explination makes sense.
Thanks in advance for all the help.