美文网首页
将2个无关联的select结果一同输出

将2个无关联的select结果一同输出

作者: 一Fu | 来源:发表于2016-12-05 15:07 被阅读0次

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

相关文章

网友评论

      本文标题:将2个无关联的select结果一同输出

      本文链接:https://www.haomeiwen.com/subject/akokmttx.html