Microsoft (NASDAQ:MSFT) and Oracle (NYSE:ORCL) are both resilient tech stocks that rebounded from ugly market downturns over the past three decades. But over the past five years, Microsoft's stock nearly quadrupled and crushed Oracle's 20% gain.

Microsoft's rally was driven by the expansion of its higher-growth commercial cloud business, which reduced its dependence on its older software products. Oracle attempted a similar turnaround by pivoting from its legacy database software toward cloud services, but it grew at a slower pace than Microsoft.

Colored arrows emerge from a man's head.

Image source: Getty Images.

Will those trends continue for the foreseeable future? Or will Oracle find its footing in the cloud market and catch up to Microsoft? Let's dig deeper to decide.

How does Microsoft make money?

Microsoft splits its businesses into three main units: Productivity and Business Processes, which oversees Office, Dynamics, Skype, and LinkedIn; Intelligent Cloud, which handles Azure, Windows Server, and other data center services; and More Personal Computing, which manages its Windows, Xbox, Surface, and Bing units.

Each of these businesses generated roughly a third of Microsoft's total revenue in the first nine months of fiscal 2020. The COVID-19 crisis primarily impacted the More Personal Computing segment, which struggled with slower sales of Windows licenses, gaming hardware, Surface devices, and search ads throughout the year.

Microsoft offset the weakness of those businesses with the strength of its commercial cloud (mainly Office 365, Dynamics 365, LinkedIn, and Azure) revenue, which rose 38% annually during the first nine months and accounted for 36% of its top line. The pandemic notably lit a fire under many of those businesses as more people worked from home.

How does Oracle make money?

Oracle reports its revenue in four segments: cloud services and license support (72% of its revenue in the first nine months of 2020), cloud license and on-premise license (11%), hardware (9%), and services (8%).

Oracle generates most of its revenue from database solutions, but its acquisition of NetSuite in 2016 expanded its presence in the customer relationship management (CRM) market, which is dominated by Salesforce; the human capital management (HCM) market, which is led by Workday; and its own enterprise resource planning (ERP) business. The purchase also expanded its reach among small-to-medium-sized businesses.

Oracle stopped reporting its public cloud service revenue separately in 2018, which made it difficult to gauge its turnaround efforts, and the death of co-CEO Mark Hurd -- who oversaw its cloud expansion -- cast a dark cloud over the business last year. Despite those challenges, Oracle posted stronger-than-expected growth last quarter and only expected a "minimal impact" from the pandemic, since many of its customers were already locked into long-term contracts.

Which company is growing faster?

Microsoft's revenue and earnings rose 14% and 28%, respectively, in the first nine months of 2020. It repurchased $17.2 billion in shares during those three quarters, but those buybacks only reduced its diluted share count by about 1% annually. It also pays a forward dividend yield of 1.1%.

A Microsoft store.

Image source: Microsoft.

Analysts expect Microsoft's revenue and earnings to rise 12% and 20%, respectively, this year. Those growth rates are impressive, but its stock isn't cheap at nearly 30 times forward earnings. Looking ahead, its core cloud business could also face tougher challenges in the years ahead as Azure clashes with Amazon Web Services (AWS) and Dynamics battles Salesforce.

Oracle's revenue and earnings grew 1% and 9%, respectively, in the first nine months of 2020. However, its earnings growth was heavily boosted by $13.9 billion in buybacks, which reduced its diluted share count by 12% annually.

Wall Street expects Oracle's revenue to remain flat this year as its buybacks lift its earnings 10%. The stock trades at a reasonable 13 times forward earnings, and it pays a slightly higher forward dividend yield of 1.8%.  Oracle will likely rely on Fusion and NetSuite's double-digit revenue growth, as well as new deals with growing companies like Zoom Video, to bolster its cloud business -- but it could still face stiff competition from Amazon and other industry peers.

Which stock is the better buy?

At first glance, Oracle might seem like a safer bet than Microsoft. However, Oracle's anemic revenue growth, its weak position in the public cloud market, and its addiction to "buying" earnings growth with buybacks all make it a less appealing investment.

Microsoft's stock looks frothy at these levels, and it might be prudent to wait for a bigger pullback before accumulating more shares. However, I believe investors will continue to pay a premium for Microsoft, since its commercial cloud business is firing on all cylinders and offsetting the weakness of its more macro-sensitive businesses.