My very basic understanding of the physics of air resistance is that it increases at the square of speed, so a plane that's going at 500 miles/hour must use massively more energy than a trane traveling at 100 miles/hour.
The air is thinner at cruising altitude, though of course thicker at takeoff altitude. I'm sure longer flights are much more efficient than shorter, but whether they ever overtake trains I'm not sure.
Fun fact once flights go above a certain length they get less efficient because all that fuel they are carrying actually requires more fuel to move, which in turn needs to be carried. I don't think it's the energy efficiency that's the issue here. Even if trains are less energy efficient, they can much more easily be powered off renewable sources.