mysql 百分比保留小数点后两位:
concat(TRUNCATE(SUM(ag.net_amount)/SUM(ag.net_amount)* 100, 2),’%’) as winning
mysql 操作保留小数点后两位:
COUNT(IF(IFNULL(mg1.amount,-mg.amount)>0,mg1.amount,NULL))/COUNT(mg.amount) as value
按最新时间addtime ,过滤phoneid重复超过5条的信息,保留5条内的信息
select phoneid,media_id,metatype,title,addtime,new_rank as rank from (select phoneid,media_id,metatype,title,addtime, IF(@tmp=phoneid,@rank:=@rank + 1,@rank:=1) as new_rank, @tmp:=phoneid as tmp from phone_playhistory order by phoneid,addtime desc)b where new_rank < 6;