MYSQL组内排序
sql语句:
SELECT
b.fxingming,
b.fdepartid,
b.fbeizhu,
IF
( @NAME = b.fdepartid, @rank := @rank + 1, @rank := 1 ) AS rank,
@NAME := b.fdepartid
FROM
( SELECT fdepartid, fxingming, fbeizhu FROM sky_zhigonghuamingce ORDER BY fdepartid ASC, fid ASC ) b,
( SELECT @rownum := 0, @NAME := NULL, @rank := 0 ) a;