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

Leads View

view name = 'leads_view'

[NEW] Query

 SELECT uid,
    "timestamp",
    phone,
    email,
    name,
    gender,
    date_of_birth,
    age,
    age_group,
    branch,
    language,
    contact_owner,
    source,
    sremarks,
    content,
    medium,
    mremarks,
    assigned_pic,
    interest,
    leads_notes,
    leads_qualification,
    user_type,
    kyzn_account,
    sleekflow_id,
    leads_date,
    mql_date,
    "mqlPlus_date",
    "tourPlus_date",
    convert_date,
    loss_date,
    tour_date,
    "is_tour_show?",
    trial_date,
    "is_trial_show?",
    "is_inbound?",
    "is_leads?",
    "is_mql?",
    "is_mqlPlus?",
    "is_tourPlus?",
    "is_trialPlus?",
    "is_convert?",
    interest_remarks,
    submitted_email,
    assigned_email,
    "trialPlus_date",
    membership_name,
    package_name,
    start_membership,
    member_id,
    total_amount,
    payment_method,
    promotion,
    ref_program,
    ref_id,
    ref_name,
    ref_phone,
    identity_photo,
    status,
    convert_by,
    end_membership,
    signature,
    contract,
    offer_trial,
    reply_after_offer,
    last_appt_category,
    "conversationId",
    assigned_date,
        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, "timestamp"), 'DD Mon'::text) || ' - '::text) || to_char(date_trunc('week'::text, "timestamp") + '6 days'::interval, 'DD Mon'::text) AS week_inbound,
    (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,
        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, convert_date), 'DD Mon'::text) || ' - '::text) || to_char(date_trunc('week'::text, convert_date) + '6 days'::interval, 'DD Mon'::text) AS week_convert,
    last_created_by,
    hide
   FROM leads
  WHERE hide IS NULL OR hide = false;

PreviousTarget ViewNextAppt View

Last updated 5 months ago