CREATE OR REPLACE FUNCTION clear_topn3_proc()
 RETURNS VOID
 LANGUAGE plpgsql
 VOLATILE
 AS
 $$
 BEGIN
 
 
   DELETE FROM vpx_topn_past_month
    WHERE NOT EXISTS(SELECT 'x'
                       FROM VPX_SAMPLE_TIME3 t
                      WHERE t.sample_time = vpx_topn_past_month.sample_time
                      );
 
 END
 $$