list using a sql statement

I think it would be worth your while working through some tutorials
and guides. Have a look at the guides at for a start. Agile Development with
Rails is an excellent book. The tutorial at is good. Make sure that any tutorial
you try is for rails 2.3.

For your particular problem I would suggest using named_scope.