mysql & clinkhouse之查询添加比率列
1.clinkhouse比较特殊基于Java,如果是数字还得强转
select t1.area_name,t1.nums,t2.allcount,concat(toString(round(((t1.nums/t2.allcount)*100),2)),'%') as rate from ( select start_area_name as area_name,count(1) as nums from t_car_order group by start_area_name ) t1, ( select count(1) as allcount from t_car_order ) t2
2.mysql的话 去掉tostring就好
select t1.area_name,t1.nums,t2.allcount,concat(toString(round(((t1.nums/t2.allcount)*100),2)),'%') as rate from ( select start_area_name as area_name,count(1) as nums from t_car_order group by start_area_name ) t1, ( select count(1) as allcount from t_car_order ) t2
3.效果图如下
-----------------------------------------------------------------------------------------------------------------------------------------