If you time your travels right, it often makes more sense to compare prices of sleeper trains to the price of a flight + one night at a hotel instead of the flight alone. Also trains often get you to city centres while most low cost airlines will take you to an off-center airport which is also worth something.
Just like with flights, you have to book early enough and check different times, and then additionally get the discount cards, and then you're looking at comparable prices quite often.