我对msq无能为力。表中的Multil计数

时间:2015-05-24 02:52:50

标签: mysql

$sql = SELECT `id`, `email`, `avatar`,`fullname`,
        SUM(result) as sum_result,
        SUM(total) as sum_total,
        COUNT(rank)  as `top_1` where `itq_exam_thread_test`.`rank` = 1, 
        COUNT(rank)  as `top_2` where `itq_exam_thread_test`.`rank` = 2,
        COUNT(rank)  as `top_3` where `itq_exam_thread_test`.`rank` = 3
GROUP BY userid_created
ORDER BY sum_result DESC, sum_rate DESC
LIMIT 0, 100';

0 个答案:

没有答案