Sailor Moon, mainly in the manga. Usagi and Mamoru get to get married and have a child and rule the world together in bliss, aside from the occasional alien attack. The other Senshi get to spend their lives in servitude to them and cannot have relationships of their own. And that's not even mentioning the millions of people who will die before civilization is rebuilt as Crystal Tokyo. Though the senshi choose to live lives of chastity, protecting the queen and king of Crystal Tokyo, and they all seem happy with their decision.
Inverted in Code Geass, where Lelouch dies and Suzaku fakes his death and forever takes on the identity of Zero, while the surviving main characters move on with their lives and attend Ohgi and Villetta's wedding.
Fushigi Yuugi. Yeah, Miaka and Tamahome get their happy ending... Too bad the other Guardians of Suzaku are either trapped in a book or dead (and Miaka, at one point of the story, actually had the power to bring every one of them back to life and/or in the real world. But she resurrected only the guy she loves). Ultimately subverted in Eiko Den with the Suzaku warriors being reincarnated into the modern world.
In Wolf's Rain, the only characters shown in the Bittersweet Ending are the wolves and Cheza. The implication is that human characters do not get to be reincarnated in the future.
The Elfen Lied anime ends with the director of the facility laughing hysterically and the fate of the other diclonius isn't made clear. However, Kouta, Yuka, Mayu and Nana all survive to the end and there is a chance that Lucy may have survived also.
Depending on your perspective, it's either inverted, averted or played straight in Bokurano. The pilots' home universe survives, but all of them die, except for Kana and Seki in the anime. It's also discussed when Kirie talks with Tanaka about how it bothers him that people can consider a movie as having a happy ending if many unnamed characters suffer but the hero gets a happy ending, and he seems to consider such stories as having Esoteric Happy Endings unless the hero acknowledges the suffering of others.
More or less inverted in Tengen Toppa Gurren Lagann. While humanity progresses and moves forward, the protagonists take big hits. The supporting section of the group survives, but must deal with the deaths of the gunman pilots (especially the Black sisters with Kittan's death and Leyte and her children with Makken. They do rescue Nia, only for her to die a week later, after her marriage with Simon. Simon ends up Walking the Earth with Boota and Yoko returns to her isolated life as a teacher and later principal. Considering the overall messages, this is pretty jarring.
The movies aren't as bad. While Kittan still dies, the other pilots still live. Nia's death still occurs and Simon's and Yoko's fates are still the same, if not played out mildly more optimistically.
In some Chick Tracts, the main Christian will talk to one non-believer, who gets more focus than the rest of the cast and goes to heaven in the end, while the other non-Christians are implied to go to Hell. One example is "The Trial"; the twist is that the plaintiff's daughter accepted Jesus when her friend, the defendant, told her, and the girl's mother and the witnesses called in to testify (authorities from other religions) go to Hell. Then again, it's just as common to invert this, as in "Busted" the main prosecutor goes to hell while his secretary gets converted (however, we don't hear whether the suspect at the beginning was convicted, much less whether he deserved the outcome).
Mutopia X has a happy ending for Ortega and Armena. Thanks to the ending of House of M, Armena is no longer a mutant, does not project a forcefield around her when she sleeps, and the happily married couple can finally share a bed and sleep together. Oh, that's so sweet... if we forget about the death of their daughter and the mass depowering of the mutants in Mutant Town that we had seen in the previous pages.
Saturday Night Fever: Tony heads to the big city to dance on Broadway! He gets the girl! Well... the girl who wasn't treated like dirt, raped, and then forgotten about, that is. And let's just forget Tony's friend Bobby C, who falls off the Verrazanno-Narrows Bridge during an act of depressed recklessness.
The 1998 movie version of Les Miserables ended the story before Jean Valjean dies, making it a happy ending as long as you're Jean Valjean, Marius, or Cosette and not any of the rest of the revolutionaries, who all died on the barricades.
The Ring: Rachel and Aiden make a copy of the cursed videotape, thus passing on the evil. Someone else will certainly watch the video and die, but it's OK because the main characters are safe! Then again, it's a horror movie. The only way to survive is to doom other people, and the only way to get out of the movie alive is to harden yourself to that. (Note that in the original, the person being set up to die is the lead's father.)
The end of Birth of a Nation, with the main characters happily married and the Klan firmly in control of the South, is kind of like that. Or maybe that's just Values Dissonance.
Invoked and ultimately subverted in Saving Private Ryan; the members of the squad who are Saving Private Ryan discuss and express discontent over the fact that their lives are being risked to save the life of one man who, from their frame of reference, is no more important than they. Subverted in that, while James Ryan is saved at the expense of nearly every man in the squad, he is left with a mere bittersweet ending as a result of this, being stuck with survivor's guilt for the rest of his life due to his saviors' deaths.
In Hellboy II: The Golden Army the movie ends with Liz and Hellboy planning on their future together with their children. Abe Sapien, on the other hand, gets to mourn the death of his lost love, Princess Nuala, who killed herself to stop her brother from destroying the human world, and Hellboy is still destined to destroy the world.
Avatar: Jake Sully and his alien catgirlfriend Neytiri get to live happily ever after. The last two humans on the planet (both friends of Jake's, remember) are likely going to starve or suffocate soon, and there's the fact that thousands of Na'vi are now dead (including Neytiri's father and former boyfriend), but at least the love-birds are together, right?
Not to mention what will happen in a few years when the RDA returns, this time with modern weapons and a real army...
Signs: Millions or billions of people have been killed or enslaved by the alien invasion, but God smiled on this one family and saved them so yay!
In Memoirs of a Geisha, Chiyo manages to unite with her beloved Chairman. Pumpkin is never heard from again, Mameha lives alone and without her beloved Baron, and General Nobu just stays away because "he can't forgive [Chiyo/Sayuri]".
Red Riding Hood: The village continues to live in fear even though the Wolf never returned. Valerie's mother has no one left, except Valerie who now lives in her dead grandmother's house and it's unknown if they see each other. Peter, after being bitten by the Wolf on a Blood Moon and thus becoming one every full moon returns to Valerie at the end of the movie after running away for some time to learn to control his werewolf power and the end credits show them being happy together.
2012: The main characters and several thousand others survive - the entire rest of the world (except, it's revealed, Africa) drowned.
Knowing actually one-ups the above. Aliens save two children (not the leads, but significant characters) and transport them to another planet before a solar flare wipes out every living creature on Earth.
In the Film of the Book of War Horse, only Joey and Albert (and his family as well) get a happy ending. The other characters die or are left with nothing to live for (Like Emilie's grandfather)
At the end of 12 Years a Slave, Solomon is freed and reunited with his family in New York, but the other slaves employed by Edwin Epps are no better off than before. In fact, more than one historian has wondered what became of Patsy after the events of the movie but couldn't find any solid answers.
Subverted and Lampshaded in Red Dragon. A family called the Leads is murdered, and Will definitely doesn't get a happy ending.
Alexander McCall Smith's book The Careful Use of Compliments ends with the independently wealthy Isabel using her money to buy the journal she edits, firing the editorial board, and replacing it with her friends, all so she won't lose her editing job. Good for her, but sucky for the editorial board, the guy who was going to be the new editor, and all the journal's readers, since the journal will undoubtedly suffer a precipitous decline in quality.
Juliet Marillier's Daughter of the Forest. The sorceress is defeated. Sorcha and Red finally get together, are completely content with their lives and get a Babies Ever After ending, but Simon is left out in the cold, Margary is left alone with a baby, Liam's one true love is dead, Colum has lost his self-confidence and Finbar is stuck with a swan's wing. Quite a Downer Ending for most of the cast.
In Shadowleague All the main characters are pictured as looking at a bright future that they'll build together with everyone they met during the story, so everything must be going good... unless you're one of the many who died of the invading vampire-creatures, the plague or various other causes throughout the upheaval up until the main characters fix most of it.
Maggie Furey seems to have a thing for pulling this off quite well, at the end of her Artefacts of Power series, if you're not a friend of Aurian, you're looking at a bleak life... and even then, two of her friends are stuck ruling a province for someone they don't like ruling under, too many people simply die, the Nightrunners don't really have a home anymore, (and if Faerie rule has a bad effect on trade they might not have of a living either), and the three Xandim protagonists are outcasts of the to-be-brought-back-in-chains variant. Let's just say it's reasonable that Aurian wants to take some time off with her child, lover, and a couple ofbig black cats.
In Breaking Dawn, the main characters all get happy endings. Meanwhile, every other secondary character goes back to a nomadic life, presumably on the Volturi's target list.
Discussed in Witches Abroad, where a voodoo priestess fights a fairy godmother who's manipulating the Theory of Narrative Causality for her own ends; the priestess thinks to herself at one point that she's fighting for all the exploited and down-trodden everyday people who "never got a happy ending" because they're just extras and side characters.
Avi's 1990 Newbery Medal-winning children's novel The True Confessions of Charlotte Doyle has a very happy ending for the main character, Charlotte Doyle. The villain Captain Jaggery frames her for murder and tries to get her executed but drowns before he can, and Charlotte runs away from her sexist 1832 life to work on the ship. What a happy ending. But not for the man Jaggery murdered, who was shown to be a very kind, good man who was killed so painfully Charlotte heard him screaming from high above in the rigging. And not for Mr. Cranick who was beaten by Capt. Jaggery to the point that his arm had to be amputated for not tying a rope properly, and then rose the crew up in mutiny only to be promptly murdered by Capt. Jaggery. But those don't matter, because everything goes perfectly for Charlotte and Zachariah!
The Hunger Games: Katniss and Peeta get a happy ending, nearly everyone else gets killed.
The sequels provide a rare inversion of this trope - the Capitol is defeated and is not replaced with an equally tyrannical President Coin. Lots of named characters die, but society now has a chance at a better life. As for Katniss and Peeta, they spend decades nurturing whatever shards of sanity they managed to keep.
At the end of the second season première of It's Always Sunny in Philadelphia, Frank very conspicuously says "The important thing is that nobody important got seriously hurt'' after the gang got in a car accident. The camera then pans over to an unnamed character who was with the group at the time lying in a full body cast in a hospital bed calling them jerks.
Doctor Who, in Horror of Fang Rock. The Doctor and Leela have killed the alien Rutan that was threatening a lighthouse and destroyed its mother ship. They leave safely in the TARDIS, but the Rutan managed to all the other characters first.
The play Life Is A Dream by Pedro Calderon de la Barca ends with the main couple having a beautiful wedding! Never mind the pointless war the protagonist and his father were having.
Henry V ends with the wedding of the eponymous King and Princess Katherine of France after Henry fights a bloody war of conquest against his soon-to-be father-in-law. However, Shakespeare lampshades the trope by pointing out in the epilogue that Henry's conquests will be short-lived and his premature death will lead to a bloody civil war.
In A Midsummer Night's Dream, Demetrius is given the love-in-idleness, thus forcing him to fall in love with Helena. While this is definitely good for Helena, it's not really a happy ending for Demetrius, given that he doesn't have a choice in the matter. He doesn't even seem to be aware that anything's out of the ordinary, making this a subversion.note This, however, depends on your interpretation of the whole love spell thing. A common interpretation now is to see it as incredibly squicky mind control quasi-rape, but a number of older works seem to view magically induced love as being just as valid as naturally occurring love. This is particularly prominent once you get back to Classical Mythology, where all love is the result of the gods going, "Okay, you hook up with that person, and you hook up with that person, and ... oh, how about we give that guy a donkey fetish?"
Some interpretations of Twelfth Night play the ending this way. Viola and Sebastian are reunited and happily married to the Duke Orsino and the Countess Olivia, respectively. However, Olivia's whole marriage is based on the fact that she actually fell in love with her husband's twin sister, Sir Andrew leaves Illyria in disgrace and heartbreak, Anthony the pirate has lost the young man he loved and been arrested while trying to help him, Toby Belch and Maria are trapped in a loveless marriage, and Malvolio has sworn revenge on the whole cast. Feste's sad song "For the rain it raineth every day" doesn't help.
Fable II. The Needs of the Few ending resurrects your dog, sister, spouse (if you married), and children (if you had any). The countless hundreds of people who perished over the twenty years of the Spire's creation? Still goners.
Taken Up to Eleven with the Needs Of the One ending, where you get a mountain of gold, but everyone who died stays dead.
The ending of Fire Emblem: Mystery of the Emblem is bad for practically everyone except Marth, Caeda, and a few others.
In The Secret of Monkey Island, if you sink your ship with the catapultic rock thing, Herman Toothrot will take you back to Melee island instead of your crew, and in the ending you'll get a nice sequence about how they're trapped in the cannibal hut. Escape from Monkey Island also treats this as canon and plays the trauma for laughs.
Inverted in Dragon Age: Origins for a female Warden who was in a relationship with Alistair and didn't harden him, or for a male Warden who was in a relationship with Morrigan. Everyone but the leads (in your party anyway) gets a happy ending.
A male Warden who romanced Morrigan has the opportunity to disappear with her into the Eluvian in the DLC Witch Hunt, and a female Human Noble who romanced and didn't harden Alistair can marry him at the Landsmeet and accept Morrigan's ritual, meaning they do get a happy ending... fornow.
Appears in Dragon Age II in the Templar ending, where Kirkwall has been devastated, Thedas is rapidly approaching its first world war, and the entire band of heroes has been split up...except for Hawke and his/her Love Interest. If you side with the mages you end up fleeing your home. Again.
The best ending of Valkyrie Profile: Covenant of the Plume has Wylfred finally find peace, his mother regain her sanity, and Tilte learning about Ancel's death and being able to grieve him properly instead of just sensing that something's plain wrong. The rest of the cast, however, don't get featured at all in the ending and most of the characters that don't you meet but don't recruit get rather depressing ends. It doesn't help that the two other endings are Downer Endings.
Downplayed in Knights of the Old Republic II: The Sith Lords. The Exile's team goes off to found the new Jedi Order, fix the damaged Republic, and shut down the HK-50's while she is condemned to flying off to die at the hands of the True Sith. It's implied in The Old Republic MMO that she did manage to do enough to set back the invasion for almost 300 years, but she still misses out on the oppurtunity to see all of her actions come to fruition or pursue a relationship with Atton or the Disciple.
Split fifty-fifty for the main characters in Final Fantasy XIII: Lightning and Snow get Serah back (though the sequel takes Lighting away from Serah immediately thereafter), Sazh has his son back, but Hope's mother is dead and Fang and Vanille are turned into crystals for all eternity.
Also split fifty-fifty for the rest of humanity (or rather, the handful survivors). They lost their homes and are forced to live under the harsh conditions of Gran Pulse and are no longer protected by the Fal'cie. Then again the Fal'cie were trying to kill all of them. The main characters' final act plan was to stop the Fal'cie and, failing at that, to mitigate the damage.
Xenogears: Hooray, the two leads have finally found each other and reunited with the rest of the party, after killing Deus and freeing everyone from its control, making them able to lead their own lives! Unfortunately, "everyone" doesn't include the approximately 95% of the human race who either got turned into mutants and absorbed into Deus or straight-up killed.
Played very darkly in The Last of Us: Joel and Ellie both survive and seemingly find a stable place to live together. The rest of the cast besides Bill, Tommy, and Maria die. Humanity lost its biggest hope at recovering from the Zombie Apocalypse, because Joel refused to let Ellie be sacrificed to make a cure. The writers' stated intention for the ending subverts this trope: Ellie hated that Joel made that decision for her so that she lost all respect for him and would inevitably leave him. So not even the leads got a happy ending.
To the Moon gives a "happy ending" in the form of a Dying Dream to the main character Johnny, in which he re-lives another version of his life in which his twin brother, Joey, never died and where he travels to the Moon with his soulmate River, but there's the fact that this never happened in reality, and that the real world counterparts died after suffering great pain for years.
In Family Guy, Lois is targeted for assassination by the Mafia by putting a bomb in her car. But Peter convinces the kingpin to spare her life; and the episode ends with Peter saying "all that matters is that nobody important got hurt." (As the parking-valet's clothes come floating down from the sky in little pieces.)
And in another episode:
Peter: I guess being a hero isn't always about saving lives. Sometimes it's just about caring for the people you love.
Random Woman: Help! I've been robbed! Peter: Who cares? I don't even know you!
In My Little Pony: Friendship Is Magic episode "The Best Night Ever", after trashing the Grand Galloping Gala and ultimately having their dreams of the best night ever ruined, Princess Celestia comes in and reassures them that she had always found the Gala dreadfully dull and invited her friends in the hopes that they could spice things up a bit, and the episode ends with them having a good laugh about it. Please remember that the Mane Cast at various points assaulted the other party guests, cost probably many thousands of dollar equivalents in damages, ruined probably hundreds of man hours (pony hours?) of effort, probably caused some minor psychological scarring to the other guests when one of them sent an animal stampede into the ballroom while wearing an Axe Crazy expression and screaming, and otherwise ruined the event for hundreds of other guests.
In TaleSpin, Baloo is declared the heir to a rich family and inherits their fortune. The reason he is the sole heir is because all the others were killed by the cook and the butler in a scheme to inherit the fortune, but all their attempts on Baloo's life fail and the cook and the butler are arrested. So all live happily.... except for, you know, every single other member of the rich family Baloo was the last surviving heir to, who were all killed by the servant and the butler. And we mean EVERY member, because they had to seek out Baloo, who was very distantly related and didn't even know about the family. Even the Romanov massacre didn't get all of the Romanovs except for ONE survivor!
Done several times on Futurama, where the main characters resolve their issues while the city gets destroyed in the background. One episode had Fry and Leela making up after Fry put a humiliating video of her on the Internet, meanwhile all of Bender's and Fry's Twitter subscribers get turned into zombies. Another had Bender being saved from execution by going on a murderous rampage with Santa Claus (It Makes Sense in Context).