SQL中只有两列数据(字段1,字段2),将其相同字段1的行转列 转换前: 转换后: --测试数据 if not object_id(N'Tempdb..#T') is null drop table #T Go Create table #T([MDF_LOT_NO] int,[ERP_MODE_CD] int) Insert #T , union all , union all , union all , Go --测试数据结束 DECLARE @name VARCHAR(max),@sql
//整数相除 保留一位小数 public static String division(int a ,int b){ String result = ""; float num =(float)a/b; DecimalFormat df = new DecimalFormat("0.0"); result = df.format(num); return result; }
方式一: double f = 3.1516; BigDecimal b = new BigDecimal(f); , BigDecimal.ROUND_HALF_UP).doubleValue(); 输出结果f1为 3.15: 源码解读: public BigDecimal setScale(int newScale, int roundingMode) //int newScale 为小数点后保留的位数, int roundingMode 为变量进行取舍的方式: BigDecimal.ROU