select id,num,rank from (
select heyf_tmp.id,heyf_tmp.num,@rownum:=@rownum+1 ,
if(@pdept=heyf_tmp.id,@rank:=@rank+1,@rank:=1) as rank,
@pdept:=heyf_tmp.id
from (
select id,num from (SELECT
t.OPERATE_LOG_USER_ID AS id,
t.OPERATE_SEARCH_WORD AS word,
COUNT(*)AS num
FROM
skp_operate_log AS t
WHERE
t.OPERATE_LOG_TIME
GROUP BY
id,
word
ORDER BY
num DESC)tt order by id asc ,num desc
) heyf_tmp ,(select @rownum :=0 , @pdept := null ,@rank:=0) a ) result
)ttt
where rank in(1,2)
统计所有记录的数量:SELECT COUNT(*) FROM table_name
统计某列的数量:
SELECT COUNT(column_name) FROM table_name
where 条件
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)