SELECT `t`.`id_project`, `p`.`title`, `p`.`id`, `p`.`color`, `t`.`task_count`,
`t`.`task_lose`, `t`.`task_active`
FROM (
SELECT `id_project`, COUNT(*) AS `task_count`,
SUM(`status` = '1' AND `deadlines` < :TIME) AS `task_lose`,
SUM(`status` = '1') AS `task_active`
FROM `tasks`
GROUP BY `id_project`
) AS `t`
RIGHT JOIN `projects` AS `p` ON `p`.`id` = `t`.`id_project`
ORDER BY `t`.`task_lose` DESC, `t`.`task_active` DESC,
`t`.`task_count` DESC, `p`.`id` DESC
SELECT `id_project`, COUNT(*) AS `task_count`, SUM(`status` = '1') AS `task_lose`, SUM(`status` = '1') AS `task_active`
from `tasks` group by id_project
$date = new \DateTime('@' . $deadlines);
прописал$date = new \DateTime();
$date->setTimestamp($deadlines);