Aggregation function on custom field error
When I try to create a data processor with aggregation function (SUM) on a custom field produces "DB Error: no such field". When I check the log, the error is related to the custom field being missing because the name of the field used in the query is not correct.
Here is the query that generates the error where the field "contribution_Gifts_US_Amount" is not in my database. The actual field name in the custom field value table is us_amount_101
- SELECT COUNT( * ) AS count FROM ( SELECT DISTINCT SUM(
contribution_Gifts
.contribution_Gifts_US_Amount
) ASsum
,address
.country_id
AScountry
FROM ( SELECT_contribution
.id
ASid
,_contribution
.contact_id
AScontact_id
,_contribution
.financial_type_id
ASfinancial_type_id
,_contribution
.contribution_page_id
AScontribution_page_id
,_contribution
.payment_instrument_id
ASpayment_instrument_id
,_contribution
.receive_date
ASreceive_date
,_contribution
.non_deductible_amount
ASnon_deductible_amount
,_contribution
.total_amount
AStotal_amount
,_contribution
.fee_amount
ASfee_amount
,_contribution
.net_amount
ASnet_amount
,_contribution
.trxn_id
AStrxn_id
,_contribution
.invoice_id
ASinvoice_id
,_contribution
.invoice_number
ASinvoice_number
,_contribution
.currency
AScurrency
,_contribution
.cancel_date
AScancel_date
,_contribution
.cancel_reason
AScancel_reason
,_contribution
.receipt_date
ASreceipt_date
,_contribution
.thankyou_date
ASthankyou_date
,_contribution
.source
ASsource
,_contribution
.amount_level
ASamount_level
,_contribution
.contribution_recur_id
AScontribution_recur_id
,_contribution
.is_test
ASis_test
,_contribution
.is_pay_later
ASis_pay_later
,_contribution
.contribution_status_id
AScontribution_status_id
,_contribution
.address_id
ASaddress_id
,_contribution
.check_number
AScheck_number
,_contribution
.campaign_id
AScampaign_id
,_contribution
.creditnote_id
AScreditnote_id
,_contribution
.tax_amount
AStax_amount
,_contribution
.revenue_recognition_date
ASrevenue_recognition_date
,_contribution
.is_template
ASis_template
,_contribution_soft
.contribution_id
AScontribution_soft_contribution_id
,_contribution_soft
.contact_id
AScontribution_soft_contact_id
,_contribution_soft
.amount
AScontribution_soft_amount
,_contribution_soft
.currency
AScontribution_soft_currency
,_contribution_soft
.pcp_id
AScontribution_soft_pcp_id
,_contribution_soft
.pcp_display_in_roll
AScontribution_soft_pcp_display_in_roll
,_contribution_soft
.pcp_roll_nickname
AScontribution_soft_pcp_roll_nickname
,_contribution_soft
.pcp_personal_note
AScontribution_soft_pcp_personal_note
,_contribution_soft
.soft_credit_type_id
AScontribution_soft_soft_credit_type_id
FROMcivicrm_contribution
_contribution
LEFT JOINcivicrm_contribution_soft
_contribution_soft
ON_contribution
.id
=_contribution_soft
.contribution_id
)contribution
LEFT JOINcivicrm_value_gifts_13
contribution_Gifts
ONcontribution
.id
=contribution_Gifts
.entity_id
INNER JOINcivicrm_address
address
ONaddress
.contact_id
=contribution
.contact_id
WHERE 1 ANDcontribution
.is_test
= 0 ANDcontribution
.receive_date
BETWEEN 20201001000000 AND 20201028235959 ANDaddress
.is_primary
= 1 ORDER BYcountry
ASC )count_combined_sql_data_flow
*
Edited by pdaoud