Few industries have the type of tailwinds in their favor that healthcare enjoys. With a large population of baby boomers entering their golden years and taking prescription medications at high rates, and with access to medical care improving, the potential is enormous.

At the same time, investors need to be careful where they put their money. Investing heavily in drug companies carries unique risks -- such as key medicines coming off of patents, or a promising drug being delayed in regulatory trials.

Prescription medicine bottles lined up in a row

Image source: Getty Images.

That's why investors have flocked to periphery plays like CVS Health (CVS -1.62%) and Express Scripts (ESRX). Between these two, which is the better buy today? It's impossible to answer with 100% certainty, but we can get a better idea of what we're paying for by looking at the question from three different angles. Here's how these two stack up.

Sustainable competitive advantages

Over the past decade of investing, I have come to view a company's sustainable competitive advantage -- or "moat" in investing lingo -- as the single most important factor to research. In the simplest of terms, a moat is what keeps customers coming back to a company week after week, while eschewing the competition the whole time.

CVS's moat is twofold. With over 9,700 locations worldwide, the company doubles as both a convenience store and a pharmacy benefits management (PBM) corporation. As for the latter, CVS is the second-largest PBM in the country.

In first place, however, is Express Scripts. While the company has mail-order services for drugs, it is through partnerships with brick-and-mortar chains like Walgreens that most of its business is fulfilled.

In the end, the PBM business is heavily reliant upon keeping contracts in place with big customers. That lends a degree of risk with either stock. All one has to do is see what happened with Express Scripts' stock recently when Anthem announced it wouldn't renew its contract in 2019.

I'm siding with CVS here, as actually owning the physical locations that patients visit, as well as having other revenue streams, offers a level of protection not present with Express Scripts.

Winner: CVS.

Financial fortitude

Value and growth investor usually like seeing companies use money -- either to increase dividends or to reinvest in lucrative opportunities, respectively. Neither camp really loves when businesses have money just sitting in the bank.

But there's something to be said for letting cash sit there. Every company, at one point or another, will face difficult economic times. Those that have cash on hand have options: buy back shares on the cheap, acquire rivals, or outspend the competition to gain long-term market share.

Those that are debt-heavy are in an unfavorable situation, forced to take their eye off of the long-term time horizon in an effort to keep the company afloat over the short term.

Keeping in mind that CVS is valued at over twice the size of Express Scripts, here's how the two compare:

Company

Cash

Debt

Net Income

Free Cash Flow

CVS

$2.3 billion

$25.6 billion

$5.1 billion

$9.1 billion

Express Scripts

$3.2 billion

$13.9 billion

$3.4 billion

$4.9 billion

Data source: SEC filings, Yahoo! Finance. Net income and free cash flow presented on trailing-12-month basis.

On this score, we have a pretty clear winner: Express Scripts. I'm not a fan of the leverage that either company has, but Express Scripts' is less tenuous. And relative to the size of each company, Express Scripts is bringing in as much -- or more -- cash as CVS.

Winner: Express Scripts.

Valuation

Finally, we have the murky science of valuation. While there's no single metric that can tell you if a stock is cheap or expensive, there are a number of data points we can consult. Here are five that I like to use: price-to-earnings ratio (P/E), price-to-free cash flow ratio (P/FCF), price-to-earnings growth ratio (PEG), dividend, and free cash flow (FCF) payout.

Company

P/E

P/FCF

PEG Ratio

Dividend

FCF Payout

CVS

14

9

1.8

2.5%

21%

Express Scripts

10

8

0.8

-

-

Data source: Yahoo! Finance, E*Trade, Morningstar. P/E calculated using non-GAAP earnings when possible.

It is much more difficult to declare a winner here. Both companies appear to be very cheap, especially as compared to the market at large. That said, the market is more sour on Express Scripts, likely because of its vulnerability to defections like Anthem's.

At the same time, CVS offers a very healthy dividend that has tons of room for growth in the future. You don't get any payout for investing with Express Scripts. Combine the two factors and I'm calling this one a tie.

Winner: Tie.

My winner is...

So there you have it: We have a draw. Whenever this happens, I always side with the company that has a stronger moat. In this case, that means that CVS comes out ahead. While I don't own the stock myself, I have given it an outperform rating on my CAPS profile.

Given the company's shift to a health-centric focus in recent years, favorable valuation, and solid dividend, it's worth kicking the tires on CVS if you're looking for an investment in the healthcare sector.