# View: int_dbt_prod_dt_perf_rights_territory_label

**View Name:** int_dbt_prod_dt_perf_rights_territory_label
**Table Source:** `INTELLIGENCE.DBT_PROD.DT_PERF_RIGHTS_TERRITORY_LABEL`
**File Path:** `views/int_dbt_prod_dt_perf_rights_territory_label.view.lkml`

## Overview

- **File Size:** 1566 bytes
- **Lines of Code:** 48
- **Dimensions:** 2
- **Measures:** 0
- **Dimension Groups:** 0
- **Filters:** 0

## Comments & Notes

- derived_table: {
- WITH label_territories AS (
- SELECT id, TRY_TO_NUMBER(a.value::string) AS country_id

## Dimensions

| Name | Type |
|------|------|
| `vendor_id` | number |
| `list_territories` | string |

## Derived Table

```sql
#   sql:
  #   WITH label_territories AS (
  #       SELECT id, TRY_TO_NUMBER(a.value::string) AS country_id
  #       FROM orchard_app_reporting_v2.art_relations_prod_art_relations.vendor_contract,
  #       LATERAL FLATTEN(INPUT => SPLIT(royalty_collection_territory, ',')) a
  #   )
  #   SELECT v.vendor_id, LISTAGG(DISTINCT c.name, '; ') WITHIN GROUP (ORDER BY c.name ASC) AS list_territories
  #   FROM royalty_accounting_reporting.prod.vw_dim_abacus_ar_vendor v
  #       INNER JOIN intelligence.dbt_prod.active_vendor_contracts vw ON v.vendor_id = vw.vendor_id
  #       LEFT JOIN label_territories lt ON vw.vendor_contract_id = lt.id
  #       LEFT JOIN orchard_app_reporting_v2.art_relations_prod_art_relations.country c ON lt.country_id = c.id
  #   WHERE v.migrated_to_abacus
  #   GROUP BY 1 ;;
  #
```

