It wasn't all that long ago that both Microsoft (NASDAQ:MSFT) and Oracle (NYSE:ORCL) would have both been considered no-brainer investments in the tech market. While both companies have made stumbles transitioning their businesses to ride the next tech wave, only Microsoft has successfully stayed atop its board and surfed toward renewed success.

Microsoft's jump from a software-based company to cloud computing services has helped push the tech stalwart's stock price up about 150% over the past three years. Meanwhile, Oracle's slow move away from its legacy software business hasn't been as impressive, and investors have taken notice. Oracle's shares have failed to beat the S&P 500 benchmark during the past three years.

But to really understand how these companies are doing, we need to take a closer look at their financials, what advantages they may have over their competitors, and how their valuations stack up against each other.

Two blocks sitting on a scale.

Image source: Getty Images.

Financial fortitude

Company Cash Debt Free Cash Flow (TTM)
Microsoft $131.5 billion $86.3 billion $33.6 billion
Oracle $40.0 billion $56.4 billion $13.1 billion

Data sources: Yahoo Finance! and Morningstar. TTM = trailing 12 months.

There really isn't much of a contest here between the two companies. Microsoft generates much more cash and has substantially more free cash flow than Oracle. This gives Microsoft more flexibility to adapt to economic downturns or snatch up smaller businesses to help spur new growth.

While Microsoft does have more debt than Oracle, its available cash more than offsets its liabilities.

Winner: Microsoft.

Valuation

Company P/E Ratio (TTM) Forward P/E EV/EBITDA
Microsoft 28.4 25.0 18.4
Oracle 19.7 14.6 12.5

Data source: Yahoo! Finance. TTM = trailing 12 months.

The average price-to-earnings ratio for companies in the S&P 500 is about 25, which makes Oracle's shares relatively cheap compared with Microsoft's. But Microsoft's stock isn't all that expensive based on these metrics, either.

Meanwhile, the average EV/EBITDA for companies in the S&P 500 is about 17, which again makes Oracle's stock cheaper when compared with Microsoft's. So based on these metrics, Oracle gets the win on valuation.

Winner: Oracle.

Competitive advantage

There was a time when Oracle had a sustainable competitive advantage over its competitors. It could offer some of the best hardware on the market and get enough customers to use its products so that it became too expensive for them to switch to its competitors.

But nearly every hardware company has been forced to transition to cloud-based software and services in the past decade or so. Some have made the leap better than others. While Oracle has made changes to its business, it hasn't been enough to retain old customers. Oracle's cloud services and licensing segment -- which makes up 69% of its business now -- grew by just 1% in the most recent quarter, while all of its other revenue segments experienced year-over-year declines.

Meanwhile, Microsoft has done a fantastic job of moving from traditional software sales to recurring cloud-based software sales and adding services like its public cloud computing hosting service, Azure. In the most recent quarter, Microsoft's Office commercial products and cloud service sales increased 12%, its intelligent cloud services (which includes server products) jumped 22%, and sales from its popular Azure service (which holds 14% of the public cloud computing market) spiked 73% year over year.

In short, Microsoft has successfully moved to the cloud, and its sales are growing substantially from that transition. Microsoft easily gets the win in this category.

Winner: Microsoft.

Microsoft for the win

There really isn't much of a contest between these two companies. Sure, Oracle's shares are technically less expensive than Microsoft's, but that doesn't make them a better value. Microsoft's sales across its most important revenue segments are growing, it's a leader in the expanding cloud computing space, and it has plenty of cash on hand to continue investing in its future.

Oracle, on the other hand, is still having a rough time transitioning to the cloud. The company's sales aren't growing as fast as they need to be, and it's still unclear how Oracle can set itself apart from its competitors.

For all these reasons, Microsoft gets the overall win as the better stock to buy in this matchup.