I have some data in database:
id user 1 zhangsan 2 zhangsan 3 zhangsan 4 lisi 5 lisi 6 lisi 7 zhangsan 8 zhangsan
I want keep order, a
I think what you are looking for is to COUNT(ID):
SELECT COUNT(ID) FROM table GROUP BY user