# View: dt_perf_rights_territory_subaccount

**View Name:** dt_perf_rights_territory_subaccount
**Table Source:** `INTELLIGENCE.DBT_PROD.DT_PERF_RIGHTS_TERRITORY_SUBACCOUNT`
**File Path:** `dt_perf_rights_territory_subaccount.view.lkml`

## Overview

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

## Comments & Notes

- derived_table: {
- WITH subaccount_territories AS (
- SELECT src.subaccount_id, srct.subaccount_royalty_collection_territory AS country_id

## Dimensions

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

## Derived Table

```sql
#     sql:



# WITH subaccount_territories AS (
#     SELECT src.subaccount_id, srct.subaccount_royalty_collection_territory AS country_id
#     FROM orchard_app_reporting_v2.art_relations_prod_art_relations.subaccount_royalty_collection src
#         INNER JOIN orchard_app_reporting_v2.art_relations_prod_art_relations.subaccount_royalty_collection_territories srct
#             ON src.subaccount_royalty_collection_id = srct.subaccount_royalty_collection_id AND src.active = 'Y'
# )
# SELECT sa.subaccount_id, LISTAGG(DISTINCT c.name, '; ') WITHIN GROUP (ORDER BY c.name ASC) AS list_territories
# FROM orchard_app_reporting_v2.art_relations_prod_art_relations.subaccount sa
#     INNER JOIN royalty_accounting_reporting.prod.vw_dim_abacus_ar_vendor v ON sa.vendor_id = v.vendor_id
#     INNER JOIN intelligence.dbt_prod.active_vendor_contracts vw ON v.vendor_id = vw.vendor_id
#     LEFT JOIN subaccount_territories st ON sa.subaccount_id = st.subaccount_id
#     LEFT JOIN orchard_app_reporting_v2.art_relations_prod_art_relations.country c ON st.country_id = c.id
# GROUP BY 1 ;;
#
```

