0

I cannot ORDER BY the dt_contacted field. No matter which way I have done this, it keeps on listing in the order it was entered by.

SELECT leads.*, historical.history
FROM leads
    LEFT JOIN (SELECT lead_id,
                    group_concat( concat( DATE_FORMAT(dt_contacted,"%m-%d-%Y %h:%i %p"),": ",action," ",note,"\n" ) SEPARATOR " " )
                        AS history                     
                FROM (SELECT * 
                        FROM lead_actions 
                        ORDER BY TIMESTAMP(dt_contacted) DESC) hist
                GROUP BY lead_id               
            ) AS historical
    ON leads.id = historical.lead_id
WHERE leads.id = :button_id
Rick James
  • 135,179
  • 13
  • 127
  • 222

0 Answers0