The S&P 500 is officially in an earnings recession for the first time in three years, and the trend is expected to get worse in the third quarter.

The entirety of the S&P 500 index SPX, +1.59% has reported results for the second quarter, showing an average earnings drop of 0.35%. Components posted a 0.29% decline in earnings per share in the first quarter, marking the first period of back-to-back declines since the second quarter of 2016. Earnings recessions are typically categorized as two straight quarters of falling earnings.

Opinion: Stock market’s eerie parallels to September 2007 should raise recession fears

Analysts surveyed by FactSet currently project a steeper drop for the third quarter, with estimates calling for a 3.95% decline on average. Sentiment has worsened since the start of the year, as analysts had been projecting a 1.07% increase in third-quarter earnings as of late March. But they expect things to turn positive again in the holiday period, with expectations for 1.3% growth overall in the calendar year.

Some of the worst-performing companies for the second quarter were in metals and mining, with earnings for that subsector down 76% on average amid falling prices and rising costs for companies like Freeport-McMoRan Inc. FCX, -0.52% . The materials sector overall saw a 17.88% decline, led by weakness in mining that’s projected to persist for another quarter.

Read: Stocks could drop 20% after an October disappointment, strategist warns

Industrials were another negative area, though most of the sector’s 10.23% decline could be blamed on Boeing Co. BA, +6.83% , which swung to a big loss after its 737 Max jets were grounded. Building products and construction companies were other big contributors to the sector’s decline.

Software and IT services were among the bright spots in the tech sector, but storage and semiconductors helped drive a 5.98% average earnings drop for information-technology companies. Chip companies had been calling for a second-half rebound heading into the latest round of earnings, but now some executives are a bit less confident. And looking ahead to the third quarter, analysts model a 30.81% drop in chip-sector earnings, steeper than the 25.38% drop experienced in the latest period.

The memory game: Chip companies giving mixed signals about a rebound

In all, five of the 11 S&P sectors saw earnings rise, led by health care and, particularly, insurers. Cigna Corp. CI, +0.97% witnessed a 72.42% rise in earnings, while Humana Inc. HUM, +3.57% grew profits by 49.84%.

The other sectors to show profit growth were communication services, financials, real estate and utilities. Analysts expect the same five sectors that grew earnings in the second quarter to repeat that performance in the third quarter.

The S&P 500 has ticked up 3.1% in the past three months.