# Getting Distinct Rows While Still Returning Other Fields

**URL:** <https://www.ruby-forum.com/t/getting-distinct-rows-while-still-returning-other-fields/88466>\
**Category:** Rails\
**Created:** [March 11, 2007, 4:27pm UTC](https://www.ruby-forum.com/t/getting-distinct-rows-while-still-returning-other-fields/88466 "2007-03-11T16:27:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [March 11, 2007, 4:27pm UTC](https://www.ruby-forum.com/t/getting-distinct-rows-while-still-returning-other-fields/88466/1 "2007-03-11T16:27:57Z")

</div>

On occasion I encounter this problem but I never remember how I fix it  
the time before… which is annoying for myself.

I have the following find:  
@conversations = Message.find(:all, :select =\> “DISTINCT from\_user\_id,  
created\_at”, :conditions =\> [“to\_user\_id = ?”, session[:user\_id]])

I want distinct from\_user\_id but at the same time I want to have other  
fields removed like created\_at. If I return more then from \_user\_id I  
am not getting distinct from\_user\_ids…

What is the rails way of solving my problem? 🙂

## Thanks eveyone for helping me out! 🙂

John K.  
removed\_email\_address@domain.invalid

[http://www.kopanas.com](http://www.kopanas.com)

> **[Canadian University Software Engineering Conference - CUSEC](http://cusec.net/)**
>
> Canadian University Software Engineering Conference is a yearly conference created by students for students.

[http://www.soen.info](http://www.soen.info)
