select cartodb_id, 'minor' as type, ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom, ST_Transform(ST_Buffer(the_geom::geography, 100000)::geometry, 3857) AS the_geom_webmercator from all_day where mag <= 2.9 UNION ALL select cartodb_id, 'light' as type, ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom, ST_Transform(ST_Buffer(the_geom::geography, 300000)::geometry, 3857) AS the_geom_webmercator from all_day where mag > 2.9 and mag <= 3.9 UNION ALL select cartodb_id, 'moderate' as type, ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom, ST_Transform(ST_Buffer(the_geom::geography, 500000)::geometry, 3857) AS the_geom_webmercator from all_day where mag > 3.9 and mag <= 4.9 UNION ALL select cartodb_id, 'strong' as type, ST_Buffer(the_geom::geography, 100000)::geometry) AS the_geom, ST_Transform(ST_Buffer(the_geom::geography, 700000)::geometry, 3857) AS the_geom_webmercator from all_day where mag > 4.9