For subjects with mid-year, the ranking is taken from the entire year's SACs, and your SAC score will be the corresponding ranking average exam score for unit 3+4
The ranking only ranks you. It's based on the principle that similar ability students will perform similarly in exams. If you are narrowly in front, then your exam score wouldnt be hugely ahead of the cohort, (which consequently become a ranking exam score used for SACs etc)
but if you are hugely in front, the usual result is your exam score will be hugely in front, and in effect, you become a statistical anomaly and doesnt affect the cohort much (such as methods at my school last year, i got 45, next person got 24)
how far ahead in ranking should accurately reflect how well you do in exam, so just make sure you get a good ranking in SACs, and do awesome on the exam
hope that made sense