In 2019, global e-commerce giant Amazon (AMZN -1.43%) placed an order to purchase 100,000 electric utility vehicles from Rivian Automotive (RIVN -2.52%) to help fulfill its goal to have an entirely green energy-powered delivery fleet by 2030. Along with the order, Amazon accumulated a stake in the electric vehicle maker. That stock purchase has wreaked havoc on Amazon's bottom-line results over the last few quarters.

But Amazon is no stranger to navigating the volatility in emerging industries. It has become a world leader not only in e-commerce, but also in cloud services, streaming, and even digital advertising. 

Fresh off its recent 20-for-1 stock split, Amazon posted its second-quarter 2022 financial results on July 28. Here's why investors sent its stock price 10% higher the following day despite the company posting a net loss of $2 billion.

A Rivian electric vehicle parked in the driveway of a home.

Image source: Rivian Automotive.

Amazon's smaller businesses made big contributions

Amazon Web Services (AWS) is Amazon's cloud services business, and it's the leader in the industry by revenue and scope of solutions. It has been the profitability engine behind the entire company in recent years, despite accounting for just 16% of Amazon's total revenue.

AWS helps companies migrate operations online to modernize their business processes. It provides a growing number of solutions, from data storage to virtual machines to advanced machine learning tools. That's a small sample of hundreds of services AWS offers to 21 different industries at the moment.

Amazon's total second-quarter revenue came in at $121.2 billion, a 7% jump compared to the year-ago quarter. But AWS' revenue rose a whopping 33% to $19.7 billion, and advertising also beat the broader company for growth, increasing by 18% to $8.7 billion.

Therefore, while e-commerce remains Amazon's largest revenue generator, its smaller segments are driving the company's growth and are gradually becoming much larger contributors.

Rivian Automotive sank Amazon's Q2 bottom line

Rivian Automotive listed on the public markets in 2021, and its stock has been on an incredibly volatile ride ever since. Amazon reports changes in the value of its 18% stake in the company in its net income results. 

In the fourth quarter of 2021, Rivian delivered an $11.8 billion benefit to Amazon's earnings, followed by a $7.6 billion loss in the first quarter of 2022. In the recent second quarter, thanks to the continued decline in Rivian's stock price, Amazon incurred a further $3.9 billion loss on its shareholding. 

Considering Amazon reported a $2 billion overall net loss in Q2, it would have actually made a profit of $1.9 billion if not for the negative impact of Rivian. That said, the company knows investing in the electric vehicle industry is an extremely long-term game, so it could take several years for its bet on the up-and-coming manufacturer to pay off. 

In July, Amazon announced it would finally begin rolling out electric delivery vehicles from its initial 2019 order with Rivian. That also means Rivian is ramping up its vehicle deliveries, which will improve the company's financial performance, and potentially its beaten-down stock price. 

Buy Amazon stock for the long run

Amazon wasn't built in a single quarter, so investors would be wise to maintain a long-term focus. Since the company listed publicly in 1997, its stock has generated a return of more than 149,800% -- in other words, an investment of $10,000 back then would be worth $14.9 million today. 

Over the last four quarters, Amazon has generated a profit of $1.11 per share (adjusted for its recent stock split). It places its stock at an eye-watering price-to-earnings multiple of 121, which is over four times higher than the 26.9 multiple of the Nasdaq-100 technology index. 

But since Amazon Web Services has accounted for all the company's operating income over the last four quarters, and given the speed with which that segment is growing, investors are likely discounting some recent underperformance in Amazon's e-commerce business on the earnings front.

In addition, the company has yet to reveal how profitable its advertising segment is. It has generated over $33.9 billion in sales in the last four quarters, and there are enormous opportunities ahead in that space. Amazon is gearing up to exclusively deliver the NFL's Thursday Night Football on its Prime streaming platform, plus its hotly anticipated Lord of the Rings series, which hits screens (also on Prime) in September. 

Amazon is one of the most diverse technology companies investors can buy. Even in a difficult economic environment with high inflation and rising interest rates, having multiple revenue streams provides some insulation against weaker consumer spending in its e-commerce business. 

That's why, despite taking a hit from its Rivian investment in Q2, investors should consider building a position in Amazon now with the intention of holding for the long run.