title: In Left join with order by always fetch first data from relational table. (Rails)
body: <p>I have two tables like invoices and receipts</p>
  
  <pre><code>1. invoices
  
      id name    amt   status
      1   test    100   paid
      2   test1   300  not paid
      3   test2   400  not paid
  
  2. receipts
      id amount invoice_id receipt_date
       1  50      1         22-apr-2014  
       2  30      1         24-apr-2014   
       3  30      1         25-apr-2014
  </code></pre>
  
  <p>Following is my query</p>
  
  <pre><code>@invoices_info = Invoice.select("invoices.id as inv_id,receipts.receipt_date as receipt_date,sum(receipts.amount) as receipt_amount")
                        .joins('left join receipts on receipts.invoice_id = invoices.id')
                        .where("invoices.status in ('Paid')")
                        .group("invoices.id").order("receipts.receipt_date desc")
  
  This query shows data as:
   inv_id  receipt_amount receipt_date
     1      100            22-apr-2014
  </code></pre>
  
  <p>So problem is, it fetch first date rather than descending date. I want last receipt date "25-apr-2014".</p>
  
  <p>Can anyone help me?</p>