sql - How to filter out intraweek data in PostgreSQL? -
i have query i'm leveraging dashboard visualization. issue query includes data current week - problematic because week not baked. ideally, add filter pulls in data w/in last 52 weeks excludes data date greater recent reporting week (sun - sat). here have:
select (date_trunc('week',cj.created_at:: timestamptz) + '5 days':: interval)::date ,case when o.vertical null or o.vertical not in ('auto','franchise') 'smb' else o.vertical end vertical ,count(distinct cj.native_candidate_job_id) applicant_traffic dim_candidate_jobs cj join dim_organizations o on cj.native_organization_id = o.native_organization_id o.demo = false , not(o.name ~~* (array['%test%','%api%'])) , cj.created_at:: date > current_date - interval '52 weeks' , cj.created_at:: date < (date_trunc('week',current_date:: timestamptz) + '1 day':: interval)::date , o.current = 'y' , cj.current = 'y' group 1,2;;
and cj.created_at >= date_trunc('week', current_date) - interval '52 weeks' , cj.created_at < date_trunc('week', current_date)
Comments
Post a Comment