Wal-Mart’s U.S. business posted its best same-store sales result in three years during the second quarter.