RE: find by sql


#1
@invoices = Invoice.find_by_sql(pSql);

Try @invoices = Invoice.find(:all, :select => “Distinct invoices.id,
invoices.invoice_number, invoices.approve_date,invoices.sent_date,
invoices.paid_date”,
: join => " ,projects, payments",

			       :Conditions =>["projects.id =

payments.project_id AND payments.invoice_id = invoices.id AND
projects.id = ?",params[:id]])

Although I have not tried it, it should work. If not take a look at the
log file to see what is the sql being generated and customize the above
statement accordingly.

Bharat