P.unit_id, P.resource_id, P.resource_type, SUM(amount) AS reward FROM prod_pointsvc.g_vw_point P WHERE P.resource_type in (‘feed’, ‘lottery’) GROUP BY 1, 2, 3, 4 ); SELECT SUM(amount) FROM table_b roulette이 추가된 것을 반영하지 못함 INSERT INTO TABLE_A ( SELECT DATE_TRUNC(‘day’, P.created_at) AS data_at, P.unit_id, P.resource_id, P.resource_type, SUM(amount) AS reward FROM prod_pointsvc.g_vw_point P WHERE P.resource_type in (‘feed’, ‘roulette’, ‘lottery’) GROUP BY 1, 2, 3, 4 ); SELECT SUM(amount) FROM table_a