To find means over a certain area of the sky, use queries like select sa/ct, sd/ct, ct from (select q3c_ang2ipix(raj2000, dej2000)|(2^50-1)::bigint as x, count(*) as ct, sum(raj2000) as sa, sum(dej2000) as sd from usnob.data group by x) as q;