The stock market has had a dismal first half of 2022, and few areas of the market have been spared. Overall, the S&P 500 is down by 20%, and many investors' favorite stocks are performing far worse.

However, not all investments are lower this year, and that's true in the world of exchange-traded funds (ETFs), as well as in the stock market. With that in mind, here are three ETFs, all with different investment objectives, that have all produced positive total returns so far in 2022.

Energy has been a big winner in 2022

We'll start with the most obvious. If you've bought gasoline in the past few months, it's no secret that energy prices have soared in 2022. And most energy stocks have done the same.

The Energy Select Sector SPDR ETF (XLE -0.29%) is one of the largest ETFs that track the space. With a 0.10% expense ratio, it's also one of the most cost-efficient ways to invest.

As you might expect, ExxonMobil and Chevron are the two largest holdings, but the fund holds large positions in dozens of well-known energy stocks. As of June 29, the ETF has delivered total returns of 35% year to date for its investors.

High-yielding stocks have kept this ETF moving higher

Many dividend stocks have not been spared in the market downturn, and most dividend-focused ETFs are not in the green this year. However, the WisdomTree U.S. High Dividend ETF (DHS 0.37%) is an exception, with a 2% total return so far in 2022.

The main reason this dividend ETF has outperformed most of its peers is that it tracks a proprietary index (the WisdomTree U.S. High Dividend Index), and this index happens to be heavily weighted with sectors that have outperformed in 2022. In fact, 69% of the fund's assets are invested in energy stocks or sectors considered to be defensive (consumer staples, healthcare, and utilities). Because of the ETF's heavy allocation in these areas, this could be not only a solid income investment, but an investment that's worth a closer look if you're worried about a recession arriving in the near future.

Oil and gas aren't the only commodities doing well

We all know that oil and gas have spiked much higher, but you might not realize that many metal prices have increased in 2022, as well. Iron ore is significantly higher than where it started 2022, and gold is in positive territory, as well, just to name a couple of examples. As a result, the SPDR S&P Metals and Mining ETF (XME -0.15%) has delivered slightly positive total returns year to date.

This ETF invests in a diverse portfolio of various metal and mining companies, and top holdings include Steel Dynamics, Allegheny Technologies, and Reliance Steel & Aluminum. No holding makes up more than 6% of the fund's assets, and while its 0.35% expense ratio isn't exactly the lowest on this list, it's not high for a specific-focus ETF like this one.

Are these ETFs worth buying now?

These three ETFs have outperformed the market so far in 2022, but it doesn't mean they'll continue doing so. Conversely, it also doesn't mean they're overdue for a decline.

The bottom line is that ETFs like these are great for investors who want exposure to a certain sector or type of stock but don't want too much of their returns levered to any single investment. If you want more exposure to energy, materials, or income-focused investments in your portfolio, all three of these are solid ETFs that could be worth a closer look.