Thermatix Thermatix - 5 months ago 9
MySQL Question

order by sum of columns on a per row basis in sequel

I have the following columns:

comments_html,fb_total,google_plus_one,pinterest,linked_in


when added together for a particular row they make up the value total_social on that given row.

the table is
npt_articles


How do I order by the aggregate value
total_social


I'm also using the sequel gem.

Answer

Not sure I understand your quetsion... but this may give you an idea:

SELECT (comments_html+fb_total+google_plus_one+pinterest+linked_in) as 'total_social', *
FROM npt_articles
WHERE <<something>>
ORDER BY 1