If you want your $1,000 to turn into a whole lot more a few years down the road, buying stocks is a great idea. But not just any stocks. The best bet is a company that has a track record of earnings growth -- and solid future prospects too.

You can find them in any industry. Today, though, let's look at retailers. It's been a tough year for them -- higher inflation and economic troubles have weighed on companies and consumers. But there still are some players that have what it takes to weather the storm and perform over the long haul. The following two companies actually generate revenue from customers before they even buy anything. Let's check out these winning retail players.

1. Amazon

You don't have to sign up for Amazon's (AMZN 0.57%) Prime program to shop on the e-commerce website. But more than 200 million people have. And that means Amazon is bringing in steady annual revenue from them. Amazon says Prime members' spending has been increasing -- and they're relying more and more on Amazon for shopping and entertainment.

Of course, today's economic environment is weighing on retail. That's hurt Amazon's earnings in recent times.

But here's some good news. The company's cloud computing business -- Amazon Web Services (AWS) -- continues to report double-digit growth in sales and operating income. That's in spite of the current economic situation. And AWS actually is the big profit driver. AWS last year accounted for more than 70% of Amazon's total operating income.

This means Amazon can count on AWS during these difficult times -- as well as in easier times. Importantly, AWS is the market leader. And the cloud computing market is expected to grow in the double digits through this decade. AWS should continue to drive Amazon's growth well into the future.

As for e-commerce, woes may not be over. Amazon must still manage higher costs. Shoppers may not spend as much if inflation hurts their wallets. But the tough times won't last forever. History shows us economic downturns are followed by recovery and growth. As a market leader, Amazon is well positioned to benefit once the pressures of inflation and a difficult economy ease.

Prospects look good for these two Amazon businesses. And the company's track record shows us it can deliver top-notch earnings -- and share performance -- over time. That makes it a great buy for long-term investors.

AMZN Chart

AMZN data by YCharts.

2. Costco

You have to pay a membership fee to shop at Costco Wholesale (COST -0.41%). In return, you get prices that usually beat those of other retailers. This business model has worked for Costco over the long term. Earnings and return on invested capital have climbed over time.

COST Net Income (Annual) Chart

COST Net Income (Annual) data by YCharts.

Of course, you might wonder whether, in difficult economic times like right now, people may reconsider paying a membership fee before even setting foot in a store.

I would argue that this actually might be a moment of strength for Costco. Though there is an annual fee to pay, customers who shop at Costco often enough clearly get their money's worth. So, when they're worried about spending, customers might favor Costco over other stores.

Costco has shown that its membership continues to grow. The company recently hit an all-time high in membership renewal rates. At the end of the fiscal fourth quarter, Costco's renewal rate in the U.S. and Canada reached 92.6%, up 0.3 percentage points from the previous quarter. And the number of cardholders climbed 6.5% year over year to more than 118 million at the end of the fourth quarter.

The trend in executive memberships also supports the idea of strong future revenue prospects. Executive memberships cost double the amount of a traditional membership. This higher level of membership comes with various benefits. Executive membership is on the rise. And that's important because these members make up a significant share of sales -- nearly 72%.

Now let's talk about price. Trading at 33 times forward earnings estimates, Costco isn't the cheapest retailer on the block. But considering Costco's earnings track record and today's membership growth, it's worth paying a premium for this stock.

And Costco's valuation isn't as high as it was a few months ago. It's declined 22% since the start of the year. This looks like the perfect opportunity to get in on this remarkable stock.