# View: generated_income_summary_sum_function

**View Name:** generated_income_summary_sum_function
**Table Source:** `Derived Table (Custom SQL)`
**File Path:** `views/generated_income_summary_sum_function.view.lkml`

## Overview

- **File Size:** 2526 bytes
- **Lines of Code:** 45
- **Dimensions:** 1
- **Measures:** 0
- **Dimension Groups:** 0
- **Filters:** 0

## Dimensions

| Name | Type |
|------|------|
| `SUM` | number |

## Derived Table

```sql
sql:
    SELECT SUM(source_usd) SUM
    FROM ( SELECT
      (CASE WHEN (rpd.agreement_nr_agreement_type LIKE '%Performer%') THEN rpd.royalty_sub_account_ip_id ELSE null END) con_id
,     (CASE WHEN (rpd.agreement_nr_agreement_type LIKE '%Performer%') THEN rpd.interested_party_sub_account_name ELSE null END) contributor_name
,     rpd.royalty_period_start_date start_date
,     rpd.royalty_period_end_date end_date
,     rpd.recording_id wrc_id
,     rpd.recording_title title
,     rpd.recording_subtitle version
,     rpd.recording_isrc isrc
,     rpd.recording_artist artist
,     rpd.right_type_description right_type
,     rpd.agreement_id agr_id
,     rpd.interested_party_assignor_name assignor_name
,     rpd.agreement_client_rights client_rights
,     rpd.agreement_nr_agreement_type incoming_type
,     rpd.interested_party_source_name source_cmo
,     r.description right_description
,     rpd.agreement_payment_currency_abbreviation agr_curr
,     "sum"(rpd.roy_pay_fin_acc_chain_source_amount) source_acc
,     "sum"(rpd.roy_pay_fin_acc_payment_wht_adjusted_amount) distributed_acc
,     "sum"(((rpd.roy_pay_fin_acc_chain_source_amount / (1 - COALESCE((rpd.batch_wht_percentage / 100), (rpd.royalty_wht_percentage / 100)))) - rpd.roy_pay_fin_acc_chain_source_amount)) wht_acc
,     "sum"(rpd.roy_pay_fin_usd_chain_source_amount) source_usd
,     "sum"(rpd.roy_pay_fin_usd_payment_wht_adjusted_amount) distributed_usd
,     "sum"(((rpd.roy_pay_fin_usd_chain_source_amount / (1 - COALESCE((rpd.batch_wht_percentage / 100), (rpd.royalty_wht_percentage / 100)))) - rpd.roy_pay_fin_usd_chain_source_amount)) wht_usd
,     rpd.territory_name terr_name
,     rpd.roy_pay_payment_date payment_date
,     rpd.reconciliation_max_payment_date reconciliation_date
,     rpd.agreement_assignor_id agreement_assignor_id
    FROM
      ("AWAL_SAX"."RDL_DATASETS"."ROYALTY_PAYMENT_DETAIL" rpd
    LEFT JOIN "AWAL_SAX"."SAX"."RIGHTS" r ON (rpd.roy_pay_right_id = r.id))
    WHERE ((((rpd.agreement_client_rights = 'Neighbouring Rights') AND (rpd.agreement_outgoing_type_id = 'AOT2')) OR (((rpd.agreement_client_rights = 'Recording Rights') AND (rpd.reconciliation_type = 'Neighbouring Rights')) AND (rpd.agreement_outgoing_type_id = 'AOT2'))) AND (rpd.roy_pay_payment_date >= date '2012-01-01'))
    GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 24, 25, 26, 27)
;;
```

