# View: svod_revenue_views

**View Name:** svod_revenue_views
**Table Source:** `Derived from: Dbt_Prod.Awal_Tier_Groups, Dbt_Prod.Youtube_Subscription_Mrr_Update, Intelligence.Dbt_Prod, Prod.Dim_Release`
**File Path:** `views/yt_performance_report/svod_revenue_views.view.lkml`

## Overview

- **File Size:** 1449 bytes
- **Lines of Code:** 56
- **Dimensions:** 0
- **Measures:** 2
- **Dimension Groups:** 1
- **Filters:** 0

## Measures

| Name | Type |
|------|------|
| `partner_revenue` | sum |
| `owned_views` | sum |

## Dimension Groups

| Name | Type |
|------|------|
| `download_date` | time |

## Derived Table

```sql
sql:
      WITH latest_month AS (
    SELECT DATE_TRUNC('month', MAX(download_date)) AS max_month
    FROM INTELLIGENCE.DBT_PROD.YOUTUBE_SUBSCRIPTION_MRR_UPDATE
)

SELECT
    sub.download_date,
    SUM(sub.partner_revenue) AS partner_revenue,
    SUM(sub.owned_views) AS owned_views
FROM (
    SELECT *
    FROM INTELLIGENCE.DBT_PROD.YOUTUBE_SUBSCRIPTION_MRR_UPDATE,
         latest_month
    WHERE
        download_date >= DATEADD(month, -1, max_month)
        OR download_date = DATEADD(month, -12, max_month)
) AS sub
LEFT JOIN facts.prod.dim_release AS facts_prod_dim_release
    ON CAST(sub.current_upc AS VARCHAR) = CAST(facts_prod_dim_release.releaseid AS VARCHAR)
LEFT JOIN INTELLIGENCE.DBT_PROD.AWAL_TIER_GROUPS AS int_dbt_prod_awal_tier_groups
    ON facts_prod_dim_release.labelid = int_dbt_prod_awal_tier_groups.labelid
WHERE
    (int_dbt_prod_awal_tier_groups.brand_name NOT IN ('awal', 'altafonte')
     OR int_dbt_prod_awal_tier_groups.brand_name IS NULL)
GROUP BY 1
ORDER BY 1 DESC
      ;;
```

