# View: sony_applications_data_leads

**View Name:** sony_applications_data_leads
**Table Source:** `Derived from: Awal_Sax, Awal_Sax.Sax, Prod.Audit_Event_Gda_Leads`
**File Path:** `DOSC/Community_Support/applications_data/views/sony_applications_data_leads.view.lkml`

## Overview

- **File Size:** 4190 bytes
- **Lines of Code:** 166
- **Dimensions:** 17
- **Measures:** 0
- **Dimension Groups:** 2
- **Filters:** 0

## Dimensions

| Name | Type |
|------|------|
| `Comments` | string |
| `Company` | string |
| `Consultant` | string |
| `ConvertedAccountId` | string |
| `ConvertedContactId` | string |
| `Country` | string |
| `Email` | string |
| `FirstName` | string |
| `Id` | string |
| `IsConverted` | string |
| `LastName` | string |
| `LeadScore` | string |
| `Approver` | string |
| `ApproverEmail` | string |
| `Status` | string |
| `VoucherCode` | string |
| `VoucherCodeOwner` | string |

## Dimension Groups

| Name | Type |
|------|------|
| `CreatedDate` | time |
| `LastModifiedDate` | time |

## Derived Table

```sql
sql:
      select
        replace(record_content:Comments__c, '"', '') AS Comments,
        replace(record_content:Company, '"', '') AS Company,
        replace(record_content:Consultant__c, '"', '') AS Consultant,
        replace(record_content:ConvertedAccountId, '"', '') AS ConvertedAccountId,
        replace(record_content:ConvertedContactId, '"', '') AS ConvertedContactId,
        coalesce(TERRITORIES.NAME,  replace(record_content:Country, '"', '')) AS Country,
        split_part(replace(record_content:CreatedDate, '"', ''), '+', 1) AS CreatedDate,
        replace(record_content:Email, '"', '') AS Email,
        replace(record_content:FirstName, '"', '') AS FirstName,
        replace(record_content:Id, '"', '') AS Id,
        replace(record_content:IsConverted, '"', '') AS IsConverted,
        split_part(replace(record_content:LastModifiedDate, '"', ''), '+', 1) AS LastModifiedDate,
        replace(record_content:LastName, '"', '') AS LastName,
        replace(record_content:LeadScore__c, '"', '') AS LeadScore,
        replace(record_content:Status, '"', '') AS Status,
        CASE
          WHEN replace(record_content:Owner:Email, '"', '') = 'mlorenz@theorchard.com' THEN 'Auto Approval'
          ELSE CONCAT(replace(record_content:Owner:FirstName, '"', ''), ' ', replace(record_content:Owner:LastName, '"', ''))
        END AS Approver,
        replace(record_content:Owner:Email, '"', '') AS ApproverEmail,
        replace(record_content:VoucherCode__c, '"', '') AS VoucherCode,
        replace(record_content:VoucherCodeOwner__c, '"', '') AS VoucherCodeOwner
      FROM
        FACTS.PROD.AUDIT_EVENT_GDA_LEADS
      LEFT JOIN
        AWAL_SAX.SAX.TERRITORIES ON ISO_ALPHA_3_CODE = replace(record_content:Country, '"', '')
      WHERE
        replace(record_content:IsConverted, '"', '') = 'true';;
```

