In a rails application I need to return an ActiveRecord collection containing multiple columns, but only 1 column must be unique. There is a default scope which is not the unique value.
Default Scope
default_scope { order('executed_at DESC') }
Current query WITHOUT unique :terms.
Search.where(organization_id: @my_array_of_ids)
.executed_after(from_date_time)
.limit(100)
.pluck(:terms)
executed_after(from_date_time) is a scope as well. How can I alter the above query to return unique terms without using the .uniq method? I want this to be a single SQL statement.