I think this sentiment is expressed quite nicely from the following scene in the Star Trek II: Wrath of Khan movie:
With the
Enterprise (ship) in imminent danger of destruction, Spock enters a highly radioactive chamber in order to fix the ship’s drive so the crew can escape danger. Spock quickly perishes, and, with his final breaths, says to Kirk, “Don’t grieve, Admiral. It is logical. The needs of the many outweigh . . .” Kirk finishes for him, “The needs of the few.” Spock replies, “Or the one.”