http://blog.csdn.net/isoleo/article/details/50817976
http://blog.csdn.net/acmain_chm/article/details/4126306
1、添加行号,b表没实质作用,只是添加行号,(增加一列)的一个操作
select @r:= @r+1 as row_no, pkgname, coefficient, model_id
from a ,
(select @r:=0 ) b
limit 10;
2、生成分组序号,MySQL没有row_number(),partition 功能函数,下列语句是按照model_id分组,
select
@group_row:= case when @model_id=a.model_id then @group_row+1 else 1 end as group_row,
@model_id:=a.model_id as model_id,
a.coefficient,a.pkgname
from `getui_tag`.`model_coefficient` a ,
(select @group_row:=1,@model_id:='' ) b
limit 100;