select *,CONCAT(ROUND(100*ciriliucun/huoyue,2),'%') ciri from( select DATE_FORMAT(a.logindate,'%Y-%m-%d') time,count(DISTINCT(a.userId)) huoyue,count(DISTINCT(b.userId)) ciriliucun from log a LEFT JOIN log b on a.userId = b.userId and STR_TO_DATE(b.logindate,'%Y-%m-%d') = DATE_FORMAT(DATE_ADD(STR_TO_DATE(a.logindate,'%Y-%m-%d'),INTERVAL 1 DAY),'%Y-%m-%d') GROUP BY time ) p LIMIT 7;