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


  DELETE FROM vpx_topn_past_day
   WHERE NOT EXISTS(SELECT 'x'
                      FROM VPX_SAMPLE_TIME1 t
                     WHERE t.sample_time = vpx_topn_past_day.sample_time
                     );

END
$$