select menu_title,
totalDays,
totalCooked
from (select menu_title,
count(*) as cookedTimes,
1 as idx
from cookrecord
WHERE uid = 22
GROUP BY menu_title
order by cookedTimes DESC limit 1) a
left join
(select
count(*)as totalDays,
sum(num) as totalCooked,
1 as idx
from
(select id,
count(*) as num
from cookrecord
where uid = 22
GROUP BY day(gmtCreate)
order by num) t1)t2
on a.idx = t2.idx
网友评论