this is a table name test1
id Roll Rank Grade
1 10 50 A
2 20 60 B
3 30 40 X
4 20 50 A
5 30 90 O
6 10 80 C
want result in following format :
id Roll Rank Grade
1 10 50,80 A,C
2 20 60,80 B,A
3 30 40,90 X,O
This will do the trick:
SELECT id, Roll, GROUP_CONCAT(Rank), GROUP_CONCAT(Grade)
FROM your_table
GROUP BY Roll
HAVING COUNT(*) > 1