KYZN Docs
Home
  • Welcome
  • Intro
    • What is KYZN?
    • Age Group
  • KYZN Funnel
    • Glossary
      • General
      • Tracking Framework
    • Report
      • TAC Funnel
      • TCC Funnel
      • TAC Sleekflow
  • KYZN CRM
    • Glossary
      • My Leads
        • Add Leads
        • Add Family Leads
        • Add Appointment
        • Add Membership
        • Edit Branch
        • Edit PIC
        • Edit & Delete Leads
        • Search Leads
        • Reschedule Appointment
        • Clear Abnormal Stage
      • Approach
      • Pool
      • My Appt
        • Edit & Delete Appointment
        • Trial Form
      • My Convert
      • User Manager
      • UTM Generator
      • Assign PIC
      • Set Target
      • Schedule List
    • Event Bulk Data
  • Digital System
    • ETL Process
      • Query Checking
        • Cek Funnel Stage
        • Insert from temp_leads
        • Insert from sleekflow
        • Check Duplicate
        • Update Source Ads
        • Conversion Duration Analysist
        • Cek branch tidak match
        • Select Potential Contact
      • Query View
        • TAC Combined
        • TAC
        • TAC Appt
        • TAC Appt - Appt
        • TAC Appt - MQL
        • TAC Appt - MQLplus
        • TAC Appt - Tourplus
        • TAC Appt - Trialplus
        • TAC Convert
        • TAC Inbound
        • TAC Leads
        • TAC MQL
        • TAC MQLplus
        • TAC Tourplus
        • TAC Trialplus
        • Target View
        • Leads View
        • Appt View
        • Actual vs Target
        • All Time Leads Stages
        • All Time Appt Date
        • Budget Control
      • Database Management
        • pgAdmin
        • Looker Studio
  • Changelog
    • 2025-03
Powered by GitBook
On this page
  1. Digital System
  2. ETL Process
  3. Query View

Target View

view name = 'target_view'

[NEW] Query

 WITH daterange AS (
         SELECT generate_series(target.start_date::timestamp with time zone, target.end_date::timestamp with time zone, '1 day'::interval)::date AS date,
            target.user_id,
            target.branch,
            target.division,
            target."position",
            target.pic,
            target.target_inbound,
            target.target_leads,
            target.target_mql,
            target."target_mqlPlus",
            target."target_tourPlus",
            target."target_trialPlus",
            target.target_convert,
            target.end_date - target.start_date + 1 AS total_days
           FROM target
        ), dailytargets AS (
         SELECT daterange.date,
            daterange.branch,
            daterange.division,
            daterange."position",
            daterange.pic,
            daterange.target_inbound::double precision / daterange.total_days::double precision AS daily_target_inbound,
            daterange.target_leads::double precision / daterange.total_days::double precision AS daily_target_leads,
            daterange.target_mql::double precision / daterange.total_days::double precision AS daily_target_mql,
            daterange."target_mqlPlus"::double precision / daterange.total_days::double precision AS daily_target_mqlplus,
            daterange."target_tourPlus"::double precision / daterange.total_days::double precision AS daily_target_tourplus,
            daterange."target_trialPlus"::double precision / daterange.total_days::double precision AS daily_target_trialplus,
            daterange.target_convert::double precision / daterange.total_days::double precision AS daily_target_convert
           FROM daterange
        )
 SELECT date,
    branch,
    division,
    "position",
    pic,
    daily_target_inbound AS target_inbound,
    daily_target_leads AS target_leads,
    daily_target_mql AS target_mql,
    daily_target_mqlplus AS "target_mqlPlus",
    daily_target_tourplus AS "target_tourPlus",
    daily_target_trialplus AS "target_trialPlus",
    daily_target_convert AS target_convert
   FROM dailytargets
  GROUP BY date, branch, division, "position", pic, daily_target_inbound, daily_target_leads, daily_target_mql, daily_target_mqlplus, daily_target_tourplus, daily_target_trialplus, daily_target_convert
  ORDER BY pic, date;

PreviousTAC TrialplusNextLeads View

Last updated 5 months ago