SELECT channel,game_id,count(*) AS more_positive_user FROM (
SELECT channel,game_id, user_id FROM netgame_platform_log_login_user WHERE date='2014-12-30' 
GROUP BY channel,game_id, user_id HAVING count(*)>=5
) AS a GROUP BY channel,game_id新手求教能实现上面查询的更加高效简单的sql语句~

解决方案 »

  1.   

    使用 COUNT(DISTINCT expr,[expr...]) Returns a count of the number of rows with different non-NULL expr values. COUNT(DISTINCT) returns 0 if there were no matching rows. mysql> SELECT COUNT(DISTINCT results) FROM student;In MySQL, you can obtain the number of distinct expression combinations that do not contain NULL by giving a list of expressions. In standard SQL, you would have to do a concatenation of all expressions inside COUNT(DISTINCT ...).