29.08.2019, 12:03
Если дату хранишь в unix формате то весь запрос выглядит так:
Code:
SELECT ac.name as name, ad.level as level, ad.vigs as vigs, FROM_UNIXTIME(ac.geton_date, '%m.%d.%Y %H:%i') as geton_date, TRUNCATE(( SELECT SUM(o.online_sec) FROM online o WHERE o.account_id = ac.id AND o.date > UNIX_TIMESTAMP(CURDATE()) GROUP BY o.account_id ), 0) as online_sec FROM admin ad LEFT JOIN account ac ON ac.id = ad.admin_id ORDER BY ad.level as level DESC, ac.name as name