select sum(if(performance =1,1,0)) as p1, sum(if(performance =2,1,0)) as p2, ... sum(if(performance =5,1,0)) as p5 from comment where status=1 and jid=1
select max(pCnt),t.performance from (select count(performance) as pCnt ,performance from comment where jid=1) t
忘了加上这个group by performanceselect max(pCnt),t.performance from (select count(performance) as pCnt ,performance from comment where jid=1 group by performance) t
select max(pCnt),t.performance from (select count(performance) as pCnt ,performance from comment where jid=1 group by performance) t 这个是求某个分数的个数最多的select max(pSum),t.performance from (select sum(performance) as pSum ,performance from comment where jid=1 group by performance) t 这个是求某个分数总计起来最大的
select cid,performance,count(performance) from comment where jid=4022 and status=1 GROUP BY performance order by COUNT(performance) desc这样可以解决了,还是谢谢你们
这样 select t2.performance from (select max(pSum),t.performance from (select sum(performance) as pSum ,performance from comment where jid=1 group by performance) t ) t2
sum(if(performance =2,1,0)) as p2,
...
sum(if(performance =5,1,0)) as p5
from comment where status=1 and jid=1
from
(select count(performance) as pCnt ,performance from comment where jid=1) t
from
(select count(performance) as pCnt ,performance from comment where jid=1 group by performance) t
from
(select count(performance) as pCnt ,performance from comment where jid=1 group by performance) t
这个是求某个分数的个数最多的select max(pSum),t.performance
from
(select sum(performance) as pSum ,performance from comment where jid=1 group by performance) t
这个是求某个分数总计起来最大的
from
comment
where jid=4022 and status=1
GROUP BY performance
order by COUNT(performance) desc这样可以解决了,还是谢谢你们
select t2.performance from
(select max(pSum),t.performance from
(select sum(performance) as pSum ,performance from comment where jid=1 group by performance) t ) t2