Fishing Database that stores All-time records. However, when someone has a joint record, I want to revert to the first capture as the true record.
select *
from T
inner join (select Type,
Name,
max(TotDrams) as maxdrams
from T
WHERE Type='Common Bream'
group by Type, Name
) sq on T.Type = sq.Type
and T.Name = sq.Name
and sq.maxdrams = T.TotDrams
ORDER BY Ranking ASC
The above returns the all time records with the best capture for each name, but when a record is joint it naturally returns the additional record. I only want the earliest date record to be included in the all time records.
Is there a way of adapting the above code to remove the additional joint records and only pick the earliest recorded?
Fishname Rank Weight Angler Date
Slimey Rank 1 2 lb 3 oz John Budd 30/11/2013
Fishy Rank 2 1 lb 15 oz Chris Clot 12/01/2009
Scales Rank 3 1 lb 12 oz John Budd 21/03/2014
Scales Rank 3 1 lb 12 oz Harry White 01/04/2002
With the above example - which is what is currently happening, I would like to have John Budd's joint record removed as it is joint and is not the original.
One other note:- This SQL will be used with php.