小数转换为百分比形式
一 使用java实现
import java.text.DecimalFormat;
public class decimal {
    public static void main(String[] args) { 
        DecimalFormat df = new DecimalFormat("0%");
        DecimalFormat df1 = new DecimalFormat("0.00%");
        System.out.println(df.format(Double.parseDouble(args[0])));
        System.out.println(df1.format(Double.parseDouble(args[0])));
    }
}

二 使用sql操作
SELECT CONCAT( TRUNCATE ( 2 / 13 * 100, 2 ), '%' ) AS poi	#15.38%
SELECT CONCAT( TRUNCATE ( 2 / 13 * 100, 0 ), '%' ) AS poi	#15%
                                    
                    
                
                
            
        
浙公网安备 33010602011771号