SELECT round(Jmag) AS bin, count(*) AS n, AVG(SQRT(POWER(pmRA,2)+POWER(pmDE,2))) AS pmavg FROM lspm.main GROUP BY bin ORDER BY bin