The wealthy are flocking to the beach this summer—and so is their money.

Real estate sales in the Hamptons hit a record in the second quarter, according to a new report from brokerage firm Douglas Elliman and Miller Samuel, the appraisal and research firm. Sales for the quarter came to $1.145 billion, up 23 percent from last year's second quarter, which totaled $929.4 million.

The second-quarter total is the highest since Miller Samuel began tracking the Hamptons market in 2005, according to Jonathan Miller, the company's president and CEO.

"It was a surprisingly strong quarter," he said.