我有以下查询:
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
我想根据第三列对结果进行排序,将按以下方式计算:
order = comments * 6 + likes * 4
如何创建这个“虚拟”列并在计算中使用其他两个的结果?
谢谢!