MYSQL Calculate ranking of row that is not yet inserted
BEGIN;
INSERT the row
calculate the rank; put it into an app variable
ROLLBACK;


The ROLLBACK lets you undo the INSERT.  But meanwhile, you have grabbed the rank.