select CASE WHEN rank and rank 10 THEN WHEN rank 11 and rank 20 THEN W

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
select s.*,
CASE
WHEN rank >= 1 and s.rank <= 10 THEN 1
WHEN rank >= 11 and s.rank <= 20 THEN 2
WHEN rank >= 21 and s.rank <= 30 THEN 3
WHEN rank >= 31 THEN 0
END as AccountType
FROM
(
SELECT u.ID, @rownum := @rownum + 1 AS rank
FROM
Users u,
(SELECT @rownum := 0) r
) as s