Three pharmacy retailers combined make more than 40% of all revenue from prescriptions in the U.S. CVS Health (NYSE:CVS) and Walgreens Boots Alliance (NASDAQ:WBA) are the nation's largest pharmacy chains, with Rite Aid (NYSE:RAD) lagging behind. 

None of these pharmacy stocks have performed well so far in 2017. CVS Health's share price is barely above where it started the year, and Walgreens stock is actually down year to date. Then there's Rite Aid, which has seen its stock plunge more than 70% after a potential acquisition by Walgreens was scrapped.

Still, though, there's a case to be made for buying each one of these stocks. But which is the best buy among the three? Here's how CVS Health, Walgreens, and Rite Aid compare. 

Pharmacist holding pill bottle in front of computer monitor

Image source: Getty Images.

The case for CVS Health

There are two story lines for CVS Health. The company isn't just one of the top pharmacy retailers in the country; CVS also operates one of the largest pharmacy benefits managers (PBMs). While the retail pharmacy business is struggling somewhat, the PBM business is booming.

In the second quarter, CVS Health reported a solid year-over-year revenue increase for its PBM. That growth stemmed from higher claim volume and higher drug prices. However, its retail/long-term care (LTC) segment saw sales decline slightly because of higher generic-dispensing rates and reimbursement pressure. Another key factor is that CVS Health lost a couple of big contracts in late 2016 to Walgreens.

Investors have reason to like CVS Health stock over the long run, though, for a couple of key reasons. First, aging demographic trends in the U.S. should help the retail/LTC segment return to growth. These trends also benefit the PBM unit. Second, CVS Health is in solid financial position and rewards shareholders with nice a dividend, which currently yields nearly 2.5%. With the company using only 37% of earnings to fund the dividend program, future dividend hikes seem likely. 

The case for Walgreens

Walgreens Boots Alliance is both a pharmacy retailer and a pharmacy wholesaler. The company has enjoyed decent sales growth in its U.S. pharmacy stores. However, Walgreens' international retail pharmacies and its wholesale business have seen sales decline recently.

There's not too much for investors to really be concerned about, though. The international and wholesale numbers look much better when adjusted for currency fluctuations. And on an overall basis, Walgreens is growing both its top and bottom lines. The company is also set to capture a much bigger share of the U.S. retail market with its purchase of 1,932 stores from Rite Aid.

The same trends that should benefit CVS Health work to Walgreens' advantage, as well. Wall Street analysts project even stronger earnings growth for Walgreens over the next five years than they do for CVS. I suspect part of the reasoning behind those projections is the company's U.S. momentum and its higher profit margin. As icing on the cake, Walgreens pays a dividend that yields a little over 2%.

The case for Rite Aid

The argument for why investors should consider Rite Aid stock is very different. The company's revenue is falling. It lost money in the first two quarters of this year. And Rite Aid is about to be much smaller after selling off a large chunk of its stores to Walgreens. So why even remotely consider the stock? It could be a bargain.

Rite Aid will emerge from the Walgreens transaction with significantly lower debt. The company should also increase its profitability, thanks to divesting many of its underperforming stores. Rite Aid also gets to use Walgreens' network to buy generic drugs, which should reduce its costs.

Because of the shellacking its stock has taken this year, Rite Aid now has a market cap of only $2.2 billion or so. That translates to a heavily discounted price tag per store compared to what Walgreens is paying -- or what others might pay. If you're willing to wait for Rite Aid to turn things around as a leaner, meaner operation, or if you think that the company could still be an acquisition target, the stock could be a winner yet. 

"Buy" diagram with pen and calculator

Image source: Getty Images.

Best buy

Among these three pharmacy leaders, my view is that Walgreens is the safest pick. CVS Health is in a rebuilding phase after losing those big contracts mentioned earlier, and "rebuilding" would be an understatement for what Rite Aid now faces. Walgreens, meanwhile, will claim an even bigger presence in the U.S. and should see better days in the future for its international and wholesale businesses.

But I must admit that I'm a little leery of being a loud cheerleader for any of these stocks. Amazon (NASDAQ:AMZN) made waves earlier this year when reports surfaced that the e-commerce giant was looking at moving into the pharmacy market. While some question whether Amazon could be successful, I don't.

My view is that Walgreens and CVS Health stocks should perform relatively well over the next few years. Rite Aid is kind of a roll of the dice, although it could turn out to be a great value pick when all is said and done. Over the long run, though, the entire retail pharmacy industry should watch out: Amazon might be coming.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.