You can reference select fields if they're in subqueries:
SELECT c_total + l_total AS Total
FROM (
SELECT
JSON_LENGTH(comments) as c_total,
JSON_LENGTH(likes) as l_total,
(c_total+l_total) as total
FROM posts
) A
;
otherwise I think you have to repeat the logic:
SELECT
JSON_LENGTH(comments) as c_total,
JSON_LENGTH(likes) as l_total,
(JSON_LENGTH(comments) + JSON_LENGTH(likes)) as total
FROM posts
;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…