Home >Backend Development >PHP Tutorial >MYSQL 排名排序有关问题

MYSQL 排名排序有关问题

WBOY
WBOYOriginal
2016-06-13 10:34:03829browse

MYSQL 排名排序问题
SELECT sum( `yb2000_event_point` ) , `yb2000_event_phone`, `yb2000_event_riqi` FROM yb2000_event WHERE yb2000_event_riqi LIKE '%2012%' GROUP BY yb2000_event_phone order by sum( `yb2000_event_point` ) desc 

用这语句查出来了 用户的一年积分总排行 可是我想加个 条件 查出来某人的 积分数和排行 可是排行没法取 个位 大师 请教下

------解决方案--------------------
SET @rank =0;
select * from (SELECT @rank := @rank +1 AS rank, yb2000_event_phone, yb2000_event_point,user_id
FROM yb2000_event
GROUP BY yb2000_event_phone
ORDER BY yb2000_event_point)a where a.user_id='user_id'
给我分嚓

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn