# Find\_by\_sql distinct

**URL:** <https://www.ruby-forum.com/t/find-by-sql-distinct/50124>\
**Category:** Rails\
**Created:** [December 13, 2005, 9:45am UTC](https://www.ruby-forum.com/t/find-by-sql-distinct/50124 "2005-12-13T09:45:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [December 13, 2005, 9:45am UTC](https://www.ruby-forum.com/t/find-by-sql-distinct/50124/1 "2005-12-13T09:45:40Z")

</div>

hey,

i have this sql statement  
@all\_clients = Client.find\_by\_sql(“select distinct \* from clients  
…”)

is there any other way for implementing this “distinct” into an sql  
statment  
with parameters??

thanks in adavance  
Nick

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 10, 2008, 4:01pm UTC](https://www.ruby-forum.com/t/find-by-sql-distinct/50124/2 "2008-01-10T16:01:26Z")

</div>

Yes, with

@all\_clients = Client.find(:all, :select =\> “DISTINCT x”

where x will be the column you want to discriminate with.

Brutyn N. wrote:

> hey,
> 
> i have this sql statement  
> @all\_clients = Client.find\_by\_sql(“select distinct \* from clients  
> …”)
> 
> is there any other way for implementing this “distinct” into an sql  
> statment  
> with parameters??
> 
> thanks in adavance  
> Nick
