MySQL社区

标题: 有没有更好的方法来写这个SQL? [打印本页]

作者: Ronins    时间: 2014-2-26 13:39
标题: 有没有更好的方法来写这个SQL?
各位大神,帮小弟看看有没有更好的方法来写这个SQL; 图片中的count,我想求他的占比,我能想到的方法就是先用一个临时参数把总的数给统计出来,再group by 让count除以临时参数得出占比,有没有更好的SQL来处理例子??

作者: Ronins    时间: 2014-2-26 13:40
..
作者: admin    时间: 2014-2-26 16:00
还没想到...
作者: oracleworm    时间: 2014-3-13 12:27
select count/(select sum(count) from table) from table;
作者: nycle    时间: 2014-3-13 19:59
good{:soso_e179:}




欢迎光临 MySQL社区 (http://www.mysqlpub.com/) Powered by Discuz! X3.2