Everyone knows the marijuana industry is booming. Canada's recreational cannabis market opens later this year. The medical cannabis market in Germany -- the largest economy in Europe -- is expanding quickly. Thirty U.S. states have already legalized medical marijuana, with nine of them also allowing the legal use of recreational marijuana. More states could follow in their footsteps.

With all of this going on, you might think that marijuana-related businesses would be rolling in profits. But that's not the case. Most of them remain unprofitable despite the rapid growth of the industry. There are a few companies, however, that are profitable.

Which marijuana stocks are most profitable? Based on trailing-12-month earnings, three stocks with market caps of $200 million or more ranked at the top: Scotts Miracle-Gro (NYSE:SMG), Aphria (NASDAQOTH: APHQF), and CannTrust Holdings (OTC:CNTTQ). Here's what sets these marijuana stocks apart from all the rest.

1. Scotts Miracle-Gro

Scotts Miracle-Gro has emerged as the go-to hydroponics supplier for marijuana cultivators. The company completed several acquisitions over the past few years to solidify its position in the rapidly growing cannabis industry, including its purchase of Sunlight Supply in April. Scotts generated trailing-12-month net income of $219 million, making it by far the most profitable marijuana stock.

There's one catch with Scotts Miracle-Gro's solid profits: Most of its money isn't made from selling to the cannabis industry. In the company's fiscal 2018 Q3, which ended on June 30, 2018, only 7.5% of Scotts' total revenue stemmed from its Hawthorne segment, which focuses on the cannabis market. What's more, Hawthorne has actually operated in the red so far in fiscal 2018.

However, Scotts Miracle-Gro fully expects its Hawthorne business to generate strong profits in the coming years. California, which generates roughly half of the segment's sales, got off to a rocky start in 2018 with its legal recreational marijuana market. As the kinks are worked out in the state and other large states legalize recreational pot, Scotts should see its marijuana-related profits continue to grow like a weed (pun fully intended.)

2. Aphria

Aphria claims a spot among the top five biggest Canadian marijuana producers. Unlike most of its peers, though, Aphria is profitable. The company's trailing-12-month net income is nearly CA$24 million. And despite somewhat disappointing fiscal 2018 Q4 results announced a few weeks ago, Aphria has achieved 11 consecutive quarters of positive adjusted EBITDA -- an accomplishment none of the other major Canadian marijuana growers have pulled off.

As was the case with Scotts Miracle-Gro, though, Aphria's profitability requires further explanation. The company reported a big profit in its fiscal 2018 first quarter due to an unrealized gain on long-term investments, notably including Aphria's investment in Arizona-based Copperstate Farms. Without this one-time gain, Aphria wouldn't have been profitable over the past 12 months.

There's good news and bad news for Aphria over the near term. The bad news is that the company is likely to see its bottom line deteriorate some. The good news, though, is that this will be the result of Aphria boosting its investments to prepare for anticipated high demand for recreational cannabis in Canada and medical cannabis in international markets.

3. CannTrust Holdings

CannTrust Holdings, like Aphria, is a licensed producer of medical cannabis in Canada. The company reported its fifth consecutive quarter of positive earnings just a few days ago. CannTrust's trailing-12-month net income is CA$18.5 million.

Is an asterisk warranted for CannTrust's profitability, too? Yep. If you look closely at the company's financial statements, you'll find that CannTrust's gross profit exceeded its revenue in three of the last four quarters. That's because the company benefited from unrealized gains on changes in the fair value of biological assets. In other words, the accounting value of CannTrust's cannabis plants that haven't been harvested yet increased.

CannTrust is busy cranking up its production capacity to supply the domestic recreational marijuana market. The company expects to be able to grow more than 100,000 kilograms of cannabis per year when all of its expansion efforts are completed. CannTrust has also signed supply agreements for recreational cannabis with three Canadian provinces.

The bottom line isn't the bottom line

Should investors buy the marijuana stocks just because they're the most profitable? No. As we saw, positive earnings numbers can be a little deceiving. More important, other companies that aren't profitable could be even stronger over the long run because they're investing in ways that will pay off in the future.

Having said that, I do like Scotts Miracle-Gro as a long-term pick. My view is that the company will enjoy strong earnings growth from its Hawthorne segment. I also think Scotts' core business of selling consumer lawn and garden products has growth potential. Profitability isn't everything, but it definitely helps.