1.排列顺序
SELECT (@i:= @i + 1) AS rank,
dept_id as org_id,dept_name as org_name,spare1 as total_points FROM sys_dept,(SELECT (@i := 0) ) r
order by spare1 desc;
2.为null填写默认字段
SELECT (@i:= @i + 1) AS rank,
dept_id as org_id,dept_name as org_name,IFNULL(spare1,0) as total_points FROM sys_dept,(SELECT (@i := 0) ) r
order by spare1 desc;