WITH g AS (
  SELECT ST_Buffer(ST_SetSRID(ST_MakePoint(0,0),4326)::geometry, 1000)::geometry AS g
),
points AS(
  SELECT (
    ST_Dump(
      cdb_crankshaft.cdb_dot_density(g.g, 100)
    )
  ).geom AS p FROM g
)
SELECT count(*), sum(CASE WHEN ST_Contains(g,p) THEN 1 ELSE 0 END) FROM points, g
 count | sum 
-------+-----
   100 | 100
(1 row)

