If I K-O a drifblim who is the opponents last pokemon with aftermath with my last pokemon who has one hp
I think you would win because the opponent went to 0 HP first. The opposite would be true of Explosion.
That would be for friend/wi-fi battles, for battles in the actual game you will faint and lose the battle, as far as I know.
Aftermath causes foe to lost of 25% of Max HP, so you lose too (in that example)