select result.* from (
select heyf_tmp.*,@rownum:=@rownum+1, if(@pdept=heyf_tmp.group_no,@rank:=@rank+1,@rank:=1) as rank, @pdept:=heyf_tmp.group_no from ( select * from commodity_package order by detail_id asc ) heyf_tmp ,(select @rownum :=0 , @pdept := null ,@rank:=0) a ) result where result.package_id = 4 and result.rank = 1 ; |
|