I have a set of serial numbers of the type XXRX123456, where the 'X's indicate the model type, the 'R' is random, and the numbers are sequential. I've created a totals query that groups by LotNumber, then determines the Max and Min values based on the sequential numbers of each serial number and returns the full serial number of the Max and Min values. IE, if I had the following values for a lot number (which could well be written to the table in this order):
XXAX000001, XXEX000004, XXLX000003, XXBX000005, XXGX000002
I'd want it to return XXAX000001 for the Min and XXBX000005 for the Max.
The SQL I've put in place to do this seems inefficient, as I'm currently pulling the serial numbers apart, putting them back together in the form 123456XXRX, determining the Min and Max values, pulling those values back apart, and putting them back together as XXRX123456 again. Does anyone have any better suggestions that don't involve Dfunctions? I can't use Dfunctions at the moment, for reasons that are long and depressing.
In case it helps, I can create fields in the table to populate with pieces of each serial number, such as SerialNumeric = Right(SerialNumber,6) and/or SerialAlpha = Left(SerialNumber,4).