# View: abacus_contracts_linked_to_contributors

**View Name:** abacus_contracts_linked_to_contributors
**Table Source:** `Derived from: Prod.Nr_Contribution_Type, Prod.Performance_Nr_Contribution, Prod.Performance_Nr_Contributor, Prod_Royalty_Accounting_Royalty_Accounting.Account, Prod_Royalty_Accounting_Royalty_Accounting.Account_Contract + 3 more`
**File Path:** `views/abacus_contracts_linked_to_contributors.view.lkml`

## Overview

- **File Size:** 3926 bytes
- **Lines of Code:** 156
- **Dimensions:** 22
- **Measures:** 0
- **Dimension Groups:** 0
- **Filters:** 0

## Dimensions

| Name | Type |
|------|------|
| `ACCOUNT_ID` | string |
| `ACCOUNT_NAME` | string |
| `CONTRACT_ID` | string |
| `CONTRACT_NAME` | string |
| `TERM_START` | date |
| `TERM_END` | date |
| `IS_PRIMARY_CONTRACT` | string |
| `CONTRIBUTOR_ID` | string |
| `CONTRIBUTOR` | string |
| `CONTRACT_TERM_ID` | string |
| `CONTRACT_TERM_NAME` | string |
| `IS_PRIMARY_CONTRACT_TERM` | string |
| `CONTRIBUTION_ID` | string |
| `SOUND_RECORDING_ID` | string |
| `RECORDING_TITLE` | string |
| `VERSION` | string |
| `MAIN_ARTIST` | string |
| `ISRC` | string |
| `FIRST_RELEASE_YEAR` | string |
| `CONTRIBUTION_TYPE` | string |
| `VALID` | string |
| `LAST_CONTRIBUTION_MODIFIED` | string |

## SQL Comments

- track details

## Derived Table

```sql
sql:
      select
  a.account_id,
  a.account_name,
  c.contract_id,
  c.contract_name,
  c.term_start,
  c.term_end,
  ac.is_primary_for_calc is_primary_contract,
  to_char(ar.value) contributor_id,
  nc.name contributor,
  ct.contract_term_id,
  ct.contract_term_name,
  ct.is_base_term is_primary_contract_term,
replace(con.value,'"','') contribution_id,
sr.id sound_recording_id,
sr.recording_title,
sr.version,
sr.main_artist,
sr.isrc,
sr.first_release_year,
cont.contribution_type,
nrbution.valid,
cont.last_modified_at last_contribution_modified
from
  orchard_app_reporting_v2.prod_royalty_accounting_royalty_accounting.account a
  left join orchard_app_reporting_v2.prod_royalty_accounting_royalty_accounting.account_contract ac on ac.account_id = a.account_id
  left join orchard_app_reporting_v2.prod_royalty_accounting_royalty_accounting.contract c on c.contract_id = ac.contract_id
  left join orchard_app_reporting_v2.prod_royalty_accounting_royalty_accounting.contract_term ct on ct.contract_id = c.contract_id
    join (lateral flatten (input => parse_json (ct.attachments_relations),path=>'contributor_ids')) ar
join facts.prod.performance_nr_contributor nc on nc.id=ar.value
left join table(flatten (input => ct.attachments, outer => TRUE)) con
join orchard_app_reporting_v2.prod_royalty_accounting_royalty_accounting.run_controller_contract rcc on rcc.contract_id=c.contract_id
--track details
inner join FACTS.prod.performance_nr_contribution nrbution on con.value = nrbution.id
inner join FACTS.prod.nr_contribution_type cont on nrbution.id = cont.nr_contribution_id and cont.is_deleted not like true
inner join FACTS.prod.nr_contribution_contributed_to_nr_sound_recording nsr on nrbution.id = nsr.nr_contribution_id
inner join FACTS.prod.performance_nr_sound_recording sr on nsr.nr_sound_recording_id = sr.id

where rcc.run_controller_id in (6,11)
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22;;
```

