With the first leg of third-quarter earnings in the books, investors may be getting skittish about the outlook. 

But a second glance shows the picture may actually be positive for the S&P 500, UBS Global Wealth Management Chief Investment Officer Mark Haefele said in a note. 

Q3 earnings for the index are expected to contract 4.6%, but that contraction is far from widespread. "Weakness is concentrated in the energy, materials, and technology sectors, as well as select megacap stocks," Haefele pointed out. "The median S&P 500 company should grow earnings 4-5%." 

Specifically, energy companies in the index are expected to see earnings contract 35% for the quarter, FactSet consensus estimates show. Oil stocks have underperformed the S&P 500, as the outlook on oil prices isn't exactly rosy. Chevron (CVX - Get Report) is up 4.5% for the year. BP (BP - Get Report) is down 3.4%. Exxon Mobil (XOM - Get Report) is down 1.8% for the year. 

Materials companies are expected to see an earnings decline of 9.3%. Steel prices, which popped when President Donald Trump instituted tariffs in March 2018, began to slump. Since July 2018, the price of hot rolled coil has fallen 45%. Tariffs, while initially inflationary, are ultimately disinflationary, as companies are forced to raise prices ahead of demand for goods. 

U.S. Steel (X - Get Report) has seen its shares fall 42% this year, while Nucor (NUE - Get Report) is down 1%. And in light of the earnings outlook, fundamentals don't look to be inflecting positively any time soon. 

Tech broadly is expected to see an earnings decline of 10.2% in the quarter. 

Haefele on the other hand called out consumer staples, consumer discretionaries and utilities as three sectors that could shine. Staples are expected to see earnings contract just 1.8%. Moreover, utilities are expected to see earnings grow 4.2%. 

But money has flown aggressively into staples and utilities. Stocks this year have seen a heavy does of risk-on sentiment, and staples and utilities, typically defensive sectors, have been a large part of the rally.

Now, some consumer-staple stocks are not exactly cheap. The Invesco Consumer S&P Staples ETF (XLP - Get Report) is up 21% on the year, outpacing the S&P 500's 19% gain. Procter & Gamble (PG - Get Report) , one of the premier U.S. staples, trades at 22 times next year's earnings. 

And utilities may not be extremely cheap either. The Invesco S&P Utilities ETF is up 22% on the year. Con Edison (ED - Get Report) trades at 20 times forward earnings.