Sales of single-family homes and condominiums in Massachusetts declined in July, while median prices for both continued their upward trend, according to The Warren Group.

Statewide, 5,688 single-family homes sold in July, down 4.2 percent from the same month last year, marking the first time sales have decreased in that month since 2010, when there was a 27.6 percent decrease year-over-year.

Condominium sales also decreased last month, falling 4.3 percent from a year earlier to a total of 2,235.

“The decrease in single-family home and condo sales is discouraging, and the limited inventory is definitely a factor,” said Cassidy Murphy, The Warren Group’s editorial director. “The rise in the median selling price for both single-family homes and condos indicates that good inventory is selling quickly, and at a good price. There just isn’t a lot of it.”

The median price of a single-family home rose 1.7 percent in July to $355,000, marking the 22nd consecutive month of year-over-year increases, while the median condo price rose 5.5 percent to $327,000, up from $310,000 a year earlier.