Query select distinct post_id as ID from wphx_postmeta inner join wphx_posts on wphx_posts.ID = wphx_postmeta.post_id where wphx_posts.post_type='class' and wphx_posts.post_status='publish' and wphx_postmeta.meta_key='_wcs_timestamp' and wphx_postmeta.meta_value>='1519171200' order by wphx_postmeta.meta_value