Distinct Query Expression in Ecto
In an Ecto query expression, use distinct: true
to ensure the values returned from your query are distinct.
from(u in User, distinct: true, select: u.first_name)
You can also use distinct with an expression to be more specific
from(u in User,
distinct: last_name,
order_by: [asc: :last_name])
Tweet