I have the following query:
SELECT p.`ID`, (SELECT COUNT(`ID`) FROM `comments` c WHERE c.`post_id` = p.`ID`) AS `comments`, (SELECT COUNT(`ID`) FROM `likes` l WHERE l.`post_id` = p.`ID`) AS `likes` FROM `posts` p
I want to order the results according to the third column, which will be calculated the following way:
order = comments * 6 + likes * 4
How can I create this "virtual" column and use the results of the other two in a calculation?