Depending on the use case you can probably use the :group by operator.