I have a table with two columns first for userId & second for marks
+-------+-------+
| UserId | Marks |
+--------+-------+
|      1 |   20  |
|      1 |   20  |
|      3 |   15  |
|      1 |   30  |
|      3 |   20  |
|      4 |   25  |
+--------+-------+
I want to count marks of particalur user and then give rank like 1st or 2nd With userId
+-------+-------+
| UserId | Rank  |
+--------+-------+
|      1 |   1   |
|      3 |   2   |
|      4 |   3   |
+--------+-------+
I have two queries one for Counting marks and second for getting rank but don't know how to combine that both queries and get result like
Queries are :
count total :
SELECT UserId, SUM(Marks) AS total FROM result GROUP BY UserId
Get Rank :
( SELECT UserId, Marks, FIND_IN_SET( Marks, ( SELECT GROUP_CONCAT( Marks ORDER BY Marks DESC ) FROM result ) ) AS rank FROM result ) ORDER BY
rankASC
