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

Appt View

view name = 'appt_view'

[NEW] Query

 SELECT appt_id,
    visit_category,
    appt_category,
    name,
    phone,
    uid,
    tour_date,
    "is_tour_show?",
    trial_date,
    "is_trial_show?",
    assigned_pic,
    mql_date,
    trial_class,
    visit_notes,
    "is_mql?",
    "is_mqlPlus?",
    "is_tourPlus?",
    "is_trialPlus?",
    contact_owner,
    created_by,
    assign_to_team,
    class_category,
    "mqlPlus_date",
    missed_date,
    "tourPlus_date",
    "trialPlus_date",
    family_id,
    branch,
    progress,
        CASE
            WHEN tour_date IS NULL AND trial_date IS NOT NULL THEN trial_date
            WHEN trial_date IS NULL AND tour_date IS NOT NULL THEN tour_date
            WHEN tour_date IS NOT NULL AND trial_date IS NOT NULL THEN GREATEST(tour_date, trial_date)
            ELSE NULL::timestamp without time zone
        END AS appt_date,
    (to_char(date_trunc('week'::text,
        CASE
            WHEN tour_date IS NULL AND trial_date IS NOT NULL THEN trial_date
            WHEN trial_date IS NULL AND tour_date IS NOT NULL THEN tour_date
            WHEN tour_date IS NOT NULL AND trial_date IS NOT NULL THEN GREATEST(tour_date, trial_date)
            ELSE NULL::timestamp without time zone
        END), 'DD Mon'::text) || ' - '::text) || to_char(date_trunc('week'::text,
        CASE
            WHEN tour_date IS NULL AND trial_date IS NOT NULL THEN trial_date
            WHEN trial_date IS NULL AND tour_date IS NOT NULL THEN tour_date
            WHEN tour_date IS NOT NULL AND trial_date IS NOT NULL THEN GREATEST(tour_date, trial_date)
            ELSE NULL::timestamp without time zone
        END) + '6 days'::interval, 'DD Mon'::text) AS week_appt_date,
    (to_char(date_trunc('week'::text, mql_date), 'DD Mon'::text) || ' - '::text) || to_char(date_trunc('week'::text, mql_date) + '6 days'::interval, 'DD Mon'::text) AS week_mql,
    (to_char(date_trunc('week'::text, "mqlPlus_date"), 'DD Mon'::text) || ' - '::text) || to_char(date_trunc('week'::text, "mqlPlus_date") + '6 days'::interval, 'DD Mon'::text) AS week_mqlplus,
    (to_char(date_trunc('week'::text, "tourPlus_date"), 'DD Mon'::text) || ' - '::text) || to_char(date_trunc('week'::text, "tourPlus_date") + '6 days'::interval, 'DD Mon'::text) AS week_tourplus,
    (to_char(date_trunc('week'::text, "trialPlus_date"), 'DD Mon'::text) || ' - '::text) || to_char(date_trunc('week'::text, "trialPlus_date") + '6 days'::interval, 'DD Mon'::text) AS week_trialplus,
    hide,
    q1_rate_class,
    q2_class_time,
    q3_class_prices,
    q4_join_member
   FROM appt
  WHERE hide IS NULL OR hide = false;

PreviousLeads ViewNextActual vs Target

Last updated 5 months ago