Mysql using SUM and DISTINCT - Why not use GROUP
Yes the answers in the title . Consider
SELECT SUM(DISTINCT te.field_company_total_employees_value) FROM field_data_field_company_total_employees AS te INNER JOIN field_data_field_user_company AS uc ON te.entity_id = uc.field_user_company_target_id INNER JOIN field_claiming_user AS cu ON uc.entity_id = cu.field_claiming_user_target_id INNER JOIN field_data_field_urn_offer as uo ON cu.entity_id = uo.entity_id WHERE uo.field_urn_offer_target_id = 20 GROUP BY te.id
Produced the results wanted.
No comments:
Post a Comment