Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
SELECT DATE_FORMAT(t.datetime, '%Y-%m-%d') AS `date`, count(t.id), count(a.id), sum(a.affiliate_sum), sum(a.order_sum) FROM transitions AS t INNER JOIN affiliates a ON a.transition_id = t.id GROUP BY `date`
SELECT c.id, c.name FROM orders AS o INNER JOIN clients c ON o.id_client=c.id GROUP BY o.id_client HAVING count(o.id_client) > 3