bad_results=Qx.select("CONCAT(custom_field_joins.supporter_id, '_', custom_field_joins.custom_field_master_id) AS our_concat, COUNT(id) AS our_count").
from(:custom_field_joins).
group_by("our_concat").
having('COUNT(id) > 1').parse
custom_field_joins_from_qx=CustomFieldJoin.
where("CONCAT(custom_field_joins.supporter_id, '_', custom_field_joins.custom_field_master_id) IN (SELECT our_concat FROM (#{bad_results}) AS ignore)").