id | user_id | level_id
1 | 5 | 7
2 | 5 | 6
3 | 4 | 9
select count(*) as cnt
from (select user_id
from table
group by user_id)