CREATE OR REPLACE FUNCTION clear_topn4_proc()
RETURNS VOID
LANGUAGE plpgsql
VOLATILE
AS
$$
BEGIN


  DELETE FROM vpx_topn_past_year
   WHERE NOT EXISTS(SELECT 'x'
                      FROM VPX_SAMPLE_TIME4 t
                     WHERE t.sample_time = vpx_topn_past_year.sample_time
                     );

END
$$