# View: dt_agg_restrictions_subacct_territory

**View Name:** dt_agg_restrictions_subacct_territory
**Table Source:** `INTELLIGENCE.DBT_PROD.RESTRICTIONS_SUBACCOUNT_TERRITORY`
**File Path:** `dt_agg_restrictions_subacct_territory.view.lkml`

## Overview

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

## Comments & Notes

- derived_table: {
- SELECT agg_restrictions.subaccount_id, c.name
- SELECT sa.subaccount_id, vtr.country_id

## Dimensions

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

## Measures

| Name | Type |
|------|------|
| `list_aggregate_restrictions` | string |

## Derived Table

```sql
#  sql:
  #  SELECT agg_restrictions.subaccount_id, c.name
  #  FROM (
  #      SELECT sa.subaccount_id, vtr.country_id
  #      FROM orchard_app_reporting_v2.art_relations_prod_art_relations.subaccount sa
  #          INNER JOIN intelligence.dbt_prod.active_vendor_contracts vw ON sa.vendor_id = vw.vendor_id
  #          INNER JOIN (
  #              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(territory_carve_out, ',')) a) vtr ON vtr.id = vw.vendor_contract_id
  #      WHERE vtr.country_id IS NOT NULL
  #      UNION ALL
  #          SELECT subaccount_id, country_id
  #          FROM orchard_app_reporting_v2.art_relations_prod_art_relations.subaccount_territory_restriction
  #  ) agg_restrictions
  #      INNER JOIN orchard_app_reporting_v2.art_relations_prod_art_relations.country c ON agg_restrictions.country_id = c.id ;;
  #
```

