Skip to content

Instantly share code, notes, and snippets.

@mmrobins
Created September 19, 2018 17:54
Show Gist options
  • Save mmrobins/14f814da9c3f7e4d22cbbd94ae4b6668 to your computer and use it in GitHub Desktop.
Save mmrobins/14f814da9c3f7e4d22cbbd94ae4b6668 to your computer and use it in GitHub Desktop.
first passport data issue query in ecto
alias Db.Salesforce.{FieldMapping, Organization, SObjectType}
alias Db.Repo
import Ecto.Query
mappings =
from(
[fm, o, t, f, af] in FieldMapping.joined_query(),
where: t.name == "lead",
select: [af.name, t.name, o.code, fragment("group_concat(?)", f.field)],
group_by: [af.name, t.name, o.code],
having: count("*") > 1
) \
|> Repo.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment