Answer the question
In order to leave comments, you need to log in
How to make that the subquery is not considered each time?
SELECT `id`, ROUND(`views`/(2020 - `releaseDate` + 1)*100/(SELECT ROUND(`views`/(2020 - `releaseDate` + 1)) pop FROM `manga` ORDER BY pop DESC LIMIT 1)) pop FROM `manga` WHERE `active` = 1 ORDER BY pop DESC LIMIT 10
(SELECT ROUND(`views`/(2020 - `releaseDate` + 1)) pop FROM `manga` ORDER BY pop DESC LIMIT 1)
Answer the question
In order to leave comments, you need to log in
SELECT `t`.`id`, ROUND(`t`.`views`/(2020 - `t`.`releaseDate` + 1)*100/`m`.`max`) AS `pop`
FROM `manga` AS `t`
JOIN (
SELECT MAX(ROUND(`views`/(2020 - `releaseDate` + 1))) AS `max`
FROM `manga`
) AS `m`
WHERE `t`.`active` = 1
ORDER BY `pop` DESC
LIMIT 10
SELECT
t.`id`,
<your_subquery>
FROM (
SELECT *
FROM `manga`
WHERE `active` = 1
ORDER BY pop DESC LIMIT 10) t
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question