SELECT DATE_FORMAT(SYSDATE(),'%Y-%m-%d') AS date;
-- 2021-06-05
SELECT DATE_FORMAT(SYSDATE(),'%Y-%m-%d %H:%i:%s') AS dateTime;
-- 2021-06-05 15:06:30
SELECT total,dept_name from
(select @gn:=case when @dept_name=dept_name then @gn+1 else 1 end gn,@dept_name:=dept_name dept_name, total
from
(select count(*) total,l.dept_name from sys_login_log l group by l.dept_id having l.dept_id is not null) aa,
(select @gn:=1) bb order by total desc) tmp where gn <=10;