mysql 实现排名及中文排序实例[分页累加行号]

/*排名相同情况下,优先按姓名排序*/
SELECT t.`name`, t.company_name, @rownum:=@rownum+1 as rankNum, t.ss from (
    SELECT u.`name`, sci.company_name, @rownum:=0,(u.check_num+u.online_hours) as ss FROM v_user u
    LEFT JOIN sys_company_info sci ON u.companyId = sci.company_id
    WHERE u.account_state = '1'
    ORDER BY (u.check_num+u.online_hours) DESC, convert(u.`name` USING gbk) COLLATE gbk_chinese_ci ASC LIMIT 0,20
)t

你可能感兴趣的:(mysql,中文排序,排名,convert,分页累加行号)