/*排名相同情况下,优先按姓名排序*/
SELECT t.`name`, t.company_name, @rownum:[email protected]+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
时间: 2024-09-30 15:46:15